2

I would like Solr to return all results if a user query contains only stopwords, e.g. q=the, (by default Solr returns 0 results). Is there any flag in Solr config that I can switch on, or any Solr query syntax construction I can use to achieve this?

I really don't like the idea of duplicating stopword logic on the client side, and firing q=*:* if all terms are stopwords.

Jayendra
  • 52,349
  • 4
  • 80
  • 90
Aliya
  • 1,168
  • 12
  • 17
  • are you using any stopfilter or analyzers for stop filters? it would be better if you could give us some details about your configuration about stop words if you are using any – denizdurmus Nov 14 '12 at 00:59
  • please try to explain your motivation a bit more. it's presumably not very common that a user would want all documents to be returned from a search without explicitly asking for that. – joeln Nov 14 '12 at 04:33

2 Answers2

1

Check out the Edismax Query parser, which handles the query different if the query is of all stopwords.

includes advanced stopword handling: stopwords are not required in the mandatory part of the query but are still used in the proximity boosting part. If a query consists of all stopwords, such as "to be or not to be", then all words are required

Even though it would not work as a all (*:*) results query, but surely would match most of the results.

Jayendra
  • 52,349
  • 4
  • 80
  • 90
  • can you write a query of edismax explaining stopwords searching if only stopwords is in the phrase. – MTA Jan 31 '17 at 06:49
0

A hacky solution to this problem would be to set q=*:* AND _query_:"{! var=$userq}", and send the user query to the userq URL parameter instead of q.

This explicitly sets the result to be the intersection of all documents and the user query (if you are unfamiliar with the _query_:"{!...}" syntax, see http://wiki.apache.org/solr/LocalParams).

Note, this will return different scores, but the same order, compared to the user query alone.

joeln
  • 3,563
  • 25
  • 31