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 Tamás Barta <ba...@gmail.com> on 2018/10/02 10:55:37 UTC

Dynamic filters

Hi,

I have been using Solr for a while for an online web store. After search a
filter box appears where user can filter results by many attributes. My
question is how can I do it with Solr that he filter box show only
available options based on result. For example if attribute "type" can be
1, 2, 3 but the results contains only 1 and 2, then only these two values
should be available in the filters.

I get only the first page results and I don't want to read the full results
from Solr because of performance. Is there any way to get available values
by fields for a query without degrade performance?

Thanks, Tamás

Re: Dynamic filters

Posted by Emir Arnautović <em...@sematext.com>.
Hi Tamas,
Maybe I am missing the point and you already discarded that option, but you should be able to cover such cases with simple faceting?

Thanks,
Emir
--
Monitoring - Log Management - Alerting - Anomaly Detection
Solr & Elasticsearch Consulting Support Training - http://sematext.com/



> On 2 Oct 2018, at 12:55, Tamás Barta <ba...@gmail.com> wrote:
> 
> Hi,
> 
> I have been using Solr for a while for an online web store. After search a
> filter box appears where user can filter results by many attributes. My
> question is how can I do it with Solr that he filter box show only
> available options based on result. For example if attribute "type" can be
> 1, 2, 3 but the results contains only 1 and 2, then only these two values
> should be available in the filters.
> 
> I get only the first page results and I don't want to read the full results
> from Solr because of performance. Is there any way to get available values
> by fields for a query without degrade performance?
> 
> Thanks, Tamás


Re: Dynamic filters

Posted by Shawn Heisey <ap...@elyograg.org>.
On 10/2/2018 5:03 AM, Tamás Barta wrote:
> Thank you for the answers!
>
> Is it possible to get the facet result and the search results with only one
> query? Or I have to send two queries for the Solr (one for search results
> and one for facets)?

It only requires one query.  You just add facet parameters, and 
additional processing happens with a new section in the response.

For performance reasons, this should only be done when the client needs 
the information.

Thanks,
Shawn


Re: Dynamic filters

Posted by Tamás Barta <ba...@gmail.com>.
Thank you for the answers!

Is it possible to get the facet result and the search results with only one
query? Or I have to send two queries for the Solr (one for search results
and one for facets)?

On Tue, Oct 2, 2018 at 1:02 PM Shawn Heisey <ap...@elyograg.org> wrote:

> On 10/2/2018 4:55 AM, Tamás Barta wrote:
> > I have been using Solr for a while for an online web store. After search
> a
> > filter box appears where user can filter results by many attributes. My
> > question is how can I do it with Solr that he filter box show only
> > available options based on result. For example if attribute "type" can be
> > 1, 2, 3 but the results contains only 1 and 2, then only these two values
> > should be available in the filters.
> >
> > I get only the first page results and I don't want to read the full
> results
> > from Solr because of performance. Is there any way to get available
> values
> > by fields for a query without degrade performance?
>
> If you facet on the field you're intending to filter on, you will get a
> result that contains all of the values for that field in the result set
> and the count of documents that contain each of those values.  Be sure
> that you include the parameter facet.mincount=1 or you will get a report
> of ALL possible values, including those that do not match the query.
> The count on such values will be zero.
>
> https://lucene.apache.org/solr/guide/7_5/faceting.html
>
> Adding facets *will* affect performance.  It's difficult to guess how
> much performance will be impacted ... the more unique values the field
> contains, the longer it will take to get results.If the system is sized
> appropriately, facets tend to be very fast.
>
> Thanks,
> Shawn
>
>

Re: Dynamic filters

Posted by Shawn Heisey <ap...@elyograg.org>.
On 10/2/2018 4:55 AM, Tamás Barta wrote:
> I have been using Solr for a while for an online web store. After search a
> filter box appears where user can filter results by many attributes. My
> question is how can I do it with Solr that he filter box show only
> available options based on result. For example if attribute "type" can be
> 1, 2, 3 but the results contains only 1 and 2, then only these two values
> should be available in the filters.
>
> I get only the first page results and I don't want to read the full results
> from Solr because of performance. Is there any way to get available values
> by fields for a query without degrade performance?

If you facet on the field you're intending to filter on, you will get a 
result that contains all of the values for that field in the result set 
and the count of documents that contain each of those values.  Be sure 
that you include the parameter facet.mincount=1 or you will get a report 
of ALL possible values, including those that do not match the query.  
The count on such values will be zero.

https://lucene.apache.org/solr/guide/7_5/faceting.html

Adding facets *will* affect performance.  It's difficult to guess how 
much performance will be impacted ... the more unique values the field 
contains, the longer it will take to get results.If the system is sized 
appropriately, facets tend to be very fast.

Thanks,
Shawn