Re: Negative Date Query for Local Params in Solr
Thanks, David! Perhaps browsing the Solr sources may be a necessity at some point in time. :) SRK On Wednesday, September 21, 2016 9:08 AM, David Smileywrote: So that page referenced describes local-params, and describes the special "v" local-param. But first, see a list of all query parsers (which lists "field"): https://cwiki.apache.org/confluence/display/solr/Other+Parsers and https://cwiki.apache.org/confluence/display/solr/The+Standard+Query+Parser for the "lucene" one. The "op" param is rather unique... it's not defined by any query parser. A trick is done in which a custom field type (DateRangeField in this case) is able to inspect the local-params, and thus define and use params it needs. https://cwiki.apache.org/confluence/display/solr/Working+with+Dates "More DateRangeField Details" mentions "op". {!lucene df=dateRange op=Contains}... would also work. I don't know of any other local-param used in this way. On Tue, Sep 20, 2016 at 11:21 PM David Smiley wrote: > Personally I learned this by pouring over Solr's source code some time > ago. I suppose the only official reference to this stuff is: > > https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries > But that page doesn't address the implications for when the syntax is a > clause of a larger query instead of being the whole query (i.e. has "{!"... > but but not at the first char). > > On Tue, Sep 20, 2016 at 2:06 PM Sandeep Khanzode > wrote: > >> Wow. Simply awesome! >> Where can I read more about this? I am not sure whether I understand what >> is going on behind the scenes ... like which parser is invoked for !field, >> how can we know which all special local params exist, whether we should >> prefer edismax over others, when is the LuceneQParser invoked in other >> conditions, etc? Would appreciate if you could indicate some references to >> catch up. >> Thanks a lot ... SRK >> >> Show original message On Tuesday, September 20, 2016 5:54 PM, David >> Smiley wrote: >> >> >> OH! Ok the moment the query no longer starts with "{!", the query is >> parsed by defType (for 'q') and will default to lucene QParser. So then >> it >> appears we have a clause with a NOT operator. In this parsing mode, >> embedded "{!" terminates at the "}". This means you can't put the >> sub-query text after the "}", you instead need to put it in the special >> "v" >> local-param. e.g.: >> -{!field f=schedule op=Contains v='[2016-08-26T12:00:12Z TO >> 2016-08-26T15:00:12Z]'} >> >> On Tue, Sep 20, 2016 at 8:15 AM Sandeep Khanzode >> wrote: >> >> > This is what I get ... >> > { "responseHeader": { "status": 400, "QTime": 1, "params": { "q": >> > "-{!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO >> > 2016-08-26T15:00:12Z]", "indent": "true", "wt": "json", "_": >> > "1474373612202" } }, "error": { "msg": "Invalid Date in Date Math >> > String:'[2016-08-26T12:00:12Z'", "code": 400 }} >> > SRK >> > >> > On Tuesday, September 20, 2016 5:34 PM, David Smiley < >> > david.w.smi...@gmail.com> wrote: >> > >> > >> > It should, I think... what happens? Can you ascertain the nature of the >> > results? >> > ~ David >> > >> > On Tue, Sep 20, 2016 at 5:35 AM Sandeep Khanzode >> > wrote: >> > >> > > For Solr 6.1.0 >> > > This works .. -{!field f=schedule op=Intersects}2016-08-26T12:00:56Z >> > > >> > > This works .. {!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO >> > > 2016-08-26T15:00:12Z] >> > > >> > > >> > > Why does this not work?-{!field f=schedule >> > > op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z] >> > > SRK >> > >> > -- >> > Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker >> > LinkedIn: http://linkedin.com/in/davidwsmiley | Book: >> > http://www.solrenterprisesearchserver.com >> > >> > >> > >> >> -- >> Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker >> LinkedIn: http://linkedin.com/in/davidwsmiley | Book: >> http://www.solrenterprisesearchserver.com >> >> >> > > -- > Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker > LinkedIn: http://linkedin.com/in/davidwsmiley | Book: > http://www.solrenterprisesearchserver.com > -- Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker LinkedIn: http://linkedin.com/in/davidwsmiley | Book: http://www.solrenterprisesearchserver.com
Re: Negative Date Query for Local Params in Solr
So that page referenced describes local-params, and describes the special "v" local-param. But first, see a list of all query parsers (which lists "field"): https://cwiki.apache.org/confluence/display/solr/Other+Parsers and https://cwiki.apache.org/confluence/display/solr/The+Standard+Query+Parser for the "lucene" one. The "op" param is rather unique... it's not defined by any query parser. A trick is done in which a custom field type (DateRangeField in this case) is able to inspect the local-params, and thus define and use params it needs. https://cwiki.apache.org/confluence/display/solr/Working+with+Dates "More DateRangeField Details" mentions "op". {!lucene df=dateRange op=Contains}... would also work. I don't know of any other local-param used in this way. On Tue, Sep 20, 2016 at 11:21 PM David Smileywrote: > Personally I learned this by pouring over Solr's source code some time > ago. I suppose the only official reference to this stuff is: > > https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries > But that page doesn't address the implications for when the syntax is a > clause of a larger query instead of being the whole query (i.e. has "{!"... > but but not at the first char). > > On Tue, Sep 20, 2016 at 2:06 PM Sandeep Khanzode > wrote: > >> Wow. Simply awesome! >> Where can I read more about this? I am not sure whether I understand what >> is going on behind the scenes ... like which parser is invoked for !field, >> how can we know which all special local params exist, whether we should >> prefer edismax over others, when is the LuceneQParser invoked in other >> conditions, etc? Would appreciate if you could indicate some references to >> catch up. >> Thanks a lot ... SRK >> >> Show original message On Tuesday, September 20, 2016 5:54 PM, David >> Smiley wrote: >> >> >> OH! Ok the moment the query no longer starts with "{!", the query is >> parsed by defType (for 'q') and will default to lucene QParser. So then >> it >> appears we have a clause with a NOT operator. In this parsing mode, >> embedded "{!" terminates at the "}". This means you can't put the >> sub-query text after the "}", you instead need to put it in the special >> "v" >> local-param. e.g.: >> -{!field f=schedule op=Contains v='[2016-08-26T12:00:12Z TO >> 2016-08-26T15:00:12Z]'} >> >> On Tue, Sep 20, 2016 at 8:15 AM Sandeep Khanzode >> wrote: >> >> > This is what I get ... >> > { "responseHeader": { "status": 400, "QTime": 1, "params": { "q": >> > "-{!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO >> > 2016-08-26T15:00:12Z]", "indent": "true", "wt": "json", "_": >> > "1474373612202" } }, "error": { "msg": "Invalid Date in Date Math >> > String:'[2016-08-26T12:00:12Z'", "code": 400 }} >> > SRK >> > >> >On Tuesday, September 20, 2016 5:34 PM, David Smiley < >> > david.w.smi...@gmail.com> wrote: >> > >> > >> > It should, I think... what happens? Can you ascertain the nature of the >> > results? >> > ~ David >> > >> > On Tue, Sep 20, 2016 at 5:35 AM Sandeep Khanzode >> > wrote: >> > >> > > For Solr 6.1.0 >> > > This works .. -{!field f=schedule op=Intersects}2016-08-26T12:00:56Z >> > > >> > > This works .. {!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO >> > > 2016-08-26T15:00:12Z] >> > > >> > > >> > > Why does this not work?-{!field f=schedule >> > > op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z] >> > > SRK >> > >> > -- >> > Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker >> > LinkedIn: http://linkedin.com/in/davidwsmiley | Book: >> > http://www.solrenterprisesearchserver.com >> > >> > >> > >> >> -- >> Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker >> LinkedIn: http://linkedin.com/in/davidwsmiley | Book: >> http://www.solrenterprisesearchserver.com >> >> >> > > -- > Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker > LinkedIn: http://linkedin.com/in/davidwsmiley | Book: > http://www.solrenterprisesearchserver.com > -- Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker LinkedIn: http://linkedin.com/in/davidwsmiley | Book: http://www.solrenterprisesearchserver.com
Re: Negative Date Query for Local Params in Solr
Personally I learned this by pouring over Solr's source code some time ago. I suppose the only official reference to this stuff is: https://cwiki.apache.org/confluence/display/solr/Local+Parameters+in+Queries But that page doesn't address the implications for when the syntax is a clause of a larger query instead of being the whole query (i.e. has "{!"... but but not at the first char). On Tue, Sep 20, 2016 at 2:06 PM Sandeep Khanzodewrote: > Wow. Simply awesome! > Where can I read more about this? I am not sure whether I understand what > is going on behind the scenes ... like which parser is invoked for !field, > how can we know which all special local params exist, whether we should > prefer edismax over others, when is the LuceneQParser invoked in other > conditions, etc? Would appreciate if you could indicate some references to > catch up. > Thanks a lot ... SRK > > Show original message On Tuesday, September 20, 2016 5:54 PM, David > Smiley wrote: > > > OH! Ok the moment the query no longer starts with "{!", the query is > parsed by defType (for 'q') and will default to lucene QParser. So then it > appears we have a clause with a NOT operator. In this parsing mode, > embedded "{!" terminates at the "}". This means you can't put the > sub-query text after the "}", you instead need to put it in the special "v" > local-param. e.g.: > -{!field f=schedule op=Contains v='[2016-08-26T12:00:12Z TO > 2016-08-26T15:00:12Z]'} > > On Tue, Sep 20, 2016 at 8:15 AM Sandeep Khanzode > wrote: > > > This is what I get ... > > { "responseHeader": { "status": 400, "QTime": 1, "params": { "q": > > "-{!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO > > 2016-08-26T15:00:12Z]", "indent": "true", "wt": "json", "_": > > "1474373612202" } }, "error": { "msg": "Invalid Date in Date Math > > String:'[2016-08-26T12:00:12Z'", "code": 400 }} > > SRK > > > >On Tuesday, September 20, 2016 5:34 PM, David Smiley < > > david.w.smi...@gmail.com> wrote: > > > > > > It should, I think... what happens? Can you ascertain the nature of the > > results? > > ~ David > > > > On Tue, Sep 20, 2016 at 5:35 AM Sandeep Khanzode > > wrote: > > > > > For Solr 6.1.0 > > > This works .. -{!field f=schedule op=Intersects}2016-08-26T12:00:56Z > > > > > > This works .. {!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO > > > 2016-08-26T15:00:12Z] > > > > > > > > > Why does this not work?-{!field f=schedule > > > op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z] > > > SRK > > > > -- > > Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker > > LinkedIn: http://linkedin.com/in/davidwsmiley | Book: > > http://www.solrenterprisesearchserver.com > > > > > > > > -- > Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker > LinkedIn: http://linkedin.com/in/davidwsmiley | Book: > http://www.solrenterprisesearchserver.com > > > -- Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker LinkedIn: http://linkedin.com/in/davidwsmiley | Book: http://www.solrenterprisesearchserver.com
Re: Negative Date Query for Local Params in Solr
Wow. Simply awesome! Where can I read more about this? I am not sure whether I understand what is going on behind the scenes ... like which parser is invoked for !field, how can we know which all special local params exist, whether we should prefer edismax over others, when is the LuceneQParser invoked in other conditions, etc? Would appreciate if you could indicate some references to catch up. Thanks a lot ... SRK Show original message On Tuesday, September 20, 2016 5:54 PM, David Smileywrote: OH! Ok the moment the query no longer starts with "{!", the query is parsed by defType (for 'q') and will default to lucene QParser. So then it appears we have a clause with a NOT operator. In this parsing mode, embedded "{!" terminates at the "}". This means you can't put the sub-query text after the "}", you instead need to put it in the special "v" local-param. e.g.: -{!field f=schedule op=Contains v='[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z]'} On Tue, Sep 20, 2016 at 8:15 AM Sandeep Khanzode wrote: > This is what I get ... > { "responseHeader": { "status": 400, "QTime": 1, "params": { "q": > "-{!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO > 2016-08-26T15:00:12Z]", "indent": "true", "wt": "json", "_": > "1474373612202" } }, "error": { "msg": "Invalid Date in Date Math > String:'[2016-08-26T12:00:12Z'", "code": 400 }} > SRK > > On Tuesday, September 20, 2016 5:34 PM, David Smiley < > david.w.smi...@gmail.com> wrote: > > > It should, I think... what happens? Can you ascertain the nature of the > results? > ~ David > > On Tue, Sep 20, 2016 at 5:35 AM Sandeep Khanzode > wrote: > > > For Solr 6.1.0 > > This works .. -{!field f=schedule op=Intersects}2016-08-26T12:00:56Z > > > > This works .. {!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO > > 2016-08-26T15:00:12Z] > > > > > > Why does this not work?-{!field f=schedule > > op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z] > > SRK > > -- > Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker > LinkedIn: http://linkedin.com/in/davidwsmiley | Book: > http://www.solrenterprisesearchserver.com > > > -- Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker LinkedIn: http://linkedin.com/in/davidwsmiley | Book: http://www.solrenterprisesearchserver.com
Re: Negative Date Query for Local Params in Solr
This is what I get ... { "responseHeader": { "status": 400, "QTime": 1, "params": { "q": "-{!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z]", "indent": "true", "wt": "json", "_": "1474373612202" } }, "error": { "msg": "Invalid Date in Date Math String:'[2016-08-26T12:00:12Z'", "code": 400 }} SRK On Tuesday, September 20, 2016 5:34 PM, David Smileywrote: It should, I think... what happens? Can you ascertain the nature of the results? ~ David On Tue, Sep 20, 2016 at 5:35 AM Sandeep Khanzode wrote: > For Solr 6.1.0 > This works .. -{!field f=schedule op=Intersects}2016-08-26T12:00:56Z > > This works .. {!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO > 2016-08-26T15:00:12Z] > > > Why does this not work?-{!field f=schedule > op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z] > SRK -- Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker LinkedIn: http://linkedin.com/in/davidwsmiley | Book: http://www.solrenterprisesearchserver.com
Re: Negative Date Query for Local Params in Solr
OH! Ok the moment the query no longer starts with "{!", the query is parsed by defType (for 'q') and will default to lucene QParser. So then it appears we have a clause with a NOT operator. In this parsing mode, embedded "{!" terminates at the "}". This means you can't put the sub-query text after the "}", you instead need to put it in the special "v" local-param. e.g.: -{!field f=schedule op=Contains v='[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z]'} On Tue, Sep 20, 2016 at 8:15 AM Sandeep Khanzodewrote: > This is what I get ... > { "responseHeader": { "status": 400, "QTime": 1, "params": { "q": > "-{!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO > 2016-08-26T15:00:12Z]", "indent": "true", "wt": "json", "_": > "1474373612202" } }, "error": { "msg": "Invalid Date in Date Math > String:'[2016-08-26T12:00:12Z'", "code": 400 }} > SRK > > On Tuesday, September 20, 2016 5:34 PM, David Smiley < > david.w.smi...@gmail.com> wrote: > > > It should, I think... what happens? Can you ascertain the nature of the > results? > ~ David > > On Tue, Sep 20, 2016 at 5:35 AM Sandeep Khanzode > wrote: > > > For Solr 6.1.0 > > This works .. -{!field f=schedule op=Intersects}2016-08-26T12:00:56Z > > > > This works .. {!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO > > 2016-08-26T15:00:12Z] > > > > > > Why does this not work?-{!field f=schedule > > op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z] > > SRK > > -- > Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker > LinkedIn: http://linkedin.com/in/davidwsmiley | Book: > http://www.solrenterprisesearchserver.com > > > -- Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker LinkedIn: http://linkedin.com/in/davidwsmiley | Book: http://www.solrenterprisesearchserver.com
Re: Negative Date Query for Local Params in Solr
It should, I think... what happens? Can you ascertain the nature of the results? ~ David On Tue, Sep 20, 2016 at 5:35 AM Sandeep Khanzodewrote: > For Solr 6.1.0 > This works .. -{!field f=schedule op=Intersects}2016-08-26T12:00:56Z > > This works .. {!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO > 2016-08-26T15:00:12Z] > > > Why does this not work?-{!field f=schedule > op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z] > SRK -- Lucene/Solr Search Committer, Consultant, Developer, Author, Speaker LinkedIn: http://linkedin.com/in/davidwsmiley | Book: http://www.solrenterprisesearchserver.com
Negative Date Query for Local Params in Solr
For Solr 6.1.0 This works .. -{!field f=schedule op=Intersects}2016-08-26T12:00:56Z This works .. {!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z] Why does this not work?-{!field f=schedule op=Contains}[2016-08-26T12:00:12Z TO 2016-08-26T15:00:12Z] SRK