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 Prafful Nagpal <pr...@hotmail.com> on 2016/11/23 11:51:11 UTC
Need to know how to read from solr index from update processor
Hi All
I have developed a script through which I am able to search on single core of solr cloud setup
What i want to know is there a way through which i can search the entire collection ( all cores and shards ) with unique key and get a field of that document .
var Term = Java.type("org.apache.lucene.index.Term");
previousDocId= req.getSearcher().getFirstMatch(new Term("id","unique id"));
previousDoc=req.getSearcher().doc(previousDocId);
previousData= previousDoc.getField("data_ws").stringValue();
doc.setField("data_ws",previousData+currData);
Sent from Outlook<http://aka.ms/weboutlook>
Re: Need to know how to read from solr index from update processor
Posted by Erick Erickson <er...@gmail.com>.
This looks at first blush like an XY problem. Making a script
work in SolrCloud is simple, just distribute it to all your replicas,
update your configs and reload the collection.
What's not simple is that apparently you want to pull data from the
last doc indexed. There's no guarantee at all (and, indeed, a very
high likelihood) that doc1 will to go one shard and doc2 will go to another,
this script would only find the id of the previousDocId if it happened
to land on the same shard. You'd have to search your entire collection
(all the shards) to find what you're looking for if you have more than
one shard.
What are you hoping to accomplish here? It seems like keeping the state
of the last doc indexed would be better done on the indexing client.
Best,
Erick
Best,
Erick
On Wed, Nov 23, 2016 at 3:51 AM, Prafful Nagpal
<pr...@hotmail.com> wrote:
> Hi All
>
>
> I have developed a script through which I am able to search on single core of solr cloud setup
>
> What i want to know is there a way through which i can search the entire collection ( all cores and shards ) with unique key and get a field of that document .
>
>
> var Term = Java.type("org.apache.lucene.index.Term");
> previousDocId= req.getSearcher().getFirstMatch(new Term("id","unique id"));
> previousDoc=req.getSearcher().doc(previousDocId);
> previousData= previousDoc.getField("data_ws").stringValue();
> doc.setField("data_ws",previousData+currData);
>
>
>
> Sent from Outlook<http://aka.ms/weboutlook>