Hi
I´m having problems with the definition and use of a custom analizer in a entity.
When I set a Analizer in the class definition, then the querys return nothing. And most confusing, it does not display query in debug mode.
I´m using hibernate core 3.3 whith lucene 2.9.
Definition of the class and analyzer
Code:
@Indexed
@AnalyzerDef(name = "anuncioSearchAnalizer",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = StopFilterFactory.class, params = {
@Parameter(name="words", value="resources/stopWords.properties" ),
@Parameter(name="ignoreCase", value="true")
})
}
)
@Analyzer(definition="anuncioSearchAnalizer")
public class AnuncioSearch {
...
}
Querying:
Code:
FullTextSession fullTextSession = Search.getFullTextSession(getSession());
Analyzer analizador = fullTextSession.getSearchFactory().getAnalyzer(AnuncioSearch.class);
BooleanQuery query = new BooleanQuery();
QueryParser parser = new QueryParser(Version.LUCENE_29, "idioma", analizador);
Query fechaQuery = parser.parse("es");
query.add(fechaQuery, BooleanClause.Occur.MUST);
// wrap Lucene query in a org.hibernate.Query
org.hibernate.Query hibQuery = fullTextSession.createFullTextQuery(query, AnuncioSearch.class);
hibQuery.setMaxResults(201);
return hibQuery.list();
In debug, I check that "analizador" is an org.hibernate.search.util.ScopedAnalyzer with the Filters defined in the class.
If I comment
@Analyzer(definition="anuncioSearchAnalizer") then the query works, but it does not aply Filters beacuse it´s using StandarAnalyzer...
Any help would be very apreciate
Thanks