I have the fields - make and model - in the Lucene index. These fields are mapped as Index.TOKENIZED using Hibernate search annotations.
I want to do a quick full text search on these 2 fields. In one of the records, the value of make is "Make-1" and model is "Hello World". When I pass the search string "Make-1 Hello", this record is getting matched because I'm using StandardAnalyzer. But I don't want this. I want this record to be matched only if I pass "Make-1 Hello World" or "Make-1 hello world". That is, I want the whole phrase to be matched, but case should not be sensitive. Is there any built in analyzer that works this way? Which existing analyzer can I easily extend to achieve this otherwise?
My code is as follows.
Code:
String[] fields = new String[] { "model", "make"};
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields,
new StandardAnalyzer());
parser.setDefaultOperator(QueryParser.Operator.AND);
String s = "Make-1 Hello";
Query query = parser.parse(s);
Thanks,
Seema