Is there a way to fetch at least N number of records from a Sunspot Solr Query?

121 Views Asked by At

I am trying to fetch minimum 3 records for a certain model. The problem I am facing right now is, there is full_text matching involved as well. It works fine when I pass a keyword 'Hello' to the query. It only matches a single record because it's the only one that exists.

I would like for the query to at least fetch 3 records, even if they are not matched in full_text. The rest of the conditions should be met however.

Is there a way to make sure the minimum count is met?

1

There are 1 best solutions below

0
S Jayesh On

If you are using edismax query parser for Apache Solr you could try using "bq" parameter for your actual query text (use with a boost more than 1) and setting "q=:" always; in addition to this you may also want to use "mm" parameter if you are expecting multi-word queries.

By this approch you will have full re-call in your search and will have same relevancy as of earlier queries unless you don't want to define field level boost using in place other than in "bq".

I have not used Sunspot Solr for RoR but equivalent terms may be "minimum_match" for "mm"; "boost function" for "bq".