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 "Poulton, Gareth | Gareth | DU" <ga...@mail.rakuten.com> on 2011/10/20 09:06:59 UTC

Doing a search inside an UpdateRequestProcessor

Hi,
I'm still fairly new to solr, so please bear with me.
I'm having an amount of difficulty doing a search inside an update request processor (as in, solr.update.processor.UpdateRequestProcessorChain ) that I'm trying to write. As far as I can see there's two main options, each of which is presenting a problem for me:

(1) Getting a searcher from req, i.e. SolrIndexSearcher searcher = req.getSearcher(). The problem here is that I don't see how to get a SolrDocumentList or similar from this, only regular Lucene schema-less Documents.

(2) Using solrj by doing a SolrServer server = new EmbeddedSolrServer(req.getCore());. The problem here is that (a) it uses a deprecated constructor, and (b) creating a new SolrServer on every request seems wasteful - I'd like to be able to just create one once ever without having to do anything unpleasant with static variables or modifying code outside of the class that I'm writing, if possible.

So, if anyone can shed light on how to any of (a) get a SolrDocumentList from a SolrIndexSearcher, (b) the procedure to combine a Schema and a Lucene Document to retrieve the results into something useful, (c) if there's already any SolrServer instances somewhere global that I can get a handle to, or (d) if there's an approved way of persisting objects in RequestProcessors across queries, then that would be great.

Cheers,
Gareth


Re: Doing a search inside an UpdateRequestProcessor

Posted by Ahmet Arslan <io...@yahoo.com>.
> I'm still fairly new to solr, so please bear with me.
> I'm having an amount of difficulty doing a search inside an
> update request processor (as in,
> solr.update.processor.UpdateRequestProcessorChain ) that I'm
> trying to write. As far as I can see there's two main
> options, each of which is presenting a problem for me:
> 
> (1) Getting a searcher from req, i.e. SolrIndexSearcher
> searcher = req.getSearcher(). The problem here is that I
> don't see how to get a SolrDocumentList or similar from
> this, only regular Lucene schema-less Documents.

There is a SolrPluginUtils class that you can use. With this you can convert  Lucene schema-less Documents to SolrDocumentList

SolrDocumentList list = docListToSolrDocumentList(docList, req.getSearcher(), fields, null);

for (final SolrDocument document : list) {..}

http://lucene.apache.org/solr/api/org/apache/solr/util/SolrPluginUtils.html