-
1. Re: Case Sensitivity Searches for Infinispan Query Module
hardy.ferentschik Aug 22, 2012 4:59 AM (in response to paulpa63)1 of 1 people found this helpfulHi Paul,
you will need to specify/configure the right analyzer (for indexing and searching). Per default Lucene will use the StandardAnalyzer which is a combination of StandardTokenizer with StandardFilter, LowerCaseFilter
and StopFilter using a list of English stop words. The problem in your case is the LowerCaseFilter which you don't need.
To configure your analyzer you can use the @AnalyzerDef annotation. It looks sometimes like this:
@AnalyzerDef(name = "case-sensitive",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
@TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
@Parameter(name = "language", value = "English")
})
})
@Indexed
public class MyClass {
@Field(index = Index.YES, analyze = Analyze.YES, analyzer = @Analyzer(definition = "case-sensitive"))
private String myField;
}
Have a look also at the Analysis chapter of the Hibernate Search online docs - http://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#d0e3385
It is important that you use the case sensitive analyzer at query time as well in case you are using a QueryParser.
Hope this helps.
-
2. Re: Case Sensitivity Searches for Infinispan Query Module
paulpa63 Aug 22, 2012 6:45 AM (in response to hardy.ferentschik)Hi Hardy,
Thanks for your response. I did try making some changes along these lines but ran into a "cannot be resolved to a type" error on the SnowballPorterFilterFactory class when that is referenced in the analyzer specification. I am including all of the jars from the query module of Infinispan 5.1.5.FINAL so this seems odd to me?
Re your final comment, as I am using a QueryBuilder I assume there would be no further configuration / declaration required in my case on the query end?
Thanks in advance,
Paul
-
3. Re: Case Sensitivity Searches for Infinispan Query Module
sannegrinovero Aug 28, 2012 7:52 AM (in response to paulpa63)1 of 1 people found this helpfulHi Paul,
sorry for the delay. Holiday times for most of us
Many Analyzers are optional dependencies, and distributed only with Hibernate Search, not with Infinispan as it's too big already. The SnowballPorterFilterFactory isn't actually needed to implement just case-sensitive search - it's just an example of how to define a custom text analysis. The SnowballPorterFilterFactory provides sofisticated language analysis using stemming.
If that's what you're looking for, you can download the additional optional jars from:
http://www.hibernate.org/subprojects/search/download
But for your simple case I guess you could leave that filter our:
@AnalyzerDef(name = "case-sensitive",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class),
})
-
4. Re: Case Sensitivity Searches for Infinispan Query Module
paulpa63 Aug 29, 2012 7:31 AM (in response to sannegrinovero)Hi Sanne,
Thanks for your reply. I have included solr-core and solr-solrj from Hibernate Search and the application now compiles and runs with the custom Analyzer definition. I have specified this analyzer in the @FIeld annotation on the relevant object name attrribute. However, I am still not achieving case sensitive search. (I have not made any other changes to the SearchManager/QueryBuilder/Query code?)
Paul
PS I trust you enjoyed your holiday!