Issue
i've implemented the hibernate search orm (LATEST lucene_version) that search words contains a entry query :
FullTextEntityManager fullTextEntityManager = Search.getFullTextEntityManager(entityManager);
QueryBuilder queryBuilder = fullTextEntityManager.getSearchFactory()
.buildQueryBuilder()
.forEntity(Application.class)
.get();
Query queryName = queryBuilder
.keyword().fuzzy().withEditDistanceUpTo(2).withPrefixLength(2)
.onField("name")
.matching("*" + q + "*")
.createQuery();
this queryName cannot find words like 'Wikicrédit' or 'Wikipro' or 'WikiCash' if my query is 'q=Wiki'
How can i enhance those instructions to get words that start with 'Wiki%' independently of edit distance !
Solution
Either:
- Use the
simpleQueryString
query and type your query asWiki*
. - Declare a separate
name-edgengram
field with an edge-ngram analyzer that will indexWikicrédit
as[W, Wi, Wik, Wiki, Wikic, Wikicr, ...]
and then query that field, as desribed in this answer.
Answered By - yrodiere