简体   繁体   中英

Solr/ElasticSearch - Document lookup by ID -> query or filterQuery?

I just wonder what I am supposed to use for a lookup by ID.

This thread Solr Query on Unique Integer Field seems to use a query.

But it is not what is said here: Search document by id very slow

And here: http://lucene.472066.n3.nabble.com/Solr-Unique-Key-Field-Should-Apply-on-q-search-or-fq-search-td4003066.html But I'm not reusing the same query because the lookups can be on any ID


ElasticSearch provides natively a lookup by id, someone knows what is happening under the hood of ElasticSearch lookup so that I can eventually use the same strategy with Solr?

Thanks

You should still use Filter Query cause you may search the same id some time later which would be much faster in performance in comparison to the q query

fq - Provide an optional filtering query.
Results of the query are restricted to searching only those results returned by the filter query. Filtered queries are cached by Solr . They are very useful for improving the speed of complex queries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM