itmanager223
itmanager223

Reputation: 21

blacklight solr config facet fields

We have a website that we are building running ruby 2.0, rails 4.0.1, blacklight 5.1.0, Apache solr 4.2 with sunspot solr gem for ruby.

We currently have the full solr index with products. If we search * we are able to see all the products. If we try and search a category this does not work. We are stuck at this point and are not sure how to get the facets to work.

Can anyone lead us in the right direction here as any research we have done has turned up no results.

Solrconfig.xml - http://pastebin.com/RkCS1GUT scheme.xml - http://pastebin.com/Cffu2Q3r

These files above are modified from the original blacklight example. The material field is currently the one we are using to try and search.

Thanks

Upvotes: 0

Views: 582

Answers (1)

Joe Atzberger
Joe Atzberger

Reputation: 3306

If you look at the product data, you have the category in some field. Examine your logs to see what query Blacklight is producing. Obviously it is not targeting the same field. Then move the data or adjust the Blacklight config.

To define facet fields in Blacklight, do something like this (in initializer or in a given Controller):

  configure_blacklight do |config|
    config.default_solr_params = {
      :'q.alt' => "*:*",
      :defType => 'dismax',
      :facet   => true,
    }
    config.add_facet_field 'objectType_facet',   :label => 'Object Type'
    config.add_facet_field 'content_type_facet', :label => 'Content Type'
  end

The field names and labels will vary for your data, of course.

Upvotes: 1

Related Questions