How to do a fuzzy search in Lucene.net in asp.net?

We create the lucene.net index and search based on this URL http://sonyblogpost.blogspot.in/ . but we want the result to be as follows.

example: if I search for “featured” I want to show similar terms, such as “featured”, “show”, “function”.

Anyone can help me. thanks.

+5
source share
2 answers

To perform a fuzzy search, you will create a MultiFieldQueryParser The following is an example of how to do this:

 var parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29, new[] { "field1", "field2" }, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29)); 

Your version of Lucene.Net may vary.

Next, you will receive a Fuzzy parsing request as follows:

 var query = parser.GetFuzzyQuery("fieldName", "featured", 0.7f); 

A float value of 0.7f is the minimum similarity. You can adjust this number until you get the desired results. The number cannot be greater than 1.0f . Fulfilling this query using Lucene Searcher will give you the expected results.

+6
source

You are probably looking for: Comprehensive English words with Lucene is a Java reference, but you should be able to identify the relevant parts of the lucene.NET API.

0
source

Source: https://habr.com/ru/post/972816/


All Articles