不区分大小写Solr查询小平面,但保留大小写的结果 [英] Case insensitive Solr query for facets but preserve case for results

查看:542
本文介绍了不区分大小写Solr查询小平面,但保留大小写的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Solr为我们的电子商务应用程序提供面向功能。它以标准方式实现,如此处所述 https://wiki.apache.org/solr/SimpleFacetParameters #Tagging_and_excluding_Filters



在应用程序方面,我们使用了Solr返回的方面来提供UI上的过滤体验,并且使用方面作为参数来构建URL。然后使用这些参数将fq的分面参数传递给Solr。

这个工作很好,除了我们的URL是区分大小写的,因为当我们改变小案例时,facet查询不再起作用,并且给我们提供未定义的字段错误。




如何使用Case不敏感的Solr Query for Faceting,但仍然保留用于显示构面的结果? =h2_lin>解决方案

首先:您看到未定义字段的错误,这似乎很奇怪。您可能不应该让最终用户指定所使用的字段,而不是针对那些您希望允许过滤或打分的字段验证字段。

第二:使用一个字段进行生成小平面和一个过滤。没有什么说你必须使用相同的字段来表达方面,并在 fq 中使用。

您可以使用一个KeywordTokenizer和一个LowercaseFilter来过滤字段,然后使用< copyField> 将用于分屏的字段中的内容复制到小写字段进行过滤。


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?

解决方案

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.

这篇关于不区分大小写Solr查询小平面,但保留大小写的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆