Hi Juan,

I enquired about this not so long ago. To support disjunctive queries you 
will have to write a plug in. I used query-basic as a template for writing a 
plug-in called query-disjunctive. See the Lucene javadocs for 
org.apache.lucence.search.BooleaQuery. Check out the method called add(Query 
query, boolean required, boolean prohibited). In the plug-in code specify 
the required field as false.

Here's a little snippet from my query-disjunctive plug-in:

private static void addTerms(Query input, BooleanQuery output) {
Clause[] clauses = input.getClauses();
for (int i = 0; i < clauses.length; i++) {
Clause c = clauses[i];

if (!c.getField().equals(Clause.DEFAULT_FIELD))
continue; // skip non-default fields

BooleanQuery out = new BooleanQuery();
for (int f = 0; f < FIELDS.length; f++) {

Clause o = c;
if (c.isPhrase()) { // optimize phrase clauses
String[] opt = CommonGrams.optimizePhrase(c.getPhrase(), FIELDS[f]);
if (opt.length==1) {
//o = new Clause(new Term(opt[0]), c.isRequired(), c.isProhibited());
o = new Clause(new Term(opt[0]), false, c.isProhibited());
} else {
//o = new Clause(new Phrase(opt), c.isRequired(), c.isProhibited());
o = new Clause(new Phrase(opt), false, c.isProhibited());
}
}

out.add(o.isPhrase()
? exactPhrase(o.getPhrase(), FIELDS[f], FIELD_BOOSTS[f])
: termQuery(FIELDS[f], o.getTerm(), FIELD_BOOSTS[f]),
false, false);
}
//output.add(out, c.isRequired(), c.isProhibited());
output.add(out, false, c.isProhibited());
}
}

Hope this helps,
Nick.


On 05/08/05, Juan Luis de Amaya Robles < [EMAIL PROTECTED]> wrote:
> 
> Hi,
> 
> I have nutch installed (0.6). It seems works fine. 
> if i search for "Nasa", returns several results. But if I search for
> neither "pepito OR Nasa" nor "pepito Nasa", returns nothing.
> 
> bool operators in search query works ?
> 
> thanks 
> 
> <http://dailydurham.blogspot.com>

Reply via email to