lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zhang, Lisheng" <Lisheng.Zh...@broadvision.com>
Subject RE: Phrase Query Problem
Date Mon, 17 Dec 2007 21:20:16 GMT
Hi Sirish,

A few hours ago I sent a reply to your message, if my
understanding is correct, you indexed a doc with text
as

Health and Safety

and you used phrase 

Health Safety

to create a phrase query. If that is the case, this is
normal since you used StandardAnalyzer to tokenize the
input text, so certain "stop words" are filtered out, the
complete list of filtered out words are (from lucene 20
source code StopAnalyzer):

###
  "a", "an", "and", "are", "as", "at", "be", "but", "by",
    "for", "if", "in", "into", "is", "it",
    "no", "not", "of", "on", "or", "s", "such",
    "t", "that", "the", "their", "then", "there", "these",
    "they", "this", "to", "was", "will", "with"
###

The end result is the same as your input text is 

Health Safety

Best regards, Lisheng


-----Original Message-----
From: Sirish Vadala [mailto:vsirishreddy@yahoo.co.in]
Sent: Monday, December 17, 2007 10:38 AM
To: java-user@lucene.apache.org
Subject: Phrase Query Problem



I have the following code for search:

BooleanQuery bQuery = new BooleanQuery();
Query queryAuthor;
queryAuthor = new TermQuery(new Term(IFIELD_LEAD_AUTHOR,
author.trim().toLowerCase()));
bQuery.add(queryAuthor, BooleanClause.Occur.MUST);
....................................................................
....................................................................

PhraseQuery pQuery = new PhraseQuery();
String[] phrase = txtWithPhrase.toLowerCase().split(" ");
for (int i = 0; i < phrase.length; i++) {
	pQuery.add(new Term(IFIELD_TEXT, phrase[i]));
}
pQuery.setSlop(0);
bQuery.add(pQuery, BooleanClause.Occur.MUST);
....................................................................
....................................................................

String[] sortOrder = {IFIELD_LEAD_AUTHOR, IFIELD_TEXT};
Sort sort = new Sort(sortOrder);
hits = indexSearcher.search(bQuery, sort);

Now My problem here is: If I do a search on a phrase with text Health
Safety, it is fetching me all the records where in the text is Health
and/or/in Safety. It is fetching me these records even after setting the
slop of the phrase query to zero for exact match. I am using standard
analyzer while indexing my records.

Any help on this is greatly appreciated. 

Sirish Vadala
-- 
View this message in context:
http://www.nabble.com/Phrase-Query-Problem-tp14373945p14373945.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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

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