Search document by id very slow

2019-07-31 19:02发布

my documents has an id field, called "doc_id", declared with the following attributes:

<field name="doc_id" type="long" indexed="true" stored="true" required="true" />

This id is marked as an unique key with the tag.

I try to load many documents at once, giving their ids in request f.e. doc_id:(235, 163, 256, ..., 10473)

The count of identifiers in the query is never greater than 100. However, the more documents are there in the storage the longer it takes for this query to execute. I thought this would be something like the SQL query f.e. "select doc where doc_id in (...)" but with index on "doc_id" the execution time should be constant, shouldn't it? So why is it slowing down in solandra after I add more and more docs?

I'm working with Solandra (Solr 3.4 + Cassandra 1.0.3)

Regards, T

2条回答
爷、活的狠高调
2楼-- · 2019-07-31 19:28

Use RealTimeGet (Solr >= 4.0).

http://localhost:8983/solr/get?ids=1,2
查看更多
时光不老,我们不散
3楼-- · 2019-07-31 19:30

As the ids are unique do not search over it. The search performance will always be slower.
Try to use filter queries e.g. fq=doc_id:235
This would allow Solr to use filtercache and giving you a much improved performance.

查看更多
登录 后发表回答