Lucene区分大小写不敏感的搜索 [英] Lucene case sensitive & insensitive search

查看:117
本文介绍了Lucene区分大小写不敏感的搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Lucene索引,该索引目前区分大小写.我想添加选项,以不区分大小写的搜索作为后备.这意味着与案例匹配的结果将获得更大的权重,并且将首先出现.例如,如果结果数限制为10,并且有10个匹配项符合我的情况,那就足够了.如果仅找到7个结果,则可以从不区分大小写的搜索中再添加3个结果.

I have a Lucene index which is currently case sensitive. I want to add the option of having a case insensitive search as a fall-back. This means that results that match the case will get more weight and will appear first. For example, if the number of results is limited to 10, and there are 10 matches which match my case, this is enough. If I only found 7 results, I can add 3 more results from the case-insensitive search.

我的箱子实际上更复杂,因为我有重量不同的物品.理想情况下,匹配错误"的情况会增加一些重量.不用说,我不想重复结果.

My case is actually more complex, since I have items with different weights. Ideally, having a match with "wrong" case will add some weight. Needless to say, I do not want duplicate results.

一种可能的方法是拥有2个索引.一种带大小写,一种不带大小写,并同时搜索.自然地,这里有些冗余,因为我需要索引两次.

One possible approach is to have 2 indexes. One with case and one without and search both. Naturally, there's some redundancy here, since I need to index twice.

有更好的解决方案吗?想法?

Is there a better solution? Ideas?

推荐答案

您是否已经尝试过copyField?参见 http://wiki.apache.org/solr/SchemaXml#Copy_Fields

Did you already tried copyField? see http://wiki.apache.org/solr/SchemaXml#Copy_Fields

如果未定义具有不同配置的新字段B,则通过copyField将字​​段A复制到B中.

If not define a new field B with a different configuration and copy field A into B via copyField

这篇关于Lucene区分大小写不敏感的搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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