简体   繁体   中英

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> . Reverse is possible in Solr, ElasticSearch which is <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*"

Search term -> "travel"

Document field value -> "traveling the world"

Try using the PorterStemFilterFactory in your field definition.

<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:

In: "jump jumping jumped"

Tokenizer to Filter: "jump", "jumping", "jumped"

Out: "jump", "jump", "jump"

There is another alternative to it known as solr.KStemFilterFactory which is less aggressive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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