rewrite()ing BooleanQuery results in empty clauses

View: New views
2 Messages — Rating Filter:   Alert me  

rewrite()ing BooleanQuery results in empty clauses

by ssenecal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am rewriting some BooleanQueries and the end result contains some empty
queries.

The initial query is of the form: Field1:foo* Field2:foo* Field3:foo*
Field4:foo* Field5:foo* Field6:foo*

The rewritten query is of the form: ConstantScore(Field1:foo*)
ConstantScore(Field2:foo*) ConstantScore(QueryWrapperFilter())
ConstantScore(QueryWrapperFilter()) ConstantScore(QueryWrapperFilter())
ConstantScore(QueryWrapperFilter())

The thing is, the BooleanQueries contained in the QueryWrapperFilter()s have
no clauses present.  Would this affect the performance of the query at all?
Is there a way I can prevent empty queries like these from being written if
there is a performance penalty?


Shaun

Re: rewrite()ing BooleanQuery results in empty clauses

by Michael McCandless-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

For 2.9, I believe there's hardly any runtime cost to the embedded
BooleanQuery instances that have no clauses -- when the scorer method
is invoked, it will return null, which will in turn translate into an
DocIdSet.EMPTY_DOCIDSET that ends the iteration immediately on the
first call to nextDoc.

But if you test this and find otherwise, please report back!

Mike

On Wed, Nov 4, 2009 at 3:28 AM, Shaun Senecal <ssenecal.work@...> wrote:

> I am rewriting some BooleanQueries and the end result contains some empty
> queries.
>
> The initial query is of the form: Field1:foo* Field2:foo* Field3:foo*
> Field4:foo* Field5:foo* Field6:foo*
>
> The rewritten query is of the form: ConstantScore(Field1:foo*)
> ConstantScore(Field2:foo*) ConstantScore(QueryWrapperFilter())
> ConstantScore(QueryWrapperFilter()) ConstantScore(QueryWrapperFilter())
> ConstantScore(QueryWrapperFilter())
>
> The thing is, the BooleanQueries contained in the QueryWrapperFilter()s have
> no clauses present.  Would this affect the performance of the query at all?
> Is there a way I can prevent empty queries like these from being written if
> there is a performance penalty?
>
>
> Shaun
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@...
For additional commands, e-mail: java-user-help@...