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