Solr部分和完整字符串匹配 [英] Solr Partial And Full String Match

查看:71
本文介绍了Solr部分和完整字符串匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图允许在Solr中搜索部分字符串,因此,如果有人搜索"ppopota",他们将获得与搜索"hippopotamus"相同的结果.我上下阅读了文档,觉得自己已经用尽了所有的选择.到目前为止,我有以下内容:

I am trying to allow searches on partial strings in Solr so if someone searched for "ppopota" they'd get the same result as if they searched for "hippopotamus." I read the documentation up and down and feel like I have exhausted my options. So far I have the following:

定义新的字段类型:

<fieldtype name="testedgengrams" class="solr.TextField">
   <analyzer>
     <tokenizer class="solr.LowerCaseTokenizerFactory"/>
     <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/>
  </analyzer>
</fieldtype>

定义"testedgengrams"类型的字段:

Defining a field of type "testedgengrams":

<field name="text_ngrams" type="testedgengrams" indexed="true" stored="false"/>

将text_ngrams的内容复制到文本中

Copying contents of text_ngrams into text:

<copyField source="text_ngrams" dest="text"/>

A,那是行不通的.我想念什么?

Alas, that doesn't work. What am I missing?

推荐答案

您正在使用 EdgeNGramFilterFactory 会生成令牌"hi","hip","hipp"等,因此不会与"ppopota"匹配.请改用NGramFilterFactory.

You're using EdgeNGramFilterFactory which generates tokens 'hi', 'hip', 'hipp', etc, so it won't match 'ppopota'. Use NGramFilterFactory instead.

这篇关于Solr部分和完整字符串匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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