Re: constructing query from string

2008-01-17 Thread prabin meitei
For the query I am using *newQ.toString* equals *queryFrom.ToString *well, what i am trying to accomplish is that I need to search an index (quite often say interval of around 15 mins) and the query depends on other activities done by the user till that point of a time. but i don't want the query

Re: constructing query from string

2008-01-17 Thread Erick Erickson
I just thought of an interesting test for whether toString() is reasonable. You could log/flag when the reloaded query differs. I.e. String queryFromToString; // your stored form Query newQ = parser.parse(queryFromToString); if (newQ.toString != queryFromToString) { log some stuff or throw an ex

Re: constructing query from string

2008-01-17 Thread Erick Erickson
I believe, but I'm not sure, that query and newQuery are not guaranteed to be equivalent. So I'd be cautious about this approach. But if it works for you I'm assuming that you're somehow programmatically constructing the query and therefore can't just store the original string. I'd *always* st

Re: constructing query from string

2008-01-17 Thread prabin meitei
Hi Erick, Thanks for your response. I have tried the folowing way and seems to be working. Tell me if there is any problem with the approach. String str = query.toString(); QueryParser parser = new QueryParser("", new StandardAnalyzer); Query newQuery = parser.parse(str); now use *newQuery* fo

Re: constructing query from string

2008-01-16 Thread Erick Erickson
As I remember from various threads, toString is more of a debugging aid and you cannot completely rely on the transformation from a parsed query -> tostring -> parsed query to be reliable. But this is "something I remember", so take it with a grain of salt (you might want to search the mail archive

constructing query from string

2008-01-16 Thread prabin meitei
Hi , I want to construct a query from string. how can I do it?? Actually i saved a query(a boolean query) as string (using query.toString()). Is there a way to reconstruct the query from the string i saved? How can i add more clauses to the reconstructed query? Thanks in advance. Prabin