lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jack Krupansky" <j...@basetechnology.com>
Subject Re: QueryParser and BooleanQuery
Date Sun, 22 Jul 2012 15:28:22 GMT
The query parser/analyzer is lower-casing the query terms automatically. You 
have to do the same with with terms for BooleanQuery - Term("cs-method", 
"GET") should be "Term("cs-method", "get")".

StandardAnalyzer is doing the lower-casing.

-- Jack Krupansky

-----Original Message----- 
From: Deepak Shakya
Sent: Sunday, July 22, 2012 10:17 AM
To: java-user@lucene.apache.org
Subject: QueryParser and BooleanQuery

Hi,

I have following dataset indexed in Lucene.
2010-04-21 02:24:01 GET /blank 200 120
2010-04-21 02:24:01 GET /US/registrationFrame 200 605
2010-04-21 02:24:02 GET /US/kids/boys 200 785
2010-04-21 02:24:02 POST /blank 304 56
2010-04-21 02:24:04 GET /blank 304 233
2010-04-21 02:24:04 GET /blank 500 567
2010-04-21 02:24:04 GET /blank 200 897
2010-04-21 02:24:04 POST /blank 200 567
2010-04-21 02:24:05 GET /US/search 200 658
2010-04-21 02:24:05 POST /US/shop 200 768
2010-04-21 02:24:05 GET /blank 200 347

I am querying it in two ways, first with QueryParser and other with
BooleanQuery.

*QueryParser version:*
Query q = new QueryParser(version, "cs-method", new
StandardAnalyzer(version)).parse("cs-method:GET AND cs-uri:/blank");

*BooleanQuery version:*
BooleanQuery q = new BooleanQuery();
q.add(new TermQuery(new Term("cs-method", "GET"),
BooleanClause.Occur.SHOULD);
q.add(new TermQuery(new Term("cs-uri", "/blank"),
BooleanClause.Occur.SHOULD);

When I run the two version, I am able to match the documents with the
QueryParser version, but not with BooleanQuery. The output is as follows:

*QueryParser output:*
Total Number of Documents - 11
Query --> +cs-method:get +cs-uri:blank
Total Clues Found - 5

*BooleanQuery output:*
Total Number of Documents - 11
Query --> cs-method:GET cs-uri:/blank
Total Clues Found - 0

Does anybody know why the BooleanQuery doesn't return any documents while
QueryParser does? Also, how can I change the BooleanQuery to work for the
above case?

-- 
With Regards,
Deepak Shakya 


---------------------------------------------------------------------
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