TLDR: use the lucene suggest/ package. Start with building suggester from your query logs (either a file or index them). These have a lot of flexibility about how the matches happen, for example pure prefixes, edit distance typos, infix matching, analysis chain, even now Japanese input-method integration :)
Run that suggester on the user input, retrieving say, the top 5-10 matches of relevant query suggestions. return those in the UI (typical autosuggest-type field), but also run a search on the first one. The user gets the instant-search experience, but when they type 'tes', you search on 'tesla' (if that's the top-suggested query, the highlighted one in the autocomplete). if they arrow-down to another suggestion such as 'test' or type a 't' or use the mouse or whatever, then the process runs again and they see the results for that. IMO for most cases this leads to a saner experience than trying to rank all documents based on a prefix 'tes': the problem is there is still too much query ambiguity, not really any "keywords" yet, so trying to rank those documents won't be very useful. Instead you try to "interact" with the user to present results in a useful way that they can navigate. On the other hand if you really want to just search on prefixes and jumble up the results (perhaps because you are gonna just sort by some custom document feature instead of relevance), then you can do that if you really want. You can use the n-gram/edge-ngram/shingle filters in the analysis package for that. On Wed, Oct 6, 2021 at 5:37 PM Michael Wechner <michael.wech...@wyona.com> wrote: > > Hi > > I am trying to implement a search with Lucene similar to what for > example various "Note Apps" (e.g. "Google Keep" or "Samsung Notes") are > offering, that with every new letter typed a new search is being executed. > > For example when I type "tes", then all documents are being returned > containing the word "test" or "tesla" and when I continue typing, for > example "tesö" and there are no documents containing the string "tesö", > then the app will tell me that there are no matches. > > I have found a couple of articles related to this kind of search, for > example > > https://stackoverflow.com/questions/10828825/incremental-search-using-lucene > > https://stackoverflow.com/questions/120180/how-to-do-query-auto-completion-suggestions-in-lucene > > but would be great to know whether there exist other possibilities or > what the best practice is? > > I am even not sure what the right term for this kind of search is, is it > really "incremental search" or something else? > > Looking forward to your feedback and will be happy to extend the Lucene > FAQ once I understand better :-) > > Thanks > > Michael > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org