Not Getting Desired Results From Solr Facets

solr

I am working on adding facets to my Solr queries and I am getting some odd results.

Let's say that I have a list of manufacturers that I want to have faceted. This list would include:

Port Authority
Carhartt Clothing
Dickies Uniforms

My facets for this come back as:

<int name="port">157</int>
<int name="authority">156</int>
<int name="clothing">156</int>
<int name="carhartt">105</int>
<int name="uniforms">67</int>
<int name="dickies">58</int>

Is there a way to make the facets use the full value, not split on each word? I have defined manufactuer in my schema.xml file as:

<field name="manufacturer" type="text_general" indexed="true" stored="true" multiValued="false"/>

I largely have the default schema.xml file that is in the example directory when you download Solr. The only thing I changed from the default example was add my fields.

Best Answer

One easy way to do that is copy you data to a specific facet field. You usually don't want tokenization or any other changes to you facet field.

For example, at you solr schema.xml you can do

<copyField source="manufacturer" dest="manufacturerFacet"/>

This will copy the data you try to store at the manufacturer field to the manufacturerFacet automatically. This way you can set manufacturerFacet field as the following using string as base standard type with no tokenization.

<field name="manufacturerFacet" type="string" indexed="true" stored="false" multiValued="true"/>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
Related Topic