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 Indika Tantrigoda <in...@gmail.com> on 2012/11/19 00:11:15 UTC

Date math query syntax

Hi All,

I am trying to use date math along with a filed
value. 1970-01-01T04:32:010Z+(_val_:prep_time)MINUTES is the date math
query I am using. prep_time is of type int. I am having trouble properly
formatting the string resulting in exceptions. I am guessing that I am not
properly formatting the query with quotes and/or parenthesis.

Thanks,
Indika

Re: Date math query syntax

Posted by Indika Tantrigoda <in...@gmail.com>.
Hi Jack,

Thanks for the response. Let me explain my question better.

I have a filter query to limit the query results,
start_time:[* TO 1970-01-01T10:55:002Z] AND end_time:[1970-01-01T10:55:002Z
TO *] AND session_time_range_available:true

and I also use the same query as a function query in fl using the
if(exists(query), x, y) where query is,
{!edismax}(start_time:[* TO 1970-01-01T10:55:002Z] AND
end_time:[1970-01-01T10:55:002Z TO *] AND session_time_range_available:true)

I need to extend the end_time range query based on the logic, similar to
end_time:[1970-01-01T10:55:002Z+30MINUTUES TO *]

How much I need to offset the end_time range is defined as an int type in
the schema. I was trying to use the field value query (_val_:field) to
retrive the end_time offset, resulting in the query being
1970-01-01T04:32:010Z+(_val_:**prep_time)MINUTES

However the query seems to have syntax errors. Or is it allowed to use the
_val_:field in such instances ?

As an extension I'll also have two offsets resulting in something similar
to
1970-01-01T04:32:010Z+(_val_:**prep_time)MINUTES+(_val_:extend_time)MINUTES

Thanks,
Indika

On 19 November 2012 09:17, Jack Krupansky <ja...@basetechnology.com> wrote:

> You can do numeric math in function queries, but not string operations,
> and there is no provision for doing string operations in a query using the
> result of an embedded function query.
>
> You haven't shown us a full query.
>
> Sounds like we have another candidate for "XY Problem". First you need to
> tell us what you are really trying to accomplish, THEN a solution can be
> pursued.
>
> Take a look at the "ms" function query for date calculations - which is
> separate from so-called "date-math" which is a constant offset from a base
> date literal value.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Indika Tantrigoda
> Sent: Sunday, November 18, 2012 3:11 PM
> To: solr-user@lucene.apache.org
> Subject: Date math query syntax
>
>
> Hi All,
>
> I am trying to use date math along with a filed
> value. 1970-01-01T04:32:010Z+(_val_:**prep_time)MINUTES is the date math
> query I am using. prep_time is of type int. I am having trouble properly
> formatting the string resulting in exceptions. I am guessing that I am not
> properly formatting the query with quotes and/or parenthesis.
>
> Thanks,
> Indika
>

Re: Date math query syntax

Posted by Jack Krupansky <ja...@basetechnology.com>.
You can do numeric math in function queries, but not string operations, and 
there is no provision for doing string operations in a query using the 
result of an embedded function query.

You haven't shown us a full query.

Sounds like we have another candidate for "XY Problem". First you need to 
tell us what you are really trying to accomplish, THEN a solution can be 
pursued.

Take a look at the "ms" function query for date calculations - which is 
separate from so-called "date-math" which is a constant offset from a base 
date literal value.

-- Jack Krupansky

-----Original Message----- 
From: Indika Tantrigoda
Sent: Sunday, November 18, 2012 3:11 PM
To: solr-user@lucene.apache.org
Subject: Date math query syntax

Hi All,

I am trying to use date math along with a filed
value. 1970-01-01T04:32:010Z+(_val_:prep_time)MINUTES is the date math
query I am using. prep_time is of type int. I am having trouble properly
formatting the string resulting in exceptions. I am guessing that I am not
properly formatting the query with quotes and/or parenthesis.

Thanks,
Indika