Hi,

I am using the regular QueryParser to form a PhraseQuery. It works fine, but 
when it consists of a hyphen, it gets removed, hence resulting in unexpected 
results.

Note: I am NOT using the QueryParser.escape() method before parse() method as 
it results in a BooleanQuery, while I want a PhraseQuery.

Please suggest how to retain the hyphen ("-") in my query.

*** Code **
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);
QueryParser parser = new QueryParser(Version.LUCENE_43, "CONTENTS", analyzer);
Query query = parser.parse(strSearch);
logger.info("Type of query: " + query.getClass().getSimpleName());
logger.info("query.toString: " + query.toString());

*** Log output ***
Contents of strSearch: "ab-cde"
Type of query: PhraseQuery
query.toString: CONTENTS:"ab cde"

Regards,
Raghu


_______________________________________________

This message is for information purposes only, it is not a recommendation, 
advice, offer or solicitation to buy or sell a product or service nor an 
official confirmation of any transaction. It is directed at persons who are 
professionals and is not intended for retail customer use. Intended for 
recipient only. This message is subject to the terms at: 
www.barclays.com/emaildisclaimer.

For important disclosures, please see: 
www.barclays.com/salesandtradingdisclaimer regarding market commentary from 
Barclays Sales and/or Trading, who are active market participants; and in 
respect of Barclays Research, including disclosures relating to specific 
issuers, please see http://publicresearch.barclays.com.

_______________________________________________

Reply via email to