The problem is not query parser, it is your analyzer.

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: u...@thetaphi.de

> -----Original Message-----
> From: raghavendra.k....@barclays.com
> [mailto:raghavendra.k....@barclays.com]
> Sent: Tuesday, October 15, 2013 12:15 AM
> To: java-user@lucene.apache.org
> Subject: QueryParser stripping off Hyphen from query
> 
> 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.
> 
> _______________________________________________


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

Reply via email to