简体   繁体   English

如何前缀匹配文档值 -> lucene 搜索引擎中的搜索词,例如 Solr、ElasticSearch

[英]How to prefix match a doc value -> search term in lucene search engines like Solr, ElasticSearch

We have a need to prefix match from the <document value> -> <search term> .我们需要从<document value> -> <search term>进行前缀匹配。 Reverse is possible in Solr, ElasticSearch which is <search term> -> <document value>在 Solr、ElasticSearch 中可以反向,它是<search term> -> <document value>

Example:例子:

Search term -> "traveling the world"
Document field value -> "travel"

Not sure how to prefix match or fuzzy this query so we can get this document result.不确定如何前缀匹配或模糊此查询,以便我们可以获得此文档结果。

Prefix match works like this "travel*"前缀匹配就像这样"travel*"

Search term -> "travel"搜索词 -> "travel"

Document field value -> "traveling the world"文档字段值 -> "traveling the world"

Try using the PorterStemFilterFactory in your field definition.尝试在您的字段定义中使用 PorterStemFilterFactory。

<filter class="solr.PorterStemFilterFactory"/>

Your definition may look like:您的定义可能如下所示:

<analyzer type="index">
  <tokenizer class="solr.StandardTokenizerFactory "/>
  <filter class="solr.PorterStemFilterFactory"/>
</analyzer>

Here is the input and output would be:这是输入,output 将是:

In: "jump jumping jumped"在: “跳跳跳跳”

Tokenizer to Filter: "jump", "jumping", "jumped"要过滤的分词器: “jump”、“jumping”、“jumped”

Out: "jump", "jump", "jump"出: “跳”、“跳”、“跳”

There is another alternative to it known as solr.KStemFilterFactory which is less aggressive.还有另一种替代方法,称为 solr.KStemFilterFactory,它的攻击性较低。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM