so hibernate does not support left leading wild card, right?
It’s generally not a good idea, but it does work. You just have to use
queryBuilder.keyword().wildcard().onField("myField).matching("*581*").createQuery(). Don’t forget the
.wildcard() call. See the documentation.
If it doesn’t work for you, please provide more details: your mapping, your analyzers, the exact data that gets indexed, how you build the query, what terms you pass to the query.
Is there a api to setAllowLeadingWildcard(true)?
No, since it works by default, without any warning, on contrary to Lucene’s QueryParser.
By the way, I don’t want to use ngrams, just simple query, just wild card.
As you wish. There are limitations to wildcard queries, though. You probably already know that performance won’t be great with a leading wildcard, but more importantly wildcard queries are not analyzed, so any cleanup you want to be performed on the search terms (removing dots, removing spaces, …), you will have to perform yourself. That’s a Lucene limitation, and it affects both the Lucene and Elasticsearch integrations.