How-to build AutoComplete / Suggestions with Lucene.NET ?
Asked
Active
Viewed 3,023 times
2
-
Do you want it to act upon previous queries, the full dictionary of the search index, or do lookup/search against certain fields of your data? – Mikael Svenson Feb 17 '10 at 15:52
-
Here's a nice, newer question with a good [answer](https://stackoverflow.com/questions/24968697/how-to-implements-auto-suggest-using-lucenes-new-analyzinginfixsuggester-api) Using Java, but if you use the 4.8 beta, then it's fine – Alexander Jun 21 '18 at 18:30
2 Answers
1
Very simple response here, it'll get you started.
The SpellChecker project, which is part of lucene.net contrib, will give you Google's "Did you mean?" like functionality, check that out.
For AutoComplete, you could append an * at the end of the text query. So ja* would return java, jack, jane, etc. Also, *va would return java, lava, etc (although you have to explicitly allow leading wildcards)
hope this helps

Pablote
- 4,745
- 9
- 39
- 46
-4
create a database of all search queries coming into your application. (query log)
create a table that has similar fields
QueryText varchar(x)
Occurence int
then do a search where the query text starts with what the user is searching for and order by the occurrence descending.
where QueryText LIKE 'some text%' ORDER BY Occurence DESC

Andrew Smith
- 1,634
- 10
- 11
-
Am interested to see why people downvoted this, although I think I know the answer... (too slow?) – Tim Lovell-Smith Nov 27 '12 at 07:58
-
I'm not sure myself, but this wouldn't be slow at all because we are marking the Occurrence of the query, so instead of 100 lines of the same text, we have only 1 line with an occurrence of 100. You can store this yourself inside of SQL or in Lucene if you wanted. I actually use this and it does very well at finding common search phrases. – Andrew Smith Apr 01 '14 at 14:24