Mailing List Archive

"Match All Words" Query
Hi!

I've been going round in circles trying to come up with a query that will return documents which contian ALL the query terms. This should be easy, however I would like the words to span ANY of the fields of the documents.

If the BooleanQuery(ies) do actually follow boolean logic, then I should be able to form this query:

BooleanQuery b = new BooleanQuery();

for each term in the query {
BooleanQuery sub_query = new BooleanQuery();
for each field {
Query q = QueryParser.parse(term,field,analyzer);
sub_query.add(q,false,false); <---- disjunction of fields
}

b.add(sub_query,true,false); <---- conjunction of terms
}

And then b *should* be the query.

However, the query does not give the desired results!

Probably most all users of Lucene have needed such a query... I feel i'm complicating things here!

Help would be greatly appreciated.

Melissa.
Re: "Match All Words" Query [ In reply to ]
Melissa Mifsud wrote:
>
> I've been going round in circles trying to come up with a query that will return documents which contian ALL the query terms. This should be easy, however I would like the words to span ANY of the fields of the documents.

Just a thought... have you tried building a string that'll do the query you
require and then letting the QueryParser create the actual query object(s)?

If that works, then delve into the QueryParser code and see how it does what
you're trying to do...

cheers,

Chris - Lucene Newbie, don't bite me, I don't speak Java ;-)

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
RE: "Match All Words" Query [ In reply to ]
Hi,
I haven't tried two levels of boolean queries but I did use the following
and it works fine for me.

BooleanQuery bool_query = new BooleanQuery();
for each field
{
Query q = QueryParser.parse(term,field,analyzer);
bool_query.add(q,false,false);
}
searcher.search( bool_query);
Aruna.
-----Original Message-----
From: Melissa Mifsud [mailto:melissamifsud@yahoo.com]
Sent: Saturday, April 06, 2002 10:17 AM
To: Lucene User
Subject: "Match All Words" Query


Hi!

I've been going round in circles trying to come up with a query that will
return documents which contian ALL the query terms. This should be easy,
however I would like the words to span ANY of the fields of the documents.

If the BooleanQuery(ies) do actually follow boolean logic, then I should be
able to form this query:

BooleanQuery b = new BooleanQuery();

for each term in the query {
BooleanQuery sub_query = new BooleanQuery();
for each field {
Query q = QueryParser.parse(term,field,analyzer);
sub_query.add(q,false,false); <----
disjunction of fields
}

b.add(sub_query,true,false); <---- conjunction of terms
}

And then b *should* be the query.

However, the query does not give the desired results!

Probably most all users of Lucene have needed such a query... I feel i'm
complicating things here!

Help would be greatly appreciated.

Melissa.

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>