Point taken, Erik. But, is there really a downside towards using Query.toString() if someone is not using any of the complex Query Subclasses (like a SpanQuery)?
Cheers Avlesh On Mon, May 25, 2009 at 5:38 PM, Erik Hatcher <e...@ehatchersolutions.com>wrote: > Warning: toString on a Query object is *NOT* guaranteed to be parsable back > into the same Query. Don't use Query.toString() in this manner. > > What you probably want to do is create your own QParserPlugin for Solr that > creates the Query however you need from textual parameters from the client. > > Erik > > > On May 25, 2009, at 5:16 AM, Avlesh Singh wrote: > > You missed the point, Reza. toString *has to be implemented* by all >> Queryobjects in Lucene. All you have to do is to compose the right >> >> Lucene query >> matching your needs (all combinations of TermQueries, BooleanQueries, >> RangeQueries etc ..) and just do a luceneQuery.toString() when performing >> a >> Solr query. >> >> Thinking aloud, does it make sense for the SolrQuery object to take a >> Lucene >> Query object? >> I am suggesting something like this - >> SolrQuery.setQuery(org.apache.lucene.search.Query >> luceneQuery) >> >> Cheers >> Avlesh >> >> On Mon, May 25, 2009 at 2:32 PM, Reza Safari <r.saf...@lukkien.com> >> wrote: >> >> Hmmm, overriding toString() can make wonders. I will try as you >>> suggested. >>> Thanx for quick reply. >>> >>> Gr, Reza >>> >>> >>> On May 25, 2009, at 9:34 AM, Avlesh Singh wrote: >>> >>> If you use SolrJ client to perform searches, does this not work for you? >>> >>>> >>>> SolrQuery solrQuery = new SolrQuery(); >>>> solrQuery.setQuery(*myLuceneQuery.toString()*); >>>> QueryResponse response = mySolrServer.query(solrQuery); >>>> >>>> Cheers >>>> Avlesh >>>> >>>> On Mon, May 25, 2009 at 12:39 PM, Reza Safari <r.saf...@lukkien.com> >>>> wrote: >>>> >>>> Hello, >>>> >>>>> >>>>> One little question: is there any utility that can convert core Lucene >>>>> query (any type e.q. TermQuery etc) to solr query? It's is really a lot >>>>> of >>>>> work for me to rewrite existing code. >>>>> >>>>> Thanks, >>>>> Reza >>>>> >>>>> -- >>>>> Reza Safari >>>>> LUKKIEN >>>>> Copernicuslaan 15 >>>>> 6716 BM Ede >>>>> >>>>> The Netherlands >>>>> --------------------------------------------- >>>>> http://www.lukkien.com >>>>> t: +31 (0) 318 698000 >>>>> >>>>> This message is for the designated recipient only and may contain >>>>> privileged, proprietary, or otherwise private information. If you have >>>>> received it in error, please notify the sender immediately and delete >>>>> the >>>>> original. Any other use of the email by you is prohibited. >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>> -- >>> Reza Safari >>> LUKKIEN >>> Copernicuslaan 15 >>> 6716 BM Ede >>> >>> The Netherlands >>> --------------------------------------------- >>> http://www.lukkien.com >>> t: +31 (0) 318 698000 >>> >>> This message is for the designated recipient only and may contain >>> privileged, proprietary, or otherwise private information. If you have >>> received it in error, please notify the sender immediately and delete the >>> original. Any other use of the email by you is prohibited. >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> >