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 <praffulnag...@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>