hi,
I need to perform a full text search on 2 fields make and model. The below code is used for that. The query generated is
Query =+(make:ford model:ford) +(make:fusion model:fusion)
This fits our requirements. However, if the quickSearchText has no white space after the comma, this does not work.
In this case, the query generated is Query =make:"ford fusion" model:"ford fusion"
Why does this happen? What is the work around for this problem? Can I extend StandardAnalyzer to change this behavior?
Code:
String quickSearchText = "Ford, Fusion";
String[] fields = new String[]{"make", "model"};
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
parser.setDefaultOperator(QueryParser.Operator.AND);
try{
org.apache.lucene.search.Query query = (org.apache.lucene.search.Query) parser.parse(quickSearchText);
System.out.println("Query ="+query);
Thanks,
Seema