2008/3/6, Chris Hostetter <[EMAIL PROTECTED]>:
>
>
> : If I do a query.toString(), both queries give different results, which
>
> : is probably a clue (additional paren's with the BooleanQuery)
> :
> : Query.toString the old way using queryParser:
> : +(id:1^2.0 id:2 ... ) +type:CORE
> :
> : Query.toString the new way using BooleanQuery:
> : +((id:1^2.0) (id:2) ... ) +type:CORE
>
>
> i didn't look too closely at the psuedo code you posted, but the
> additional parens normally indicates that you are actually creating an
> extra layer of BooleanQueries (ie: a BooleanQuery with only one clause for
> each term) ... but the rewrite method should optimize those away (even
> back in lucene 2.2) ... if you look at query.rewrite(reader).toString()
> then the queries *really* should be the same, if they aren't, then that
> may be your culprit.
look here,
parens will also be add is each term has a boost value larger than 1.0.
public String toString(String field) {
StringBuffer buffer = new StringBuffer();
boolean needParens=(getBoost() != 1.0) ||
(getMinimumNumberShouldMatch()>0) ;
if (needParens) {
buffer.append("(");
}
for (int i = 0 ; i < clauses.size(); i++) {
BooleanClause c = (BooleanClause)clauses.get(i);
if (c.isProhibited())
buffer.append("-");
else if (c.isRequired())
buffer.append("+");
Query subQuery = c.getQuery();
if (subQuery instanceof BooleanQuery) { // wrap sub-bools in
parens
buffer.append("(");
buffer.append(c.getQuery().toString(field));
buffer.append(")");
} else
buffer.append(c.getQuery().toString(field));
if (i != clauses.size()-1)
buffer.append(" ");
}
if (needParens) {
buffer.append(")");
}
if (getMinimumNumberShouldMatch()>0) {
buffer.append('~');
buffer.append(getMinimumNumberShouldMatch());
}
if (getBoost() != 1.0f)
{
buffer.append(ToStringUtils.boost(getBoost()));
}
return buffer.toString();
}
-Hoss
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>