Assuming these are numerics, use function queries I should think, see:
https://cwiki.apache.org/confluence/display/solr/Function+Queries#FunctionQueries-AvailableFunctions.
You'll see lt, gt, etc.

Best,
Erick

On Fri, Nov 4, 2016 at 11:23 PM, Prasanna S. Dhakephalkar
<prasann...@merajob.in> wrote:
> Hi John,
>
> I need to formulate a query where the both query variable are from document.
> Like get me all documents where var_1 >  var_2 (var_1 and var_2 both are in 
> document.)
>
> Thanks and Regards,
>
> Prasanna.
>
>
> -----Original Message-----
> From: John Bickerstaff [mailto:j...@johnbickerstaff.com]
> Sent: Wednesday, October 26, 2016 9:26 PM
> To: solr-user@lucene.apache.org
> Subject: Re: Query formulation help
>
> For what it's worth- you can do some complex stuff - including using document 
> fields as "variables" -- I did it on an Solr query endpoint (like
> /search) because I had stuff that was constant for every query.  The syntax 
> is challenging, but it can be done.
>
> I won't confuse the issue more unless you need something like that - let me 
> know if you do.
>
> On Wed, Oct 26, 2016 at 9:52 AM, Tom Evans <tevans...@googlemail.com> wrote:
>
>> On Wed, Oct 26, 2016 at 4:00 PM, Prasanna S. Dhakephalkar
>> <prasann...@merajob.in> wrote:
>> > Hi,
>> >
>> > Thanks for reply, I did
>> >
>> > "q": "cost:[20000 TO (20000+5000)]"
>> >
>> > Got
>> >
>> >   "error": {
>> >     "msg": "org.apache.solr.search.SyntaxError: Cannot parse
>> 'cost:[20000 to (20000+5000)]': Encountered \" <RANGE_GOOP> \"(20000+5000)
>> \"\" at line 1, column 18.\nWas expecting one of:\n    \"]\" ...\n    \"}\"
>> ...\n    ",
>> >   }
>> >
>> > I want solr to do the addition.
>> > I tried
>> > "q": "cost:[20000 TO (20000+5000)]"
>> > "q": "cost:[20000 TO sum(20000,5000)]"
>> >
>> > I has not worked. I am missing something. I donot know what. May be
>> > how
>> to invoke functions.
>> >
>> > Regards,
>> >
>> > Prasanna.
>>
>> Sorry, I was unclear - do the maths before constructing the query!
>>
>> You might be able to do this with function queries, but why bother? If
>> the number is fixed, then fix it in the query, if it varies then there
>> must be some code executing on your client that can be used to do a
>> simple addition.
>>
>> Cheers
>>
>> Tom
>>
>

Reply via email to