I guess the most direct equivalent to SQL LIKE %xyz% is just a Wildcard search on top of non-analyzed fields (requires you to allow leading wildcards), so search for *xyz*. However, just like in SQL, doing a LIKE %xyz or LIKE %xyz% - a search for *xyz or *xyz* results in a full index scan which is just not very efficient in any of the two environments, and you asked for an efficient way after all.
One very simple trick from that arena is to simply index the same term in reverse as well and then perform searches that has leading wildcards on that. That would bring us towards something like: "field: xyz* AND field_reverse: zyx*". Which could be somewhat more digestible compared to ngrams. Remember though, Lucene is a different kind of beast, the above is very much taking a "SQL mindset" and forcing that down over Lucene. That will not go very well in all cases. Kind regards Jens Melgaard Architect Systematic A/S Søren Frichs Vej 39 8000 Aarhus C Denmark Mobile: +45 4196 5119 jens.melga...@systematic.com https://systematic.com/defence/defence-newsletter https://www.linkedin.com/showcase/systematic-defence/ -----Original Message----- From: Haberl Norbert <norbert.hab...@ssi-schaefer.com> Sent: 26. juni 2020 10:10 To: user@lucenenet.apache.org Subject: AW: Infix search possible in Lucene [EXTERNAL] Thanks Shad ... that's using prefix search within a given phrase (which is perfect if you are looking for book titles or so) I need a contaions search for autocompletes (mostly single words) -> an Sql equivalent to LIKE %xyz% Wondering that lucene is not capable of this functionality. I have seen the freetext suggester but there is no scoring and acts mostly as a fallback. -----Ursprüngliche Nachricht----- Von: Shad Storhaug <s...@shadstorhaug.com> Gesendet: Freitag, 26. Juni 2020 09:40 An: user@lucenenet.apache.org Betreff: RE: Infix search possible in Lucene Would using the AnalyzingInfixSuggester help? https://lucenenet.apache.org/docs/4.8.0-beta00008/api/Lucene.Net.Suggest/Lucene.Net.Search.Suggest.Analyzing.AnalyzingInfixSuggester.html -----Original Message----- From: Haberl Norbert <norbert.hab...@ssi-schaefer.com> Sent: Friday, June 26, 2020 2:36 PM To: user@lucenenet.apache.org Subject: AW: Infix search possible in Lucene Any details ? -----Ursprüngliche Nachricht----- Von: Erik Hatcher <erik.hatc...@gmail.com> Gesendet: Freitag, 26. Juni 2020 09:10 An: user@lucenenet.apache.org Betreff: Re: Infix search possible in Lucene Yes. This can be achieved by indexing ngrams of each word. Erik > On Jun 26, 2020, at 03:03, Haberl Norbert <norbert.hab...@ssi-schaefer.com> > wrote: > > Is there a way to perform efficient *xyz* queries in Lucene? > I see a lot of suggesters in the src but no docs. Have read Mike's posts > about autocomplete but this is based on prefix searches. > > Best regards, > Norbert Haberl | Software Engineer - Global Tools Development | > Customer Service & Support Phone +43 316 6096 - 8435 | Mobile +43 676 > 8766 - 8435 SSI SCHÄFER | SSI Schäfer Automation GmbH | > Fischeraustraße 27 | 8051 Graz | Austria > > norbert.hab...@ssi-schaefer.com<mailto:norbert.hab...@ssi-schaefer.com > > > > Website<http://www.ssi-schaefer.de/en> | > Blog<http://www.ssi-schaefer.de/blog/en> | > YouTube<http://youtube.com/warehouselogistics> | > Facebook<http://facebook.com/SSI.SCHAEFER.EN> >