Question

I am after creating a web app where I would have to use dynamic fields to create facets, smilimar to pricegrabber.com.

I am not sure if pricegrabber decides the facet names or publishers ? How do we decide there will be a "Color" facet in case of microwave http://www.pricegrabber.com/appliances/microwave-ovens/p-528/ and a "resolution" facet in case of plasma/LCD http://www.pricegrabber.com/electronics/plasma-lcd-televisions/p-197/

What's the easiest way to handle such situations?

Was it helpful?

Solution

This is one way do it. Assign a category to each product and a set of properties to each category. (The category to property mappings can be stored somewhere outside of Solr, for example, in a DB.)

The properties are your dynamic fields - property_* below. For example:

{
 product_name: Brand A 3 Cu. ft. microwave,
 category: 1,
 price: 45.35,
 property_color: Red,
 property_capacity_cu_ft: 3,
 property_brand: Brand A
}, 
{
 product_name: Brand B 45 inch plasma TV,
 category: 2,
 price: 4500.35,
 property_resolution: 1920 x 1200,
 property_aspect_ratio: Widescreen,
 property_brand: Brand B
}

Also, assign a category to each one of your auto-suggest keywords. For example, microwave oven could be mapped to category 1. When someone searches for microwave oven you pull in the properties of the category it belongs to i.e.

color
capacity_cu_ft
brand

and form your query like:

q=microwave%20oven&facet=true&facet.query=property_color&facet.query=property_capacity_cu_ft&facet.query=property_brand

(Here you may want to range facet for capacity_cu_ft though.)

If the user were to search a term not in your auto-suggest dictionary, then your best bet is to actually facet on the categories themselves. (Guess this is what pricegrabber does.) Of course, price is always available, so that is a facet you can always use on all searches.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top