Re: Queries not supported by Lucene Query Parser syntax
Yes, you are always limited by the query parser syntax, but of course you can always write your own query parser as well. There is an open issue for an XML-based query parser that would give you greater control. but... it's not committed yet: https://issues.apache.org/jira/browse/SOLR-839 -- Jack Krupansky On Thu, Jan 1, 2015 at 4:08 AM, Leonid Bolshinsky leonid...@gmail.com wrote: Hello, Are we always limited by the query parser syntax when passing a query string to Solr? What about the query elements which are not supported by the syntax? For example, BooleanQuery.setMinimumNumberShouldMatch(n) is translated by BooleanQuery.toString() into ~n. But this is not a valid query syntax. So how can we express this via query syntax in Solr? And more general question: Given a Lucene Query object which was built programatically by a legacy code (which is using Lucene and not Solr), is there any way to translate it into Solr query (which must be a string). As Query.toString() doesn't have to be a valid Lucene query syntax, does it mean that the Solr query string must to be manually translated from the Lucene query object? Is there any utility that performs this job? And, again, what about queries not supported by the query syntax, like CustomScoreQuery, PayloadTermQuery etc.? Are we always limited in Solr by the query parser syntax? Thanks, Leonid
Re: Queries not supported by Lucene Query Parser syntax
Hi Leonid, Have you had a look at edismax query parser[1]? Isn't that any use to your requirement? I am not sure whether it is something that you are looking for. But the question seemed to be having a query related to that. [1] http://wiki.apache.org/solr/ExtendedDisMax#Query_Syntax On Thu, Jan 1, 2015 at 2:38 PM, Leonid Bolshinsky leonid...@gmail.com wrote: Hello, Are we always limited by the query parser syntax when passing a query string to Solr? What about the query elements which are not supported by the syntax? For example, BooleanQuery.setMinimumNumberShouldMatch(n) is translated by BooleanQuery.toString() into ~n. But this is not a valid query syntax. So how can we express this via query syntax in Solr? And more general question: Given a Lucene Query object which was built programatically by a legacy code (which is using Lucene and not Solr), is there any way to translate it into Solr query (which must be a string). As Query.toString() doesn't have to be a valid Lucene query syntax, does it mean that the Solr query string must to be manually translated from the Lucene query object? Is there any utility that performs this job? And, again, what about queries not supported by the query syntax, like CustomScoreQuery, PayloadTermQuery etc.? Are we always limited in Solr by the query parser syntax? Thanks, Leonid
Re: Queries not supported by Lucene Query Parser syntax
Hi Lenoid, Here is another un-committed parser : https://issues.apache.org/jira/browse/LUCENE-5205 Ahmet On Thursday, January 1, 2015 5:59 PM, Roman Chyla roman.ch...@gmail.com wrote: Hi Leonid, I didn't look into solr qparser for a long time, but I think you should be able to combine different query parsers in one query. Look at the SolrQueryParser code, maybe now you can specify custom query parser for every clause (?), st like: foo AND {!lucene}bar I dont know, but worth exploring There is an another implementation of a query language, for which I know it allows to combine different query parsers in one (cause I wrote it), there the query goes this way: edismax(dog cat AND lucene((foo AND bar)~3)) meaning: use edismax to build the main query, but let lucene query parser build the 3rd clause - the nested 'for and bar' (parsers are expressed as function operators, so you can use any query parser there exist in SOLR) it is here, https://issues.apache.org/jira/browse/LUCENE-5014, but that was not reviewed/integrated either So no, you are not always limited by the query parser - you can combine them (in more or less limited fashion). But yes, the query parsers limit the expressiveness of your query language, but not what can be searched (they will all produce Query object). Best, roman On Thu, Jan 1, 2015 at 10:15 AM, Jack Krupansky jack.krupan...@gmail.com wrote: Yes, you are always limited by the query parser syntax, but of course you can always write your own query parser as well. There is an open issue for an XML-based query parser that would give you greater control. but... it's not committed yet: https://issues.apache.org/jira/browse/SOLR-839 -- Jack Krupansky On Thu, Jan 1, 2015 at 4:08 AM, Leonid Bolshinsky leonid...@gmail.com wrote: Hello, Are we always limited by the query parser syntax when passing a query string to Solr? What about the query elements which are not supported by the syntax? For example, BooleanQuery.setMinimumNumberShouldMatch(n) is translated by BooleanQuery.toString() into ~n. But this is not a valid query syntax. So how can we express this via query syntax in Solr? And more general question: Given a Lucene Query object which was built programatically by a legacy code (which is using Lucene and not Solr), is there any way to translate it into Solr query (which must be a string). As Query.toString() doesn't have to be a valid Lucene query syntax, does it mean that the Solr query string must to be manually translated from the Lucene query object? Is there any utility that performs this job? And, again, what about queries not supported by the query syntax, like CustomScoreQuery, PayloadTermQuery etc.? Are we always limited in Solr by the query parser syntax? Thanks, Leonid
Re: Queries not supported by Lucene Query Parser syntax
Hi Leonid, I didn't look into solr qparser for a long time, but I think you should be able to combine different query parsers in one query. Look at the SolrQueryParser code, maybe now you can specify custom query parser for every clause (?), st like: foo AND {!lucene}bar I dont know, but worth exploring There is an another implementation of a query language, for which I know it allows to combine different query parsers in one (cause I wrote it), there the query goes this way: edismax(dog cat AND lucene((foo AND bar)~3)) meaning: use edismax to build the main query, but let lucene query parser build the 3rd clause - the nested 'for and bar' (parsers are expressed as function operators, so you can use any query parser there exist in SOLR) it is here, https://issues.apache.org/jira/browse/LUCENE-5014, but that was not reviewed/integrated either So no, you are not always limited by the query parser - you can combine them (in more or less limited fashion). But yes, the query parsers limit the expressiveness of your query language, but not what can be searched (they will all produce Query object). Best, roman On Thu, Jan 1, 2015 at 10:15 AM, Jack Krupansky jack.krupan...@gmail.com wrote: Yes, you are always limited by the query parser syntax, but of course you can always write your own query parser as well. There is an open issue for an XML-based query parser that would give you greater control. but... it's not committed yet: https://issues.apache.org/jira/browse/SOLR-839 -- Jack Krupansky On Thu, Jan 1, 2015 at 4:08 AM, Leonid Bolshinsky leonid...@gmail.com wrote: Hello, Are we always limited by the query parser syntax when passing a query string to Solr? What about the query elements which are not supported by the syntax? For example, BooleanQuery.setMinimumNumberShouldMatch(n) is translated by BooleanQuery.toString() into ~n. But this is not a valid query syntax. So how can we express this via query syntax in Solr? And more general question: Given a Lucene Query object which was built programatically by a legacy code (which is using Lucene and not Solr), is there any way to translate it into Solr query (which must be a string). As Query.toString() doesn't have to be a valid Lucene query syntax, does it mean that the Solr query string must to be manually translated from the Lucene query object? Is there any utility that performs this job? And, again, what about queries not supported by the query syntax, like CustomScoreQuery, PayloadTermQuery etc.? Are we always limited in Solr by the query parser syntax? Thanks, Leonid
Re: Queries not supported by Lucene Query Parser syntax
Hello Leonid, Yep. This problem exists and makes hard the migration from Lucene to Solr. You might be interested in Parboiled http://www.youtube.com/watch?v=DXiRYfFGHJE The simplest way to solve it is to serialize Lucene Query instance into parameter or request body. Unfortunately, Query is not Serializable, but it's possible to do this with non-invasive serializers like XStream. Then, QParserPlugin can read this param or a body and deserialize Lucene query instance. Have a good hack! On Thu, Jan 1, 2015 at 12:08 PM, Leonid Bolshinsky leonid...@gmail.com wrote: Hello, Are we always limited by the query parser syntax when passing a query string to Solr? What about the query elements which are not supported by the syntax? For example, BooleanQuery.setMinimumNumberShouldMatch(n) is translated by BooleanQuery.toString() into ~n. But this is not a valid query syntax. So how can we express this via query syntax in Solr? And more general question: Given a Lucene Query object which was built programatically by a legacy code (which is using Lucene and not Solr), is there any way to translate it into Solr query (which must be a string). As Query.toString() doesn't have to be a valid Lucene query syntax, does it mean that the Solr query string must to be manually translated from the Lucene query object? Is there any utility that performs this job? And, again, what about queries not supported by the query syntax, like CustomScoreQuery, PayloadTermQuery etc.? Are we always limited in Solr by the query parser syntax? Thanks, Leonid -- Sincerely yours Mikhail Khludnev Principal Engineer, Grid Dynamics http://www.griddynamics.com mkhlud...@griddynamics.com