You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Marcus Paradies <ma...@gmail.com> on 2011/08/15 18:49:48 UTC
SolrJ and ContentStreams
Hi
I'm considering to use SolrJ to run queries in a MLT fashion against my Solr
server. I saw that there is already an open bug filed in Jira
(https://issues.apache.org/jira/browse/SOLR-1085).
My questions is:
Is it possible to use content streams to pass a data stream to the MLT
handler in SolrJ?
Ideally I'd like to do something like
http://localhost:8983/solr/mlt?stream.body=electronics%20memory&mlt.fl=manu,cat&mlt.interestingTerms=list&mlt.mintf=0
in SolrJ. Currently I'm defining most of the MLT specific parameters in the
solrconfig.xml. Is that possible in SolrJ?
Thanks,
Marcus
--
View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-and-ContentStreams-tp3256237p3256237.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: SolrJ and ContentStreams
Posted by Marcus Paradies <ma...@gmail.com>.
Thanks Chris!
That was very helpful and solved my problem.
--
View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-and-ContentStreams-tp3256237p3278026.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: SolrJ and ContentStreams
Posted by Chris Hostetter <ho...@fucit.org>.
: I'm considering to use SolrJ to run queries in a MLT fashion against my Solr
: server. I saw that there is already an open bug filed in Jira
: (https://issues.apache.org/jira/browse/SOLR-1085).
note that that issue is really just about having convinience classes for
executing MLT style requests and parsing hte responses. Just because
those convinience methods/classes don't exist yet doesn't mean you can't
use SolrJ to send MLT requests. You can instantiate a QueryRequest object
with the SolrParams you want to specify for MLT, and then extract the data
you want directly from the QueryResponse.
The only potentially tricky part is sending an arbitrary ContentStream.
in your example you are using the "stream.body" for a short string -- this
is easy to do as a param when building a QueryRequest object, but if you
want to provide a much larger stream of data you can subclass
QueryRequest to add your own ContentStream (from a File Source or
whatever) to the Collection it will stream to hte server.
For that matter, even though it's name might fool you, i'm pretty sure you
a "ContentStreamUpdateRequest" instance with the appropriate URL for your
MLT handler will do exactly what you want.
https://lucene.apache.org/solr/api/org/apache/solr/client/solrj/request/ContentStreamUpdateRequest.html
https://lucene.apache.org/solr/api/org/apache/solr/client/solrj/request/AbstractUpdateRequest.html#setParam%28java.lang.String,%20java.lang.String%29
-Hoss