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 <apa...@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 > >