| We´d like to implement a fulltext search for eg. adress-search. The user input´s the name of the municipality and the first letters of the streetname.
queryBuilder.keyword().wildcard().onFields("municipality").onFields("streetname").matching("vienna mari*").createQuery();
This does not work, because org.hibernate.search.query.dsl.impl.ConnectedMultiFieldsTermQueryBuilder does the following:
private List<String> getAllTermsFromText(String fieldName, String localText, Analyzer analyzer) {
List<String> terms = new ArrayList<String>();
if ( termContext.getApproximation() == TermQueryContext.Approximation.WILDCARD ) {
terms.add( localText );
}
else {
try {
terms = Helper.getAllTermsFromText( fieldName, localText, analyzer );
}
catch (IOException e) {
throw new AssertionFailure( "IO exception while reading String stream??", e );
}
}
return terms;
}
The comment tell´s is, this behaviour is intended. But it depends on the configured Analyzer. In our case we use WhitespaceTokenizerFactory, so there won´t be a issue with removed * or ?. I´d like to see some kind of configuration to influence this behavior for wildcard-search. As a workarround we think of manually building the lucene-query. |