solr-api accessing document field is taking a lot of time

66 Views Asked by At

I am trying to access a field in custom request handler. I am accessing it like this for each document:

Document doc;
doc = reader.document(id);
DocFields = doc.getValues("state");

There are around 600,000 documents in the solr. For a query running on all the docs, it is taking more than 65 seconds.

I have also tried SolrIndexSearcher.doc method, but it is also taking around 60 seconds.

Removing the above lines of code bring down the qtime to milliseconds. But, I need to access that field for my algo.

Is there a more optimised way to do this?

1

There are 1 best solutions below

4
On

It seems that you querying one document at a time which is slow. If you need to query all documents try to query *:*(instead of asking for a specific id) and then iterate over the results.