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

查看:41
本文介绍了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"/>

唉,这行不通.我错过了什么?

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天全站免登陆