Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Solr sort by default when using filter query *:*?

Tags:

apache

solr

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.

like image 280
donutdan4114 Avatar asked Jan 20 '14 14:01

donutdan4114


People also ask

What is filter query in Solr?

Filter queriesThe fq parameter defines a query that can be used to restrict the superset of documents that can be returned, without influencing score. The fq parameterized queries are cached independent of the main query.

How does Solr query work?

Solr works by gathering, storing and indexing documents from different sources and making them searchable in near real-time. It follows a 3-step process that involves indexing, querying, and finally, ranking the results – all in near real-time, even though it can work with huge volumes of data.

What is the default return type of Solr request?

The default value is 0 . In other words, by default, Solr returns results without an offset, beginning where the results themselves begin.


Video Answer


2 Answers

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
like image 128
cheffe Avatar answered Dec 01 '22 14:12

cheffe


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

like image 40
Xinzz Avatar answered Dec 01 '22 13:12

Xinzz