You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by rhys J <rh...@gmail.com> on 2019/11/14 17:49:01 UTC

using gt and lt in a query

I am trying to duplicate this line from a db query:

(debt.orig_princ_amt > 0 AND debt.princ_paid > 0 AND debt.orig_princ_amt >
debt.princ_paid)

I have the following, but it returns no results:

http://localhost:8983/solr/debt/select?q=orig_princ_amt
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt>: 0 TO
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO> *
AND
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND>
princ_paid:0
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND%20princ_paid%3A%20%200>
TO
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND%20princ_paid%3A%20%200%20TO>
*
AND
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND%20princ_paid%3A%20%200%20TO%20*%20AND>
gt(orig_princ_amt
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND%20princ_paid%3A%20%200%20TO%20*%20AND%20gt(%20orig_princ_amt>,
princ_paid)


I should have 1075459 results, but I get 0.

Thanks,

Rhys

Re: using gt and lt in a query

Posted by rhys J <rh...@gmail.com>.
On Thu, Nov 14, 2019 at 1:28 PM Erick Erickson <er...@gmail.com>
wrote:

> You might be able to make this work with function queries….
>
>
>
I managed to decipher something along the lines of this:

http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt: 0 TO
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO> *
AND
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND>
princ_paid:0
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND%20princ_paid%3A%20%200>
TO
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND%20princ_paid%3A%20%200%20TO>
*&
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND%20princ_paid%3A%20%200%20TO%20*%20AND>fq={!frange
l=0}if( gt(orig_princ_amt
<http://10.40.10.14:8983/solr/debt/select?q=orig_princ_amt%3A%200%20TO%20*%20AND%20princ_paid%3A%20%200%20TO%20*%20AND%20gt(%20orig_princ_amt>,
princ_paid),1, 0 )

but it's still not giving me the entire results that the database gives. So
I'm not sure what I am missing?

Thanks,

Rhys

Re: using gt and lt in a query

Posted by Erick Erickson <er...@gmail.com>.
You might be able to make this work with function queries….

Best,
Erick

> On Nov 14, 2019, at 1:26 PM, Shawn Heisey <ap...@elyograg.org> wrote:
> 
> On 11/14/2019 11:09 AM, rhys J wrote:
>> But I'm not doing a range, I'm doing a query on whether one field is
>> greater than another field. Or am I missing something here?
> 
> I am unaware of any way to do that with simple query syntax.  Sometimes there is capability that I do not know about, though.
> 
> Solr is not designed for that kind of query.  It's something that databases do quite well, if the database design is correct.
> 
> Thanks,
> Shawn


Re: using gt and lt in a query

Posted by Shawn Heisey <ap...@elyograg.org>.
On 11/14/2019 11:09 AM, rhys J wrote:
> But I'm not doing a range, I'm doing a query on whether one field is
> greater than another field. Or am I missing something here?

I am unaware of any way to do that with simple query syntax.  Sometimes 
there is capability that I do not know about, though.

Solr is not designed for that kind of query.  It's something that 
databases do quite well, if the database design is correct.

Thanks,
Shawn

Re: using gt and lt in a query

Posted by rhys J <rh...@gmail.com>.
> Range queries are done with brackets and/or braces.  A square bracket
> indicates that the range should include the precise value mentioned, and
> a curly brace indicates that the range should exclude the precise value
> mentioned.
>
>
> https://lucene.apache.org/solr/guide/8_2/the-standard-query-parser.html#TheStandardQueryParser-RangeSearches
>
>
But I'm not doing a range, I'm doing a query on whether one field is
greater than another field. Or am I missing something here?

Thanks,

Rhys

Re: using gt and lt in a query

Posted by Shawn Heisey <ap...@elyograg.org>.
On 11/14/2019 10:49 AM, rhys J wrote:
> I am trying to duplicate this line from a db query:
> 
> (debt.orig_princ_amt > 0 AND debt.princ_paid > 0 AND debt.orig_princ_amt >
> debt.princ_paid)
> 
> I have the following, but it returns no results:

Range queries are done with brackets and/or braces.  A square bracket 
indicates that the range should include the precise value mentioned, and 
a curly brace indicates that the range should exclude the precise value 
mentioned.

https://lucene.apache.org/solr/guide/8_2/the-standard-query-parser.html#TheStandardQueryParser-RangeSearches

Thanks,
Shawn