Case insensitive Solr query for facets but preserve case for results

我与影子孤独终老i 提交于 2020-02-05 08:57:13

问题


I am using Solr to power faceting features for our e-commerce application. Its been implemented in standard way as described here https://wiki.apache.org/solr/SimpleFacetParameters#Tagging_and_excluding_Filters

On application side, we have used facets returned by Solr to offer filtering experience on UI and the URLs are built using the facets as params. These parameters are then used to further pass on the faceting parameters for fq into Solr.

This works great except that our URLs are case sensitive as the moment we change to small case the facet query no longer work and gives us Undefined field error.

How can we have Case insensitive Solr Query for Faceting but still preserve case for results that are being used to display facets?


回答1:


First: it seems weird that you're getting an error about undefined fields. You should probably not let the end user specify the field used without validating the field against those that you want to allow filtering or faceting for.

Second: Use one field for generating the facets, and one for filtering. There is nothing that says you have to use the same field for presenting the facets and for use in fq.

You can have a field with a KeywordTokenizer and an LowercaseFilter to use for filtering, and then use <copyField> to copy content from the field you use for faceting into the lowercased field for filtering.



来源:https://stackoverflow.com/questions/46376518/case-insensitive-solr-query-for-facets-but-preserve-case-for-results

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