I use the recent Solr 4.2.1 solrj libraries.
I am trying to execute an MLT request from a java program. It works fine while I only provide small pieces in stream.body, but this view defeats my purpose.
When I try to use a ContentStream, I get no response, when I make a solr.query request, it makes another request.
It looks like the server is getting my solr.request () ok. Appreciate any pointers.
Oh and I speak with solr 3.6.1
Here is what I still have:
import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.SolrDocumentList; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.common.util.NamedList; import org.apache.solr.client.solrj.*; import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.common.*; import java.io.DataInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.net.MalformedURLException; import org.apache.solr.client.solrj.request.AbstractUpdateRequest; import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest; import org.apache.solr.client.solrj.util.ClientUtils; public class SolrJSearcher { public static void main(String[] args) throws MalformedURLException, SolrServerException { HttpSolrServer solr = new HttpSolrServer("http://localhost:8983/solr"); ModifiableSolrParams params = new ModifiableSolrParams(); String mltv[] = {"Big bunch of text for testing - redacted for brevity"}; String dvalues[] = {"mlt"}; String svalues[] = {"0"}; ContentStreamUpdateRequest up = new ContentStreamUpdateRequest("/mlt"); ContentStream cs = new ContentStreamBase.StringStream(mltv[0]); up.addContentStream( cs); SolrQuery theQuery = new SolrQuery();; theQuery.set("qt", dvalues); up.setParam("start", "0"); try { solr.request(up); } catch (IOException e) {
source share