Reputation: 1803
I am using PHP to perform a SOLR query using facet fields. Some of these fields contain hyphenated text which is giving me a list of facet field results that are split
some-category-name
would give an array with keys 'some','category','name'
which I do not want.
My schema.xml defines the category field as:
<field name="category" type="text_general" indexed="true" stored="true" required="false" multiValued="true" />
How can I fix this so that the field value is not split on the hyphen?
Upvotes: 0
Views: 526
Reputation: 896
Ideally the fields you facet on should never be tokenized since Solr treats every token as a separate facet and it is counted separately while calculating the facet counts.
What you should do is either use string for your fieldtype as Marie suggest or in case you want to be able to both facet and search on this particular field, create a copy field of the type string like so
<field name="category_facet" type="string" indexed="true" stored="true" required="false" multiValued="true" docValues="true" />
<copyField source="category" dest="category_facet" />
(Note: use DocValues for efficient faceting)
and then facet on the category_facet
field.
This should give you the results you want.
Upvotes: 1
Reputation: 483
The type "text_general" you chose in your schema has Solr tokenize the values according to this :StandardTokenizer
You can:
Upvotes: 1