You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Parshant Kumar <pa...@indiamart.com.INVALID> on 2020/11/28 08:41:08 UTC

Solr collapse & expand queries.

Hi community,

I want to implement collapse queries instead of group queries . In solr
documentation it is stated that we should prefer collapse & expand queries
instead of group queries.Please explain how the collapse & expand queries
is better than grouped queries ? How can I implement it ? Do i need to add
anything in *solrconfig.xml file* as well or just need to make changes in
solr queries like below:


*fq={!collapse field=*field*}&expand.rows=n&expand=true  instead of
group.field=*field*&group=true&group.limit=n*

I have done performance testing by making above changes in solr queries and
found that query times are almost the same for both collapse queries and
group queries.

Please help me how to implement it and its advantage over grouped queries.

Thanks,
Parshant Kumar.

-- 


Re: Solr collapse & expand queries.

Posted by Joel Bernstein <jo...@gmail.com>.
Both collapse and grouping are used quite often so I'm not sure I would
agree with the preference for collapse. There is a very specific use case
where collapse performs better and in these scenarios collapse might be the
only option that would work.

The use case where collapse works better is:

1) High cardinality grouping field, like product id.
2) Larger result sets
3) The need to know the full number of groups that match the result set. In
grouping this is group.ngroups.

At a certain point grouping will become too slow under the scenario
described above. It will all depend on the scale of #1 and #2 above. If you
remove group.ngroups grouping will usually be just as fast or faster then
collapse.

So in your testing, make sure you're testing the full data set with
representative queries, and decide if group.ngroups is needed.







Joel Bernstein
http://joelsolr.blogspot.com/


On Sat, Nov 28, 2020 at 3:42 AM Parshant Kumar
<pa...@indiamart.com.invalid> wrote:

> Hi community,
>
> I want to implement collapse queries instead of group queries . In solr
> documentation it is stated that we should prefer collapse & expand queries
> instead of group queries.Please explain how the collapse & expand queries
> is better than grouped queries ? How can I implement it ? Do i need to add
> anything in *solrconfig.xml file* as well or just need to make changes in
> solr queries like below:
>
>
> *fq={!collapse field=*field*}&expand.rows=n&expand=true  instead of
> group.field=*field*&group=true&group.limit=n*
>
> I have done performance testing by making above changes in solr queries and
> found that query times are almost the same for both collapse queries and
> group queries.
>
> Please help me how to implement it and its advantage over grouped queries.
>
> Thanks,
> Parshant Kumar.
>
> --
>
>