lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aviran Mordo" <amo...@infosciences.com>
Subject RE: having problem with BooleanQuery
Date Tue, 08 Apr 2003 17:42:45 GMT
Here is how you do it.

BooleanQuery completeQuery = new BooleanQuery();
BooleanQuery bQuery = new BooleanQuery();
// full text
for (int i = 0; i < fields.length; i++)
{
  Query q = QueryParser.parse(queryString, fields[i], analyzer);
  bQuery.add(q, false, false);
}
completeQuery.add(bQuery,true,false);
// category
if(categoryQueryString != null)
{
   BooleanQuery categoryQuery = new BooleanQuery();
   for (int i = 0; i < fieldCategories.length; i++)
   {
    Query q = QueryParser.parse(categoryQueryString, fieldCategories[i],
analyzer);
    categoryQuery.add(q, false, false);
   }
   completeQuery.add(categoryQuery,true,false);
}


-----Original Message-----
From: Andrey Akselrod [mailto:aakselrod@runtime.com] 
Sent: Tuesday, April 08, 2003 1:30 PM
To: lucene-user@jakarta.apache.org
Subject: having problem with BooleanQuery


Hello,

I need to perform the follwoing search:
(search my full text fields using or condition) AND (search my category
fields using or condition)

This is what I tried to do:
BooleanQuery bQuery = new BooleanQuery();
// full text
for (int i = 0; i < fields.length; i++)
{
  Query q = QueryParser.parse(queryString, fields[i], analyzer);
  bQuery.add(q, false, false);
}
// category
if(categoryQueryString != null)
{
   BooleanQuery categoryQuery = new BooleanQuery();
   for (int i = 0; i < fieldCategories.length; i++)
   {
    Query q = QueryParser.parse(categoryQueryString, fieldCategories[i],
analyzer);
    categoryQuery.add(q, false, false);
   }
   bQuery.add(categoryQuery, false, false);
}

It does not seem to search categories. The documentation is not clear on
how to perform AND in my above condition. I tried to do
bQuery.add(categoryQuery, true, false), but then it stops returning any
results. I don't entirely understand BooleanQuery.add() function flags.

Any ideas on how to do this?

Thank you,
-a


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



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


Mime
View raw message