Solr部分和完整字符串匹配

编程入门 行业动态 更新时间:2024-10-28 20:22:52
本文介绍了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部分和完整字符串匹配

本文发布于:2023-11-22 08:44:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1616742.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   完整   Solr

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!