What makes you think the query needs to be rewritten to extract terms? Not the case...unless you want to extract Terms from say, a Wildcard or Fuzzy query. In that case you need an IndexReader however, as the terms in the Wildcard/Fuzzy query are determined by what is in your index...

I am also confused by your thread safety concern...

- Mark

John Byrne wrote:
Hi,

Is there any way to find out if an instance of Query has any terms within it? I have a custom parser (QueryParser does not do everything I need) and it somtimes creates empty BooleanQuerys. (This happens as a side effect of recursive parsing - even if there are no terms for a query, I still need to create it in case there turns out to be another query nested inside it. ).

So I need to have a way of finding out if a query is blank, so that I can exclude it when creating my final query.

The documented "extractTerms" method apparently only works if the "rewrite" method is used first, and this requires an instance of IndexReader which is not feasible for me, since all this happens in a search servlet, and needs to be thread safe.

One way I have tried is to create a BooleanClause with the query, turn it into a string with "toString()" and then check if that string contains "()".

But I was hoping for a neater way!

Any suggestions?

Thanks!
JohnB


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to