2
votes

I´m trying to setup a search across multiple document types, each with different sets of fields. So the search should always start with only the most general facet field (eg Product category), common to all document types.

PRODUCT CATEGORY  
- Camera (42)  
- TV & Video (96)  
- MP3 Player (11)  
- Video Game (63)

After selecting "Camera", I need to enable a whole set of new facet fields, exclusive to that document type (eg Brand, Capacity), like the following:

PRODUCT CATEGORY  
> Camera

BRAND  
- Canon (42)  
- Nikon (96)  
- Sony (11)  
- Samsung (63)

CAPACITY  
- 1Gb (42)  
- 2Gb (96)  
- 3Gb (11)  
- 4Gb (63)

I know this can be done by managing facet.field query parameters programmatically, but is there any better way to build this systematically? Is there any feature or tip to allow this facet fields dependency inside Solr and its field structures?

Thanks a lot!

Edit: I changed the title from "dependency of facet fields".

2

2 Answers

2
votes

IMO you do not need to create any dependency.
You can create individual fields for this entries.

When you do an Initial Query you would facet on Product Type.
Then when you filter on a specific product type, you are only going to get facets from the results as per the filter.

For e.g. Product Type Camera would have Brands Canon, Nikon as so on ... with some capacity options Product Type TV & Video would have Brands Song, Samsung as so on ... with some other attributes

So when you would Filter on Camera (fq=product_type:Camera) you would limit the results only for Product Type Camera and Brands within this filter with capacity options.
The filtering should take care of the dependency.

0
votes

I think you can do it by ensuring you index the appropiate info in each document, look at this wiki page on hierarchical facetting