lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "G.Long" <jde...@gmail.com>
Subject case-insensitive index and queries
Date Wed, 07 Nov 2012 15:50:56 GMT
Hi :)

I would like the "text" field of my index to be case-insensitive.
I'm using a PerFieldAnalyzerWrapper with a standardAnalyzer for this 
field for both indexing and querying. I read that StandardAnalyzer uses 
LowerCaseFilter to lowercase the value of the field but when I run a 
query, it doesn' work.

Here is my query :

IndexSearcher isearcher = new IndexSearcher(directory);
BooleanQuery query = new BooleanQuery();
PerFieldAnalyzerWrapper pfaWrapper = getPerfFieldAnalyzer();

QueryParser parser = new QueryParser(Version.LUCENE_31, key, pfaWrapper);
parser.setDefaultOperator(QueryParser.AND_OPERATOR);
Query param = parser.parse(value);
query.add(param, BooleanClause.Occur.MUST);

TopFieldCollector collector = TopFieldCollector.create(new 
Sort(SortField.FIELD_DOC), 200000, true, false, false, false);
isearcher.search(query, collector);


The getPerFieldAnalyzer() methods looks like :

if(perFieldAnalyzerWrapper==null){
             perFieldAnalyzerWrapper = new PerFieldAnalyzerWrapper(new 
KeywordAnalyzer());
             perFieldAnalyzerWrapper.addAnalyzer(FIELD_TEXT, new 
StandardAnalyzer(Version.LUCENE_31));
             perFieldAnalyzerWrapper.addAnalyzer(FIELD_TITLE, new 
StandardAnalyzer(Version.LUCENE_31));
}
return perFieldAnalyzerWrapper;

Is there something wrong with this code?

Thank you :)


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message