SOLR 不区分大小写的搜索 [英] SOLR Case Insensitive Search

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

问题描述

我在 SOLR 搜索中遇到了问题.
我有这样的数据:

I've a problem in SOLR Search.
I have a data like this:

我使用 solr admin 使用这样的查询来查找此数据:

I use solr admin to find this data using query like this:

address_s:*Nadi*

并找到了这些数据.但是当我使用这个查询时:

and found those data. But when I use this query:

address_s:*nadi*

它没有找到任何东西.
我在谷歌上搜索并找到了使用以下脚本创建字段的答案:

it doesn't found anything.
I've googling and I found an answer to create a field with the following script:

<fieldType name="c_text" class="solr.TextField">
    <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>

    <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
    </analyzer>
</fieldType>

我已将这些脚本复制粘贴到 schema.xml 中,但它仍然不起作用.我该怎么办?有人可以帮我吗?

I've copy paste those script into schema.xml, but it still doesn't work. What should I do? Can anyone help me?

推荐答案

address_s 字段应定义为 -

The address_s field should be defined as -

<field name="address_s" type="c_text" indexed="true" stored="true"/>

如果你使用默认的schema.xml,这个定义应该放在 -

If you are using the default schema.xml, this defination should come before -

<dynamicField name="*_s"  type="string"  indexed="true"  stored="true"/>

将其定义为不执行分析的字符串字段类型.

which defines it as a string field type with no analysis performed.

通配符查询不进行分析.
因此,如果您在索引时应用小写过滤器,查询 address_s:*nadi* 将起作用.
但是,查询 address_s:*Nadi* 不会,因为 Nadi 将不匹配索引中的 nadi,您需要小写查询客户端.

Wildcard queries does not undergo analysis.
So if you apply lower case filter at index time query address_s:*nadi* would work.
However, query address_s:*Nadi* would not, as Nadi will not match nadi in index and you would need to lower case the queries at client side.

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

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