Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple facets per field with Solr

By default, Solr returns facets for a field, and then if you select a facet value for that field, all of the other previous choices are no longer returned as part of the facets for that field.

I'm trying to develop a search engine that works more like Amazon's search engine (which is based on their own A9 search engine, and therefore, is probably similar to Amazon CloudSearch).

When you narrow down to some "facets" on Amazon searches, they continue to show the other options, along with the counts if you were to add that area to your search.

Is there a built-in way to do this in Solr? If not, how would I roll my own. Obviously I would need to cache the original facets returned for the field. But what would be the most efficient way to calculate the counts for those other faceted areas once I've already selected one (or more) facets for the field. Obviously when additional facets are selected, you're doing an "OR" query between those values, as you're trying to show things with either of the two values.

For example, I performed a search on Amazon's jewelry department for diamond ring, then narrowed down to Gold as the metal type. I was then able to choose multiple karat facets:

Example Amazon faceting

Can someone provide an example on how I could (efficiently) do this with Solr?

And is there any feature in the works for a future version of Solr that would offer this functionality out of the box (assuming it's not already in the box)?

like image 373
Mason G. Zhwiti Avatar asked Dec 26 '22 16:12

Mason G. Zhwiti


1 Answers

Tagging and excluding Filters functionality in Solr might be the feature that you are looking for, here is Wiki link explaning Multi Select Faceting.

Ex:: ../solr/select/?q=*&rows=0&facet=on&fq={!tag=krt}KARAT:10k_Gold&facet.field={!ex=krt}KARAT

This feature is present since Solr 1.4 I guess.

like image 154
mailboat Avatar answered Feb 11 '23 15:02

mailboat