Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys!!

I am getting stuck on 1 point while searching book name in Lucene Search.

I am giving scenario using 1 example.

Suppose I have a search string - "fifty shades of grey". By mistake i entered "figty" instead of "fifty". So it will not return any result.

what I need that, if user enter wrong or misspell, then it convert it into correct spell and search accordingly using Lucence.

Please help me. I m new in Lucene.

Thanks in Advance!!!

Amit Tiwari

What I have tried:

I have no idea that what should I tried.

I m waiting for response.


Thanks
Posted
Updated 15-Mar-16 23:35pm

1 solution

You need to do your own research.

Try some of these resources[^]
 
Share this answer
 
Comments
Gr8AmitTiwari 28-Mar-16 6:44am    
Hi,

This solution is not helpful.

I m getting stuck.

Please help me. I m new in Lucene.

Thanks
CHill60 28-Mar-16 7:00am    
If you are new in Lucene then you need to learn how to use it. The list of resources I supplied are ways to learn how to use it. This one specifically - Did You Mean: Lucene? Blog | Oracle Community[^] - adds the "Did you mean?" feature (spell check) to a simple search application - exactly what your post says you require.
It was on the first page of results from the link I gave.

We're not going to write your code for you, but if you get stuck come back with the code you are struggling with
Gr8AmitTiwari 29-Mar-16 7:42am    
Hi,

With the help of google, I have started my sample application, but some confusion on that.
Now Can you please resolve this?

The code section given below.

<pre lang="C#">SpellChecker spellchecker = new SpellChecker(spellIndexDirectory);
// To index a field of a user index:
spellchecker.indexDictionary(new LuceneDictionary(my_lucene_reader, a_field));
// To index a file containing words:
spellchecker.indexDictionary(new PlainTextDictionary(new File("myfile.txt")));
String[] suggestions = spellchecker.suggestSimilar("misspelt", 5);</pre>


1. What is myfile.txt. Can we create it or what?

2. String[] suggestions = spellchecker.suggestSimilar("misspelt", 5)
In the above line, spellchecker.suggestSimilar has 2 parameter. 1st is string word and 2nd is int num_sug. What is this num_sug in which pass 5.

Please help.

Thanks in advance.
CHill60 29-Mar-16 8:10am    
This is the problem with picking up code from the internet without understanding what it is actually trying to do.
"myFile.txt" is a text file that contains words. Yes you can create it.
int num_sug is the number of suggested words to return.
"As the Lucene similarity that is used to fetch the most relevant n-grammed terms is not the same as the edit distance strategy used to calculate the best matching spell-checked word from the hits that Lucene found, one usually has to retrieve a couple of numSug's in order to get the true best match.

I.e. if numSug == 1, don't count on that suggestion being the best one. Thus, you should set this value to at least 5 for a good suggestion. " which was further down the page where you found that code SpellChecker (Lucene 3.1.0 API)[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900