Reputation: 13
how add wildcard query when using hibernate search. I am using Hibernate Search 3.1.1GA jar and unable to upgrade my jar to upper version. In upper version of hibernate we can use wildcard method using Query Builder.
I am stuck please help me out.
Upvotes: 1
Views: 222
Reputation: 19109
I assume you are referring to the Hibernate Search query DSL. Something like this:
Query luceneQuery = queryBuilder
.keyword()
.wildcard()
.onField("foo")
.matching("bar*")
.createQuery();
This DSL is indeed not part Search 3.1.1 and was added later. In this version you need to build your queries by using native Lucene queries. Really all the Search DSL does is under the hood building these native queries for you. In your case you want to look at org.apache.lucene.search.WildcardQuery
or you could use the org.apache.lucene.queryParser.QueryParser
to use the Lucene query syntax which also allows wildcards.
Upvotes: 2