Search code examples
solre-commercesolrnetfaceted-search

Solr Schema.xml for Faceted Search


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.


Solution

  • 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