You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by "balaji.gandhi" <ji...@gmail.com> on 2013/01/16 21:46:19 UTC

Parsing a Lucene/Solr query and adding more clauses

Hi Team, 

I am trying to write a util which can parse a Lucene/Solr query and convert
into an object representation to add more clauses to the query. 

Eg. 
Input: (name:John AND name:Doe) 
Output: ((firstName:John OR lastName:John) AND (firstName:John OR
lastName:John)) 

I tried org.apache.lucene.queryparser.classic.QueryParser to parse the query
and iterate over the terms. But this doesn't give me the boolean operators
and boosting. Tried to use
org.apache.lucene.queryparser.surround.parser.QueryParser and
org.apache.lucene.queryparser.surround.query.SrndQuery. I didn't see any API
to manipulate the query. 

What would be the best way to do this? 

Thanks, 
Balaji



--
View this message in context: http://lucene.472066.n3.nabble.com/Parsing-a-Lucene-Solr-query-and-adding-more-clauses-tp4033973.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Parsing a Lucene/Solr query and adding more clauses

Posted by "balaji.gandhi" <ji...@gmail.com>.
This is awesome. Thanks. I will look into the API and figure out how to
manipulate the query nodes.



--
View this message in context: http://lucene.472066.n3.nabble.com/Parsing-a-Lucene-Solr-query-and-adding-more-clauses-tp4033973p4034031.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Re: Parsing a Lucene/Solr query and adding more clauses

Posted by Adriano Crestani <ad...@gmail.com>.
The Flexible query parser is what you are looking for:
http://lucene.apache.org/core/4_0_0/queryparser/index.html


On Wed, Jan 16, 2013 at 3:46 PM, balaji.gandhi <ji...@gmail.com>wrote:

> Hi Team,
>
> I am trying to write a util which can parse a Lucene/Solr query and convert
> into an object representation to add more clauses to the query.
>
> Eg.
> Input: (name:John AND name:Doe)
> Output: ((firstName:John OR lastName:John) AND (firstName:John OR
> lastName:John))
>
> I tried org.apache.lucene.queryparser.classic.QueryParser to parse the
> query
> and iterate over the terms. But this doesn't give me the boolean operators
> and boosting. Tried to use
> org.apache.lucene.queryparser.surround.parser.QueryParser and
> org.apache.lucene.queryparser.surround.query.SrndQuery. I didn't see any
> API
> to manipulate the query.
>
> What would be the best way to do this?
>
> Thanks,
> Balaji
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Parsing-a-Lucene-Solr-query-and-adding-more-clauses-tp4033973.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>