Solrnet facet returning spaces

為{幸葍}努か 提交于 2019-12-11 11:31:33

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/17907604/solrnet-facet-returning-spaces

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!