10

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.

2 Answers 2

13

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

1
  • Awesome, didn't know that type of query had a name. Jan 22, 2014 at 1:28
3

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

3
  • 1
    If I'm not applying any facets or anything, wouldn't the score be the same for all documents? If 10 documents have the same score, how does Solr sort those documents? This documentation isn't very clear: wiki.apache.org/solr/SolrRelevancyFAQ#How_are_documents_scored Jan 20, 2014 at 22:47
  • And this documentation is a bit above my head: lucene.apache.org/core/4_0_0/core/org/apache/lucene/search/… Jan 20, 2014 at 22:48
  • 2
    @donutdan4114 if any documents are returned with the exact same score, they are sorted by the internal Lucene document Id, which grow incrementally as documents are updated/inserted. In that context, those documents that have tied scores, they are sorted in the order in which they appear in the index.
    – jro
    Jan 21, 2014 at 0:26

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.