Hi there,
the exception message is "Try to search with an empty string: "
The only change I made to the application is an attempt for a custom analyzer (mostly copied from 'hibernate search in action").
this is how i annotated the indexed entity:
Code:
@Indexed
@AnalyzerDef(name="caseanalyzer",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = StopFilterFactory.class,
params = {
@Parameter(name="words", value="stopwords.txt"),
@Parameter(name="ignoreCase", value="true")
})
}
)
@Analyzer(definition = "caseanalyzer")
in addition to this, hibernate config declares a default stadardanalyzer
Code:
(<property name="hibernate.search.analyzer">org.apache.lucene.analysis.standard.StandardAnalyzer</property>)
which is working just fine.
after indexing with above, luke works just as expected, tried with a couple analyzers in there, stopwords won't retrieve anything while legit words are working fine, lowercased, etc.
however, my program making use of hibernate-search results in the above error.
just a few more details by going up the stack:
- create QueryBuilder
- query.add(qb.keyword().onField("name").matching(search.getSimpleQuery()).createQuery(), SHOULD);
- ConnectedMultiFieldsTermQueryBuilder.createQuery()
- ConnectedMultiFieldsTermQueryBuilder.createQuery(FieldContext)
here
FieldContext.field = name
this.value = value_of_the_stopword
then
searchTerm is assigned the above value
entering this method
Code:
private List<String> getAllTermsFromText(String fieldName, String localText, Analyzer analyzer) {
//it's better not to apply the analyzer with wildcard as * and ? can be mistakenly removed
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;
}
which returns an empty list of terms (termContext.getApproximation() == EXACT)
because of last step, SearchException( "Try to search with an empty string: " + fieldContext.getField() ) is thrown.
I will continue to investigate this some more, however I would much appreciate any hint on what i might be doing wrong or maybe an idea on a simpler workaround.
thank you,
val