Hi,
I'm new here, however, I'm experiencing exactly the same problems. I am using Hibernate Search 3.1.0.CR1 with Lucene 2.4.
In my entity bean I have different @AnalyzerDef annotations. For example, one field is annonated with
Code:
@Fields({
@Field(), // not stored, tokenized with default Analyzer of entity "ElementStandardAnalyzer")
@Field(name = "titlePatterns", analyzer = @Analyzer(definition = "ElementPatternAnalyzer")),
@Field(name = "titlePlain", analyzer = @Analyzer(definition = "ElementPlainAnalyzer"))
})
public String getTitle()
{
return title;
}
The "ElementStandardAnalyzer" is the default analyzer for the entity (@Analyzer annotation at the entity itself).
I also have fields which are not tokenized with an analyzer:
Code:
@Field(store = Store.YES, index = Index.UN_TOKENIZED)
public String getAssignedEAN()
{
return assignedEAN;
}
I build my query using the QueryParser:
Code:
FullTextEntityManager fem = Search.getFullTextEntityManager(em);
Analyzer luceneAnalyzer = fem.getSearchFactory().getAnalyzer(MyEntity.class);
QueryParser parser = new MultiFieldQueryParser(fields, luceneAnalyzer);
According to
Hibernate Search in Action, section 7.2.6 "the ScopedAnalyzer should apply the specified analyzer to its matching field" automatically. And indeed,
Code:
parser.parse("Blink182").toString()
evaluates to something like
Code:
title:blink182 titlePatterns:"blink 182" titlePlain:blink182 assignedEAN:blink182
However, it seems that my "ElementStandardAnalyzer" has been applied to the field
assignedEAN even though it is annotated as un-tokenized (you see that it's converted to lower-case). If there really was an EAN "Blink182" in the index it would not be found.
Did I miss something or is it a mistake to use the QueryParser when searching in un-tokenized fields?
Many thanks in advance for any help,
Joachim