Question

I'm using Solrnet to return search results and am also requesting the facets, in particular categories which is a multi-valued field.

The problem I'm coming up against is that the category "house products" is being returned as two seperate facets because of the space.

Is there a way of ensuring this is returned as a single facet value, or should I be escaping the value when it is added to the index?

Thanks in advance Al

Was it helpful?

Solution

If the tokens are generated for house products then you are using text analysis for the field.
Text fields are not suggested to be used for Faceting. You won't get the desired behavior as the text fields would be tokenized and filtered leading to the generation of multiple tokens which you see from the facets returned as response.

Use a copy field to copy the field to a String field to be able to facet on it without splitting the words.

SolrFacetingOverview :-

Because faceting fields are often specified to serve two purposes, human-readable text and drill-down query value, they are frequently indexed differently from fields used for searching and sorting:

  1. They are often not tokenized into separate words
  2. They are often not mapped into lower case
  3. Human-readable punctuation is often not removed (other than double-quotes)
  4. There is often no need to store them, since stored values would look much like indexed values and the faceting mechanism is used for value retrieval.

Try to use String fields and it would be good enough without any overheads.

OTHER TIPS

The faceting works on tokens, so if you have a field that is tokenized in many words it will split the facet too. I suggest you create another field of type string used only for faceting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top