Michel Maas
Michel Maas

Reputation: 417

Solr result grouping, different limits per group

I'm working on a project where I need to select documents from a Solr index. The results are ordered by a field called rank. The problem is, however, that the top 3 results should be premium results, which are defined by a different field, for instance premium.

Now I know I can group results, for instance by doing:

group.query=rank[0 TO 100]

and

group.query=premium[1]

I can limit these results by adding

group.limit=LIMIT

but this limit is applied to all the groups.

Is there a way to only apply this limit to the first group, so that I can limit the premium results to return only 3 documents?

Upvotes: 3

Views: 1242

Answers (1)

user2023507
user2023507

Reputation: 1183

Don't see an option for that.

If you always have to return some premium results then using group-by for that could be tricky - what if the result set (assuming you are limiting the result set to some value using 'rows' parameter) does not contain any premium results?

Maybe, breaking it down to non-premium query and using LIMIT for 'rows' parameter & premium query where 'rows'= 3 is better?

Just an opinion!

There is a request to allow multiple queries in one request pending - https://issues.apache.org/jira/browse/SOLR-1093

Upvotes: 5

Related Questions