| Same root-cause like HSEARCH-3038 Open .
queryBuilder.keyword().wildcard().onFields("field1", "field2").matching("Word1 word2").createQuery();
We indexed field1 and field2 with LowerCaseFilterFactory. The search with wildcard does not find "Word1". This happens, 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;
}
A clean solution would be to look at Solr. Solr solves this issue by defining analysers for indexing and for query.
<fieldType name="nametext" class="solr.TextField">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.KeepWordFilterFactory" words="keepwords.txt"/>
<filter class="solr.SynonymFilterFactory" synonyms="syns.txt"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
Default-behaviour should be to use the defined analyser for index and query. But optionaly there should be the option to define a analyser for query. |