Search code examples
solrfaceted-search

How not to break phrase into word when do faceting


All:

Im pretty new to Solr faceting search, when I specify some facet fields which have phrase as value, how can I just treat the value as a whole phrase but not word and only return one facet. For example:

If I have documents with field like: { "category": "baby toy"}, {"category": "clothes"}

And the result returned will look like:

["baby", 0, "boy", 0, "clothes", 1]

I wonder why it works like this and how to change it to what I mentioned above, like:

["baby boy", 1, "clothes", 1]

Thanks


Solution

  • The field you use for faceting should be defined in schema.xml as a string (type="string") in order for the facet to use the whole text. Otherwise it will divide it according to the way it has been tokenized.