On Aug 19, 2005, at 3:12 AM, Karthik N S wrote:
With refrence to the code as below
public static Query Sparse(String texts, String[] fields, Analyzer
analyzer)
{
Query bQuery = null;
try {
for (int i = 0; i < fields.length; i++) {
QueryParser qp = new QueryParser(fields[i], analyzer);
qp.setOperator
(org.apache.lucene.queryParser.QueryParser.DEFAULT_OPERATOR_AN
D);
bQuery = qp.parse(texts);
System.out.println("QUERY ANDED :" + bQuery.toString());
}
} catch(Exception pxe) {pxe.printStackTrace();}
return bQuery;
}
Using a search word = 'blue dial watch'
The Query Represented as +(content:blue content:dial content:watch)
returned me more then 100+ hits
But When used the Query representation on the same Index using LUKE
+content:blue +content:dial +content:watch
returned 10+ hits
Please can u give enlighten me with more some ideas....
Well sure.... you're not building a BooleanQuery as shown in the
original code from MFQP. Simply copy the code I provided, and add
the setOperator into it. You left out important stuff!
Erik
With regards
Karthik
-----Original Message-----
From: Erik Hatcher [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 4:07 PM
To: java-user@lucene.apache.org
Subject: Re: DEFAULT_OPERATOR_AND
On Aug 18, 2005, at 1:48 AM, Karthik N S wrote:
Does this mean MultiFieldQueryParser will always have to use
'DEFAULT_OPERATOR_OR' instead of DEFAULT_OPERATOR_AND
operations.
Yup, that's what I said :)
Is there any alternative in handling this processs ( other then API
'replaceAll(" ", " AND ")' substution)
Of course there are alternatives! MFQP is merely a thin layer on
top of QueryParser. You're free to create Query's anyway you like.
Here's one of the parse methods from MFQP:
public static Query parse(String[] queries, String[] fields,
Analyzer analyzer) throws ParseException
{
if (queries.length != fields.length)
throw new IllegalArgumentException("queries.length !=
fields.length");
BooleanQuery bQuery = new BooleanQuery();
for (int i = 0; i < fields.length; i++)
{
QueryParser qp = new QueryParser(fields[i], analyzer);
Query q = qp.parse(queries[i]);
bQuery.add(q, BooleanClause.Occur.SHOULD);
}
return bQuery;
}
You could simply create a piece of code like that with the
setOperator in there.
Erik
Please enlighten me
With regards
Karthik
-----Original Message-----
From: Erik Hatcher [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 18, 2005 7:09 AM
To: java-user@lucene.apache.org
Subject: Re: DEFAULT_OPERATOR_AND
On Aug 17, 2005, at 2:45 AM, Karthik N S wrote:
Hi Lucener's
Apologies..........
I have seen forms using 'DEFAULT_OPERATOR_AND' with something
like below
QueryParser parser = new QueryParser( "terms", analyzer);
parser.setOperator(QueryParser.DEFAULT_OPERATOR_AND);
query = parser.parse(TextParameters);
How to use the DEFAULT_OPERATOR_AND when using
MultiFieldQueryParser as below
"query = MultiFieldQueryParser.parse("text",fields,analyzer);" ?
[ I also searched the other Form's for same but no answers.]
MultiFieldQueryParser does not adhere to the default operator
setting, and will always use OR.
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]