lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Byrne <john.by...@propylon.com>
Subject Querying the Query object
Date Fri, 05 Oct 2007 16:22:57 GMT
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: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message