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* for making queries I understand that in the constructor of QueryParser it takes default field and a analyzer. If I put a blank field it seems to work. Putting null gives a null pointer exception. Regards, Prabin On Jan 16, 2008 7:44 PM, Erick Erickson <[EMAIL PROTECTED]> wrote: > 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 to see if my memory is correct). > > That said, use BooleanQuery to add as many clauses in > as many ways as you want. > > Actually, I don't know how I'd go about storing a programmatically > constructed query, I'd sure like to know if there's a way. You could > certainly store the original query if you were taking user input and > parsing it... > > Best > Erick > > On Jan 16, 2008 4:22 AM, prabin meitei <[EMAIL PROTECTED]> wrote: > > > 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 > > >