0

We're implementing solr with ecommerce application. The main objective is faster search and better faceted catalog navigation.

The problem however is, we're unable to figure out how to map dynamic facets into Solr. When I say dynamic facet, I mean this...

Samsung Galaxy S3

  • Category: Smartphone
  • Brand: Samsung
  • OS: Android
  • RAM: 1 GB
  • Processor: 1 Ghz
  • Camera: 8MP
  • Display: 4.7 inch
  • and like..

Filtering criteria, like OS, RAM, Processor, camera, etc. are dynamic to each product, some has it and some has altogether different set of filter criteria for facets. So when someone click on Android, a result will be filtered with all android phones in selected category.

We're facing an issue where we are unable to decide what the solr schema.xml will look like for supporting this kind of data dictionary for faceted search.

Dharmik Bhandari
  • 1,702
  • 5
  • 29
  • 60
  • Adding an example of how you would address this kind of question, will be a much valued answer. – Krunal Jun 14 '12 at 15:04

2 Answers2

4

Dynamic fields are what you need.

You could even do this:

product_name : samsung nexus
android_version_t : 4.0
partner_store_price_i : 19800

The _t and _i suffixes will be understood as text and integer types if you set your schema that way.

<dynamicField name="*_i"  type="int"    indexed="true"  stored="true"/>
<dynamicField name="*_s"  type="string"  indexed="true"  stored="true"/>
<dynamicField name="*_l"  type="long"   indexed="true"  stored="true"/>
<dynamicField name="*_t"  type="text"    indexed="true"  stored="true"/>

http://www.tnrglobal.com/blog/2010/07/dynamic-fields-in-apache-solr/

http://wiki.apache.org/solr/SchemaXml#Dynamic_fields

Jesvin Jose
  • 22,498
  • 32
  • 109
  • 202
  • Aitchnyu, I'm also facing similar issue. Does it mean, for each such dynamic attribute applied on product which needs to be filtered, I need to take them as dynamic field? What about faceted search? Does this needs to be defined in schema.xml? – Krunal Jun 14 '12 at 04:44
  • Yes, it needs to be defined. And these happen to come with the default schema. It is convienient if have an index that needs to store a large number of fields – Jesvin Jose Jun 14 '12 at 05:38
  • What do you mean when you say "It is convienient if have an index that needs to store a large number of fields"? – Dharmik Bhandari Jun 15 '12 at 07:42
  • Well, your products may have ~100 attributes you may not figure beforehand when you first create your index. Rather than frequently update your schema, you can use dynamic fields. – Jesvin Jose Jun 15 '12 at 08:27
2

Expanding on the answer above.

You can have fields such as isSpecial, a boolean, specialCategoryType. In the above case, they are set to true and android.

When this item is selected (isSpecial) you can refine the query and add to the predicate specialCategoryType:android.

Edit:

Lets say there are two products, an android phone and an android laptop. phone 1- os:android; type:phone; camera:8MP; specCatFacet:os,type,camera ; specCatRefine:os, type laptop- os:android; type:laptop; screensize:13; specCatFacet:os,type,screen; specCatRefine:os, type phone 2 - os:android; type:phone; camera:4MP; specCatFacet:os, type, camera; specCatRefine:os, type

When people, search for android, all three will show up. Facets displayed could be a union of both sets of facets.

When a phone1 or 2 is clicked on, you'd look at specCatRefine field, and refine the search criteria with os, type and use specCatFacet to subsequently facet them.

When the laptop is clicked on, the search is refined on os, type and facetted on os, type, screen.

Essentially, second search term refine and facetting is based on a field in each document. Your search term refining will have lot of this logic on how to create the criteria.

Hope this helps...

user1452132
  • 1,758
  • 11
  • 21
  • Hi, Can you please elaborate on this... didn't exactly get what do you mean by this. – Krunal Jun 14 '12 at 15:02
  • When a user clicks on certain product type, you want to refine user's original criteria by appending this product type. You want to do this only for certain special types (I assumed). So, the boolean type defines whether this is a special type, and the second one to define the value. In essence, I did not think a "dynamic" facet was needed, rather refining the search criteria. – user1452132 Jun 14 '12 at 18:59
  • I also didn't understand this... can you please explain with example? – Dharmik Bhandari Jun 15 '12 at 07:44
  • An example will be much helpful to me as well. – Krunal Jun 15 '12 at 19:41