How does Solr sort by default when using filter qu

2019-02-13 04:34发布

问题:

We currently have a page setup that has no filters/facet/queries applied. It is a listing of all content (using a pager). The filter query is something like *:* (anything from any field).

I can't figure out how the content is being sorted though. It says it's by "relevancy", but what does that mean when you're selecting everything?

I did some quick testing. It does not appear to be sorted by the date the content is modified, or entered into the index.

回答1:

Querying for *:* is also called a MatchAllDocsQuery. According to the SO question How are results ordered in solr in a "match all docs" query it will return the docs in the same order as they were stored in the index.

Be aware that if you update an existing document, it get's deleted and recreated. As such it would appear at the end of such a search afterwards.

There are (at least) two threads in Lucene's Nabble I am aware of that are interesting on this topic

  • http://lucene.472066.n3.nabble.com/Result-order-when-score-is-the-same-td2816127.html
    • gets really interesting around here http://lucene.472066.n3.nabble.com/Result-order-when-score-is-the-same-tp2816127p2817766.html
  • http://lucene.472066.n3.nabble.com/Result-ordering-for-Wildcard-Prefix-queries-or-ConstantScoreQueries-td492687.html


回答2:

The default search should be by score desc if the sort parameter is not specified. : will just select everything.

Reference: http://wiki.apache.org/solr/CommonQueryParameters#q



标签: apache solr