# Date comparisons in update api script fields

**URL:** https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139
**Category:** Elasticsearch
**Created:** [March 27, 2012, 4:43am UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139 "2012-03-27T04:43:45Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![rusty1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rusty1](https://discuss.elastic.co/u/rusty1)
#### Post date: [March 27, 2012, 4:43am UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/1 "2012-03-27T04:43:45Z")

</div>

I have a question about the update api, I am able to update fields  
that are integers already, but wanted to be able to do a date  
comparison like so: "script" : "now - 5s \<= ctx.\_source.5sects ?  
ctx.\_source.5seccnt += count : ctx.\_source.5sects=now" , es doen't  
accept this, but wondering if it will accept any other type of date  
arithmetic in the script?  
ctx.\_source.5sects is a date field and already mapped before inserting  
any data

Is it possible to do this kind of comparison? do I just have the  
syntax wrong?

Here is the error on 0.19 rc3  
{"error":"ElasticSearchIllegalArgumentException[failed to execute  
script]; nested: PropertyAccessException[[Error: unresolvable property  
or identifier: now]\n[Near : {... now - 5s \<= ctx.\_source.5sects ....}]  
\n ^\n[Line: 1, Column: 1]]; ","status":400}

Here is the curl call:  
curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update](http://localhost:9200/mystats1/stats1/1/_update)' -d '{  
"script" : [ "now - 5sec \< = ctx.\_source.5sects ? ctx.\_source.  
5seccnt += count : ctx.\_source.5sects=now",  
"ctx.\_source.1mincnt += count",  
"ctx.\_source.10mincnt += count",  
"ctx.\_source.1hrcnt += count",  
"ctx.\_source.1daycnt += count"

```
            ],
"params" : {
    "count" : 1
}

```

}'

works fine except for when I try to add the date arithmetic part of  
it.

Any help appeciated,

Thanks,  
Rusty

ps. great product, just getting started but love it already.

---

<div class="post-metadata">

### Author: ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)
#### Post date: [March 27, 2012, 5:43pm UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/2 "2012-03-27T17:43:35Z")

</div>

First, you can't pass several strings to the script parameter. You can (in  
mvel, which is the default scripting used) separate each by ";" within a  
single script. Also, try and replace now with System.currentTimeInMillis,  
see if it helps.

On Tue, Mar 27, 2012 at 6:43 AM, rusty [rwickell@gmail.com](mailto:rwickell@gmail.com) wrote:

> I have a question about the update api, I am able to update fields  
> that are integers already, but wanted to be able to do a date  
> comparison like so: "script" : "now - 5s \<= ctx.\_source.5sects ?  
> ctx.\_source.5seccnt += count : ctx.\_source.5sects=now" , es doen't  
> accept this, but wondering if it will accept any other type of date  
> arithmetic in the script?  
> ctx.\_source.5sects is a date field and already mapped before inserting  
> any data
> 
> Is it possible to do this kind of comparison? do I just have the  
> syntax wrong?
> 
> Here is the error on 0.19 rc3  
> {"error":"ElasticSearchIllegalArgumentException[failed to execute  
> script]; nested: PropertyAccessException[[Error: unresolvable property  
> or identifier: now]\n[Near : {... now - 5s \<= ctx.\_source.5sects ....}]  
> \n ^\n[Line: 1, Column: 1]]; ","status":400}
> 
> Here is the curl call:  
> curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update](http://localhost:9200/mystats1/stats1/1/_update)' -d '{  
> "script" : [ "now - 5sec \< = ctx.\_source.5sects ? ctx.\_source.  
> 5seccnt += count : ctx.\_source.5sects=now",  
> "ctx.\_source.1mincnt += count",  
> "ctx.\_source.10mincnt += count",  
> "ctx.\_source.1hrcnt += count",  
> "ctx.\_source.1daycnt += count"
> 
> ```
> ],
> 
> ```
> 
> "params" : {  
> "count" : 1  
> }  
> }'
> 
> works fine except for when I try to add the date arithmetic part of  
> it.
> 
> Any help appeciated,
> 
> Thanks,  
> Rusty
> 
> ps. great product, just getting started but love it already.

---

<div class="post-metadata">

### Author: ![rusty1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rusty1](https://discuss.elastic.co/u/rusty1)
#### Post date: [March 28, 2012, 3:10pm UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/3 "2012-03-28T15:10:55Z")

</div>

System.currentTimeInMillis didn't work for me. I was able to just use  
a string as a parameter and pass in the current time. It works so far  
except for one hitch  
maybe you can help me with:

In the case where the first statement is true (ct.\_source.5sects \>  
current) See below for current object as well.  
In the case of it being true is doesn't execute the rest of the  
commands seperaated by ;, but if it is false it will  
execute the all after the initial conditional. Is there a way to  
specify that the following statement after the conditional are not  
attached to the conditional statement?

curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update](http://localhost:9200/mystats1/stats1/1/_update)' -d '{  
"script" : "ctx.\_source.5sects \> current ? ctx.\_source.5seccnt +=  
count : ctx.\_source.5sects=current;ctx.\_source.1mincnt += count;  
ctx.\_source.10mincnt  
+= count;ctx.\_source.1hrcnt += count;ctx.\_source.1daycnt += count"  
,  
"params" : {  
"count" : 1,  
"current" : "2012-03-28T00:00:00"  
}  
}'

{"5sects":"2012-03-26T16:00:00","5seccnt":  
8,"1mints":"2012-03-26T16:00:00","1mincnt":  
12,"10mints":"2012-03-26T16:00:00","10mincnt":  
13,"1hrts":"2012-03-26T16:00:00","1hrcnt":  
19,"1dayts":"2012-03-26T00:00:00","1daycnt":  
25,"blacklisted":"false","blacklistexpire":"2032-01-01T00:00:00"}

Thanks for the input,  
Rusty

On Mar 27, 10:43 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> First, you can't pass several strings to the script parameter. You can (in  
> mvel, which is the default scripting used) separate each by ";" within a  
> single script. Also, try and replace now with System.currentTimeInMillis,  
> see if it helps.
> 
> On Tue, Mar 27, 2012 at 6:43 AM, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> 
> > I have a question about the update api, I am able to update fields  
> > that are integers already, but wanted to be able to do a date  
> > comparison like so: "script" : "now - 5s \<= ctx.\_source.5sects ?  
> > ctx.\_source.5seccnt += count : ctx.\_source.5sects=now" , es doen't  
> > accept this, but wondering if it will accept any other type of date  
> > arithmetic in the script?  
> > ctx.\_source.5sects is a date field and already mapped before inserting  
> > any data
> 
> > Is it possible to do this kind of comparison? do I just have the  
> > syntax wrong?
> 
> > Here is the error on 0.19 rc3  
> > {"error":"ElasticSearchIllegalArgumentException[failed to execute  
> > script]; nested: PropertyAccessException[[Error: unresolvable property  
> > or identifier: now]\n[Near : {... now - 5s \<= ctx.\_source.5sects ....}]  
> > \n ^\n[Line: 1, Column: 1]]; ","status":400}
> 
> > Here is the curl call:  
> > curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update'-d](http://localhost:9200/mystats1/stats1/1/_update'-d) '{  
> > "script" : [ "now - 5sec \< = ctx.\_source.5sects ? ctx.\_source.  
> > 5seccnt += count : ctx.\_source.5sects=now",  
> > "ctx.\_source.1mincnt += count",  
> > "ctx.\_source.10mincnt += count",  
> > "ctx.\_source.1hrcnt += count",  
> > "ctx.\_source.1daycnt += count"
> 
> > ```
> > ],
> > 
> > ```
> > 
> > "params" : {  
> > "count" : 1  
> > }  
> > }'
> 
> > works fine except for when I try to add the date arithmetic part of  
> > it.
> 
> > Any help appeciated,
> 
> > Thanks,  
> > Rusty
> 
> > ps. great product, just getting started but love it already.

---

<div class="post-metadata">

### Author: ![rusty1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rusty1](https://discuss.elastic.co/u/rusty1)
#### Post date: [March 28, 2012, 3:53pm UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/4 "2012-03-28T15:53:08Z")

</div>

Nevermind, I fixed it. I checked the syntax and I can just use the  
normal if{} else {} syntax to fix this.  
Works fine now, thanks for the help.

-Rusty

On Mar 28, 8:10 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:

> System.currentTimeInMillis didn't work for me. I was able to just use  
> a string as a parameter and pass in the current time. It works so far  
> except for one hitch  
> maybe you can help me with:
> 
> In the case where the first statement is true (ct.\_source.5sects \>  
> current) See below for current object as well.  
> In the case of it being true is doesn't execute the rest of the  
> commands seperaated by ;, but if it is false it will  
> execute the all after the initial conditional. Is there a way to  
> specify that the following statement after the conditional are not  
> attached to the conditional statement?
> 
> curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update'-d](http://localhost:9200/mystats1/stats1/1/_update'-d) '{  
> "script" : "ctx.\_source.5sects \> current ? ctx.\_source.5seccnt +=  
> count : ctx.\_source.5sects=current;ctx.\_source.1mincnt += count;  
> ctx.\_source.10mincnt  
> += count;ctx.\_source.1hrcnt += count;ctx.\_source.1daycnt += count"  
> ,  
> "params" : {  
> "count" : 1,  
> "current" : "2012-03-28T00:00:00"  
> }
> 
> }'
> 
> {"5sects":"2012-03-26T16:00:00","5seccnt":  
> 8,"1mints":"2012-03-26T16:00:00","1mincnt":  
> 12,"10mints":"2012-03-26T16:00:00","10mincnt":  
> 13,"1hrts":"2012-03-26T16:00:00","1hrcnt":  
> 19,"1dayts":"2012-03-26T00:00:00","1daycnt":  
> 25,"blacklisted":"false","blacklistexpire":"2032-01-01T00:00:00"}
> 
> Thanks for the input,  
> Rusty
> 
> On Mar 27, 10:43 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > First, you can't pass several strings to the script parameter. You can (in  
> > mvel, which is the default scripting used) separate each by ";" within a  
> > single script. Also, try and replace now with System.currentTimeInMillis,  
> > see if it helps.
> 
> > On Tue, Mar 27, 2012 at 6:43 AM, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> > 
> > > I have a question about the update api, I am able to update fields  
> > > that are integers already, but wanted to be able to do a date  
> > > comparison like so: "script" : "now - 5s \<= ctx.\_source.5sects ?  
> > > ctx.\_source.5seccnt += count : ctx.\_source.5sects=now" , es doen't  
> > > accept this, but wondering if it will accept any other type of date  
> > > arithmetic in the script?  
> > > ctx.\_source.5sects is a date field and already mapped before inserting  
> > > any data
> 
> > > Is it possible to do this kind of comparison? do I just have the  
> > > syntax wrong?
> 
> > > Here is the error on 0.19 rc3  
> > > {"error":"ElasticSearchIllegalArgumentException[failed to execute  
> > > script]; nested: PropertyAccessException[[Error: unresolvable property  
> > > or identifier: now]\n[Near : {... now - 5s \<= ctx.\_source.5sects ....}]  
> > > \n ^\n[Line: 1, Column: 1]]; ","status":400}
> 
> > > Here is the curl call:  
> > > curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > "script" : [ "now - 5sec \< = ctx.\_source.5sects ? ctx.\_source.  
> > > 5seccnt += count : ctx.\_source.5sects=now",  
> > > "ctx.\_source.1mincnt += count",  
> > > "ctx.\_source.10mincnt += count",  
> > > "ctx.\_source.1hrcnt += count",  
> > > "ctx.\_source.1daycnt += count"
> 
> > > ```
> > > ],
> > > 
> > > ```
> > > 
> > > "params" : {  
> > > "count" : 1  
> > > }  
> > > }'
> 
> > > works fine except for when I try to add the date arithmetic part of  
> > > it.
> 
> > > Any help appeciated,
> 
> > > Thanks,  
> > > Rusty
> 
> > > ps. great product, just getting started but love it already.

---

<div class="post-metadata">

### Author: ![rusty1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rusty1](https://discuss.elastic.co/u/rusty1)
#### Post date: [March 28, 2012, 4:18pm UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/5 "2012-03-28T16:18:16Z")

</div>

On a related note to this , I wanted to be able to call the update api  
and a realtime get on the same object in one  
call. I have used the multiget for getting multiple objects as well as  
a multisearch to get several search results at once  
but wondering if there is a way to pass both an update call and a get  
call in one request?  
The object has no analyzable fields in the mapping on purpose since I  
will never search the contents, only be grabbing the source  
after using the update api call. Any way to put these two calls  
together in one request? update call (listed in thread above), get  
call for same object in the update call  
Will this pose any issue for the server having to search through  
transaction log a lot for objects just updated? will the updates  
always show ?, assuming they will since  
the realtime get should show all prior updates to their source,  
correct?

-Rusty

Thanks again, really enjoying the software. Have a long history with  
mysql but this project I am currently doing uses alot of text search  
and this product really made sense for it.

On Mar 28, 8:53 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:

> Nevermind, I fixed it. I checked the syntax and I can just use the  
> normal if{} else {} syntax to fix this.  
> Works fine now, thanks for the help.
> 
> -Rusty
> 
> On Mar 28, 8:10 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> 
> > System.currentTimeInMillis didn't work for me. I was able to just use  
> > a string as a parameter and pass in the current time. It works so far  
> > except for one hitch  
> > maybe you can help me with:
> 
> > In the case where the first statement is true (ct.\_source.5sects \>  
> > current) See below for current object as well.  
> > In the case of it being true is doesn't execute the rest of the  
> > commands seperaated by ;, but if it is false it will  
> > execute the all after the initial conditional. Is there a way to  
> > specify that the following statement after the conditional are not  
> > attached to the conditional statement?
> 
> > curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > "script" : "ctx.\_source.5sects \> current ? ctx.\_source.5seccnt +=  
> > count : ctx.\_source.5sects=current;ctx.\_source.1mincnt += count;  
> > ctx.\_source.10mincnt  
> > += count;ctx.\_source.1hrcnt += count;ctx.\_source.1daycnt += count"  
> > ,  
> > "params" : {  
> > "count" : 1,  
> > "current" : "2012-03-28T00:00:00"  
> > }
> 
> > }'
> 
> > {"5sects":"2012-03-26T16:00:00","5seccnt":  
> > 8,"1mints":"2012-03-26T16:00:00","1mincnt":  
> > 12,"10mints":"2012-03-26T16:00:00","10mincnt":  
> > 13,"1hrts":"2012-03-26T16:00:00","1hrcnt":  
> > 19,"1dayts":"2012-03-26T00:00:00","1daycnt":  
> > 25,"blacklisted":"false","blacklistexpire":"2032-01-01T00:00:00"}
> 
> > Thanks for the input,  
> > Rusty
> 
> > On Mar 27, 10:43 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > > First, you can't pass several strings to the script parameter. You can (in  
> > > mvel, which is the default scripting used) separate each by ";" within a  
> > > single script. Also, try and replace now with System.currentTimeInMillis,  
> > > see if it helps.
> 
> > > On Tue, Mar 27, 2012 at 6:43 AM, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> > > 
> > > > I have a question about the update api, I am able to update fields  
> > > > that are integers already, but wanted to be able to do a date  
> > > > comparison like so: "script" : "now - 5s \<= ctx.\_source.5sects ?  
> > > > ctx.\_source.5seccnt += count : ctx.\_source.5sects=now" , es doen't  
> > > > accept this, but wondering if it will accept any other type of date  
> > > > arithmetic in the script?  
> > > > ctx.\_source.5sects is a date field and already mapped before inserting  
> > > > any data
> 
> > > > Is it possible to do this kind of comparison? do I just have the  
> > > > syntax wrong?
> 
> > > > Here is the error on 0.19 rc3  
> > > > {"error":"ElasticSearchIllegalArgumentException[failed to execute  
> > > > script]; nested: PropertyAccessException[[Error: unresolvable property  
> > > > or identifier: now]\n[Near : {... now - 5s \<= ctx.\_source.5sects ....}]  
> > > > \n ^\n[Line: 1, Column: 1]]; ","status":400}
> 
> > > > Here is the curl call:  
> > > > curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > > "script" : [ "now - 5sec \< = ctx.\_source.5sects ? ctx.\_source.  
> > > > 5seccnt += count : ctx.\_source.5sects=now",  
> > > > "ctx.\_source.1mincnt += count",  
> > > > "ctx.\_source.10mincnt += count",  
> > > > "ctx.\_source.1hrcnt += count",  
> > > > "ctx.\_source.1daycnt += count"
> 
> > > > ```
> > > > ],
> > > > 
> > > > ```
> > > > 
> > > > "params" : {  
> > > > "count" : 1  
> > > > }  
> > > > }'
> 
> > > > works fine except for when I try to add the date arithmetic part of  
> > > > it.
> 
> > > > Any help appeciated,
> 
> > > > Thanks,  
> > > > Rusty
> 
> > > > ps. great product, just getting started but love it already.

---

<div class="post-metadata">

### Author: ![rusty1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rusty1](https://discuss.elastic.co/u/rusty1)
#### Post date: [March 28, 2012, 4:22pm UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/6 "2012-03-28T16:22:02Z")

</div>

Just thinking, how difficult would it be to add an option to the  
update api call to return the source after the update in the return  
json? maybe this already exists, but haven't seen it.

Thanks,  
Rusty

On Mar 28, 9:18 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:

> On a related note to this , I wanted to be able to call the update api  
> and a realtime get on the same object in one  
> call. I have used the multiget for getting multiple objects as well as  
> a multisearch to get several search results at once  
> but wondering if there is a way to pass both an update call and a get  
> call in one request?  
> The object has no analyzable fields in the mapping on purpose since I  
> will never search the contents, only be grabbing the source  
> after using the update api call. Any way to put these two calls  
> together in one request? update call (listed in thread above), get  
> call for same object in the update call  
> Will this pose any issue for the server having to search through  
> transaction log a lot for objects just updated? will the updates  
> always show ?, assuming they will since  
> the realtime get should show all prior updates to their source,  
> correct?
> 
> -Rusty
> 
> Thanks again, really enjoying the software. Have a long history with  
> mysql but this project I am currently doing uses alot of text search  
> and this product really made sense for it.
> 
> On Mar 28, 8:53 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> 
> > Nevermind, I fixed it. I checked the syntax and I can just use the  
> > normal if{} else {} syntax to fix this.  
> > Works fine now, thanks for the help.
> 
> > -Rusty
> 
> > On Mar 28, 8:10 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> 
> > > System.currentTimeInMillis didn't work for me. I was able to just use  
> > > a string as a parameter and pass in the current time. It works so far  
> > > except for one hitch  
> > > maybe you can help me with:
> 
> > > In the case where the first statement is true (ct.\_source.5sects \>  
> > > current) See below for current object as well.  
> > > In the case of it being true is doesn't execute the rest of the  
> > > commands seperaated by ;, but if it is false it will  
> > > execute the all after the initial conditional. Is there a way to  
> > > specify that the following statement after the conditional are not  
> > > attached to the conditional statement?
> 
> > > curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > "script" : "ctx.\_source.5sects \> current ? ctx.\_source.5seccnt +=  
> > > count : ctx.\_source.5sects=current;ctx.\_source.1mincnt += count;  
> > > ctx.\_source.10mincnt  
> > > += count;ctx.\_source.1hrcnt += count;ctx.\_source.1daycnt += count"  
> > > ,  
> > > "params" : {  
> > > "count" : 1,  
> > > "current" : "2012-03-28T00:00:00"  
> > > }
> 
> > > }'
> 
> > > {"5sects":"2012-03-26T16:00:00","5seccnt":  
> > > 8,"1mints":"2012-03-26T16:00:00","1mincnt":  
> > > 12,"10mints":"2012-03-26T16:00:00","10mincnt":  
> > > 13,"1hrts":"2012-03-26T16:00:00","1hrcnt":  
> > > 19,"1dayts":"2012-03-26T00:00:00","1daycnt":  
> > > 25,"blacklisted":"false","blacklistexpire":"2032-01-01T00:00:00"}
> 
> > > Thanks for the input,  
> > > Rusty
> 
> > > On Mar 27, 10:43 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > > > First, you can't pass several strings to the script parameter. You can (in  
> > > > mvel, which is the default scripting used) separate each by ";" within a  
> > > > single script. Also, try and replace now with System.currentTimeInMillis,  
> > > > see if it helps.
> 
> > > > On Tue, Mar 27, 2012 at 6:43 AM, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> > > > 
> > > > > I have a question about the update api, I am able to update fields  
> > > > > that are integers already, but wanted to be able to do a date  
> > > > > comparison like so: "script" : "now - 5s \<= ctx.\_source.5sects ?  
> > > > > ctx.\_source.5seccnt += count : ctx.\_source.5sects=now" , es doen't  
> > > > > accept this, but wondering if it will accept any other type of date  
> > > > > arithmetic in the script?  
> > > > > ctx.\_source.5sects is a date field and already mapped before inserting  
> > > > > any data
> 
> > > > > Is it possible to do this kind of comparison? do I just have the  
> > > > > syntax wrong?
> 
> > > > > Here is the error on 0.19 rc3  
> > > > > {"error":"ElasticSearchIllegalArgumentException[failed to execute  
> > > > > script]; nested: PropertyAccessException[[Error: unresolvable property  
> > > > > or identifier: now]\n[Near : {... now - 5s \<= ctx.\_source.5sects ....}]  
> > > > > \n ^\n[Line: 1, Column: 1]]; ","status":400}
> 
> > > > > Here is the curl call:  
> > > > > curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > > > "script" : [ "now - 5sec \< = ctx.\_source.5sects ? ctx.\_source.  
> > > > > 5seccnt += count : ctx.\_source.5sects=now",  
> > > > > "ctx.\_source.1mincnt += count",  
> > > > > "ctx.\_source.10mincnt += count",  
> > > > > "ctx.\_source.1hrcnt += count",  
> > > > > "ctx.\_source.1daycnt += count"
> 
> > > > > ```
> > > > > ],
> > > > > 
> > > > > ```
> > > > > 
> > > > > "params" : {  
> > > > > "count" : 1  
> > > > > }  
> > > > > }'
> 
> > > > > works fine except for when I try to add the date arithmetic part of  
> > > > > it.
> 
> > > > > Any help appeciated,
> 
> > > > > Thanks,  
> > > > > Rusty
> 
> > > > > ps. great product, just getting started but love it already.

---

<div class="post-metadata">

### Author: ![Benjamin\_Deveze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_deveze/32/1577_2.png) [@Benjamin\_Deveze](https://discuss.elastic.co/u/Benjamin_Deveze)
#### Post date: [March 29, 2012, 12:26pm UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/7 "2012-03-29T12:26:00Z")

</div>

Hey Rusty.

It would be useful, I have created an issue for it  
[add return script option to the update API · Issue #1822 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1822).

Expect it to be implemented soon.

On Wednesday, March 28, 2012 6:22:02 PM UTC+2, rusty wrote:

> Just thinking, how difficult would it be to add an option to the  
> update api call to return the source after the update in the return  
> json? maybe this already exists, but haven't seen it.
> 
> Thanks,  
> Rusty
> 
> On Mar 28, 9:18 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> 
> > On a related note to this , I wanted to be able to call the update api  
> > and a realtime get on the same object in one  
> > call. I have used the multiget for getting multiple objects as well as  
> > a multisearch to get several search results at once  
> > but wondering if there is a way to pass both an update call and a get  
> > call in one request?  
> > The object has no analyzable fields in the mapping on purpose since I  
> > will never search the contents, only be grabbing the source  
> > after using the update api call. Any way to put these two calls  
> > together in one request? update call (listed in thread above), get  
> > call for same object in the update call  
> > Will this pose any issue for the server having to search through  
> > transaction log a lot for objects just updated? will the updates  
> > always show ?, assuming they will since  
> > the realtime get should show all prior updates to their source,  
> > correct?
> > 
> > -Rusty
> > 
> > Thanks again, really enjoying the software. Have a long history with  
> > mysql but this project I am currently doing uses alot of text search  
> > and this product really made sense for it.
> > 
> > On Mar 28, 8:53 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> > 
> > > Nevermind, I fixed it. I checked the syntax and I can just use the  
> > > normal if{} else {} syntax to fix this.  
> > > Works fine now, thanks for the help.
> > 
> > > -Rusty
> > 
> > > On Mar 28, 8:10 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> > 
> > > > System.currentTimeInMillis didn't work for me. I was able to just  
> > > > use  
> > > > a string as a parameter and pass in the current time. It works so  
> > > > far  
> > > > except for one hitch  
> > > > maybe you can help me with:
> > 
> > > > In the case where the first statement is true (ct.\_source.5sects \>  
> > > > current) See below for current object as well.  
> > > > In the case of it being true is doesn't execute the rest of the  
> > > > commands seperaated by ;, but if it is false it will  
> > > > execute the all after the initial conditional. Is there a way to  
> > > > specify that the following statement after the conditional are not  
> > > > attached to the conditional statement?
> > 
> > > > curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > > "script" : "ctx.\_source.5sects \> current ? ctx.\_source.5seccnt  
> > > > +=  
> > > > count : ctx.\_source.5sects=current;ctx.\_source.1mincnt += count;  
> > > > ctx.\_source.10mincnt  
> > > > += count;ctx.\_source.1hrcnt += count;ctx.\_source.1daycnt += count"  
> > > > ,  
> > > > "params" : {  
> > > > "count" : 1,  
> > > > "current" : "2012-03-28T00:00:00"  
> > > > }
> > 
> > > > }'
> > 
> > > > {"5sects":"2012-03-26T16:00:00","5seccnt":  
> > > > 8,"1mints":"2012-03-26T16:00:00","1mincnt":  
> > > > 12,"10mints":"2012-03-26T16:00:00","10mincnt":  
> > > > 13,"1hrts":"2012-03-26T16:00:00","1hrcnt":  
> > > > 19,"1dayts":"2012-03-26T00:00:00","1daycnt":  
> > > > 25,"blacklisted":"false","blacklistexpire":"2032-01-01T00:00:00"}
> > 
> > > > Thanks for the input,  
> > > > Rusty
> > 
> > > > On Mar 27, 10:43 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > > > First, you can't pass several strings to the script parameter. You  
> > > > > can (in  
> > > > > mvel, which is the default scripting used) separate each by ";"  
> > > > > within a  
> > > > > single script. Also, try and replace now with  
> > > > > System.currentTimeInMillis,  
> > > > > see if it helps.
> > 
> > > > > On Tue, Mar 27, 2012 at 6:43 AM, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com)  
> > > > > wrote:
> > > > > 
> > > > > > I have a question about the update api, I am able to update  
> > > > > > fields  
> > > > > > that are integers already, but wanted to be able to do a date  
> > > > > > comparison like so: "script" : "now - 5s \<= ctx.\_source.5sects  
> > > > > > ?  
> > > > > > ctx.\_source.5seccnt += count : ctx.\_source.5sects=now" , es  
> > > > > > doen't  
> > > > > > accept this, but wondering if it will accept any other type of  
> > > > > > date  
> > > > > > arithmetic in the script?  
> > > > > > ctx.\_source.5sects is a date field and already mapped before  
> > > > > > inserting  
> > > > > > any data
> > 
> > > > > > Is it possible to do this kind of comparison? do I just have the  
> > > > > > syntax wrong?
> > 
> > > > > > Here is the error on 0.19 rc3  
> > > > > > {"error":"ElasticSearchIllegalArgumentException[failed to  
> > > > > > execute  
> > > > > > script]; nested: PropertyAccessException[[Error: unresolvable  
> > > > > > property  
> > > > > > or identifier: now]\n[Near : {... now - 5s \<= ctx.\_source.5sects  
> > > > > > ....}]  
> > > > > > \n ^\n[Line: 1, Column: 1]]; ","status":400}
> > 
> > > > > > Here is the curl call:  
> > > > > > curl -XPOST '  
> > > > > > [http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > > > > "script" : [ "now - 5sec \< = ctx.\_source.5sects ?  
> > > > > > ctx.\_source.  
> > > > > > 5seccnt += count : ctx.\_source.5sects=now",  
> > > > > > "ctx.\_source.1mincnt += count",  
> > > > > > "ctx.\_source.10mincnt += count",  
> > > > > > "ctx.\_source.1hrcnt += count",  
> > > > > > "ctx.\_source.1daycnt += count"
> > 
> > > > > > ```
> > > > > > ], 
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > "params" : {  
> > > > > > "count" : 1  
> > > > > > }  
> > > > > > }'
> > 
> > > > > > works fine except for when I try to add the date arithmetic part  
> > > > > > of  
> > > > > > it.
> > 
> > > > > > Any help appeciated,
> > 
> > > > > > Thanks,  
> > > > > > Rusty
> > 
> > > > > > ps. great product, just getting started but love it already.

---

<div class="post-metadata">

### Author: ![rusty1](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rusty1](https://discuss.elastic.co/u/rusty1)
#### Post date: [March 29, 2012, 2:39pm UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/8 "2012-03-29T14:39:40Z")

</div>

Great! Thank you 🙂

On Mar 29, 5:26 am, Benjamin Devèze [benjamin.dev...@gmail.com](mailto:benjamin.dev...@gmail.com) wrote:

> Hey Rusty.
> 
> It would be useful, I have created an issue for ithttps://github.com/elasticsearch/elasticsearch/issues/1822.
> 
> Expect it to be implemented soon.
> 
> On Wednesday, March 28, 2012 6:22:02 PM UTC+2, rusty wrote:
> 
> > Just thinking, how difficult would it be to add an option to the  
> > update api call to return the source after the update in the return  
> > json? maybe this already exists, but haven't seen it.
> 
> > Thanks,  
> > Rusty
> 
> > On Mar 28, 9:18 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> > 
> > > On a related note to this , I wanted to be able to call the update api  
> > > and a realtime get on the same object in one  
> > > call. I have used the multiget for getting multiple objects as well as  
> > > a multisearch to get several search results at once  
> > > but wondering if there is a way to pass both an update call and a get  
> > > call in one request?  
> > > The object has no analyzable fields in the mapping on purpose since I  
> > > will never search the contents, only be grabbing the source  
> > > after using the update api call. Any way to put these two calls  
> > > together in one request? update call (listed in thread above), get  
> > > call for same object in the update call  
> > > Will this pose any issue for the server having to search through  
> > > transaction log a lot for objects just updated? will the updates  
> > > always show ?, assuming they will since  
> > > the realtime get should show all prior updates to their source,  
> > > correct?
> 
> > > -Rusty
> 
> > > Thanks again, really enjoying the software. Have a long history with  
> > > mysql but this project I am currently doing uses alot of text search  
> > > and this product really made sense for it.
> 
> > > On Mar 28, 8:53 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> 
> > > > Nevermind, I fixed it. I checked the syntax and I can just use the  
> > > > normal if{} else {} syntax to fix this.  
> > > > Works fine now, thanks for the help.
> 
> > > > -Rusty
> 
> > > > On Mar 28, 8:10 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> 
> > > > > System.currentTimeInMillis didn't work for me. I was able to just  
> > > > > use  
> > > > > a string as a parameter and pass in the current time. It works so  
> > > > > far  
> > > > > except for one hitch  
> > > > > maybe you can help me with:
> 
> > > > > In the case where the first statement is true (ct.\_source.5sects \>  
> > > > > current) See below for current object as well.  
> > > > > In the case of it being true is doesn't execute the rest of the  
> > > > > commands seperaated by ;, but if it is false it will  
> > > > > execute the all after the initial conditional. Is there a way to  
> > > > > specify that the following statement after the conditional are not  
> > > > > attached to the conditional statement?
> 
> > > > > curl -XPOST '[http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > > > "script" : "ctx.\_source.5sects \> current ? ctx.\_source.5seccnt  
> > > > > +=  
> > > > > count : ctx.\_source.5sects=current;ctx.\_source.1mincnt += count;  
> > > > > ctx.\_source.10mincnt  
> > > > > += count;ctx.\_source.1hrcnt += count;ctx.\_source.1daycnt += count"  
> > > > > ,  
> > > > > "params" : {  
> > > > > "count" : 1,  
> > > > > "current" : "2012-03-28T00:00:00"  
> > > > > }
> 
> > > > > }'
> 
> > > > > {"5sects":"2012-03-26T16:00:00","5seccnt":  
> > > > > 8,"1mints":"2012-03-26T16:00:00","1mincnt":  
> > > > > 12,"10mints":"2012-03-26T16:00:00","10mincnt":  
> > > > > 13,"1hrts":"2012-03-26T16:00:00","1hrcnt":  
> > > > > 19,"1dayts":"2012-03-26T00:00:00","1daycnt":  
> > > > > 25,"blacklisted":"false","blacklistexpire":"2032-01-01T00:00:00"}
> 
> > > > > Thanks for the input,  
> > > > > Rusty
> 
> > > > > On Mar 27, 10:43 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > > > > > First, you can't pass several strings to the script parameter. You  
> > > > > > can (in  
> > > > > > mvel, which is the default scripting used) separate each by ";"  
> > > > > > within a  
> > > > > > single script. Also, try and replace now with  
> > > > > > System.currentTimeInMillis,  
> > > > > > see if it helps.
> 
> > > > > > On Tue, Mar 27, 2012 at 6:43 AM, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com)  
> > > > > > wrote:
> > > > > > 
> > > > > > > I have a question about the update api, I am able to update  
> > > > > > > fields  
> > > > > > > that are integers already, but wanted to be able to do a date  
> > > > > > > comparison like so: "script" : "now - 5s \<= ctx.\_source.5sects  
> > > > > > > ?  
> > > > > > > ctx.\_source.5seccnt += count : ctx.\_source.5sects=now" , es  
> > > > > > > doen't  
> > > > > > > accept this, but wondering if it will accept any other type of  
> > > > > > > date  
> > > > > > > arithmetic in the script?  
> > > > > > > ctx.\_source.5sects is a date field and already mapped before  
> > > > > > > inserting  
> > > > > > > any data
> 
> > > > > > > Is it possible to do this kind of comparison? do I just have the  
> > > > > > > syntax wrong?
> 
> > > > > > > Here is the error on 0.19 rc3  
> > > > > > > {"error":"ElasticSearchIllegalArgumentException[failed to  
> > > > > > > execute  
> > > > > > > script]; nested: PropertyAccessException[[Error: unresolvable  
> > > > > > > property  
> > > > > > > or identifier: now]\n[Near : {... now - 5s \<= ctx.\_source.5sects  
> > > > > > > ....}]  
> > > > > > > \n ^\n[Line: 1, Column: 1]]; ","status":400}
> 
> > > > > > > Here is the curl call:  
> > > > > > > curl -XPOST '  
> > > > > > > [http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > > > > > "script" : [ "now - 5sec \< = ctx.\_source.5sects ?  
> > > > > > > ctx.\_source.  
> > > > > > > 5seccnt += count : ctx.\_source.5sects=now",  
> > > > > > > "ctx.\_source.1mincnt += count",  
> > > > > > > "ctx.\_source.10mincnt += count",  
> > > > > > > "ctx.\_source.1hrcnt += count",  
> > > > > > > "ctx.\_source.1daycnt += count"
> 
> > > > > > > ```
> > > > > > > ],
> > > > > > > 
> > > > > > > ```
> > > > > > > 
> > > > > > > "params" : {  
> > > > > > > "count" : 1  
> > > > > > > }  
> > > > > > > }'
> 
> > > > > > > works fine except for when I try to add the date arithmetic part  
> > > > > > > of  
> > > > > > > it.
> 
> > > > > > > Any help appeciated,
> 
> > > > > > > Thanks,  
> > > > > > > Rusty
> 
> > > > > > > ps. great product, just getting started but love it already.

---

<div class="post-metadata">

### Author: ![Benjamin\_Deveze](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benjamin_deveze/32/1577_2.png) [@Benjamin\_Deveze](https://discuss.elastic.co/u/Benjamin_Deveze)
#### Post date: [April 3, 2012, 12:32pm UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/9 "2012-04-03T12:32:15Z")

</div>

Ok a patch has been pushed in master and the feature will be available in  
next released version.

Have a look here for more details

> <https://github.com/elastic/elasticsearch/issues/1838>
>
> Allow to specify fields in the update request, returning the fields out of hte u…pdated doc. \`\_source\` can be used as a field, resulting in returning the full doc. the results in under \`get\` element, and has similar structure to the \`get\` response (with \`\_source\`, if requested, and \`fields\` elements).

On Thursday, March 29, 2012 4:39:40 PM UTC+2, rusty wrote:

> Great! Thank you 🙂
> 
> On Mar 29, 5:26 am, Benjamin Devèze [benjamin.dev...@gmail.com](mailto:benjamin.dev...@gmail.com) wrote:
> 
> > Hey Rusty.
> > 
> > It would be useful, I have created an issue for ithttps://  
> > [add return script option to the update API · Issue #1822 · elastic/elasticsearch · GitHub](http://github.com/elasticsearch/elasticsearch/issues/1822).
> > 
> > Expect it to be implemented soon.
> > 
> > On Wednesday, March 28, 2012 6:22:02 PM UTC+2, rusty wrote:
> > 
> > > Just thinking, how difficult would it be to add an option to the  
> > > update api call to return the source after the update in the return  
> > > json? maybe this already exists, but haven't seen it.
> > 
> > > Thanks,  
> > > Rusty
> > 
> > > On Mar 28, 9:18 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> > > 
> > > > On a related note to this , I wanted to be able to call the update  
> > > > api  
> > > > and a realtime get on the same object in one  
> > > > call. I have used the multiget for getting multiple objects as well  
> > > > as  
> > > > a multisearch to get several search results at once  
> > > > but wondering if there is a way to pass both an update call and a  
> > > > get  
> > > > call in one request?  
> > > > The object has no analyzable fields in the mapping on purpose since  
> > > > I  
> > > > will never search the contents, only be grabbing the source  
> > > > after using the update api call. Any way to put these two calls  
> > > > together in one request? update call (listed in thread above), get  
> > > > call for same object in the update call  
> > > > Will this pose any issue for the server having to search through  
> > > > transaction log a lot for objects just updated? will the updates  
> > > > always show ?, assuming they will since  
> > > > the realtime get should show all prior updates to their source,  
> > > > correct?
> > 
> > > > -Rusty
> > 
> > > > Thanks again, really enjoying the software. Have a long history with  
> > > > mysql but this project I am currently doing uses alot of text search  
> > > > and this product really made sense for it.
> > 
> > > > On Mar 28, 8:53 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> > 
> > > > > Nevermind, I fixed it. I checked the syntax and I can just use the  
> > > > > normal if{} else {} syntax to fix this.  
> > > > > Works fine now, thanks for the help.
> > 
> > > > > -Rusty
> > 
> > > > > On Mar 28, 8:10 am, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com) wrote:
> > 
> > > > > > System.currentTimeInMillis didn't work for me. I was able to  
> > > > > > just  
> > > > > > use  
> > > > > > a string as a parameter and pass in the current time. It works  
> > > > > > so  
> > > > > > far  
> > > > > > except for one hitch  
> > > > > > maybe you can help me with:
> > 
> > > > > > In the case where the first statement is true (ct.\_source.5sects
> > 
> > > > > > current) See below for current object as well.  
> > > > > > In the case of it being true is doesn't execute the rest of the  
> > > > > > commands seperaated by ;, but if it is false it will  
> > > > > > execute the all after the initial conditional. Is there a way to  
> > > > > > specify that the following statement after the conditional are  
> > > > > > not  
> > > > > > attached to the conditional statement?
> > 
> > > > > > curl -XPOST '  
> > > > > > [http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > > > > "script" : "ctx.\_source.5sects \> current ?  
> > > > > > ctx.\_source.5seccnt  
> > > > > > +=  
> > > > > > count : ctx.\_source.5sects=current;ctx.\_source.1mincnt += count;  
> > > > > > ctx.\_source.10mincnt  
> > > > > > += count;ctx.\_source.1hrcnt += count;ctx.\_source.1daycnt +=  
> > > > > > count"  
> > > > > > ,  
> > > > > > "params" : {  
> > > > > > "count" : 1,  
> > > > > > "current" : "2012-03-28T00:00:00"  
> > > > > > }
> > 
> > > > > > }'
> > 
> > > > > > {"5sects":"2012-03-26T16:00:00","5seccnt":  
> > > > > > 8,"1mints":"2012-03-26T16:00:00","1mincnt":  
> > > > > > 12,"10mints":"2012-03-26T16:00:00","10mincnt":  
> > > > > > 13,"1hrts":"2012-03-26T16:00:00","1hrcnt":  
> > > > > > 19,"1dayts":"2012-03-26T00:00:00","1daycnt":
> 
> 25,"blacklisted":"false","blacklistexpire":"2032-01-01T00:00:00"}
> 
> > > > > > Thanks for the input,  
> > > > > > Rusty
> > 
> > > > > > On Mar 27, 10:43 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > > > > > First, you can't pass several strings to the script parameter.  
> > > > > > > You  
> > > > > > > can (in  
> > > > > > > mvel, which is the default scripting used) separate each by  
> > > > > > > ";"  
> > > > > > > within a  
> > > > > > > single script. Also, try and replace now with  
> > > > > > > System.currentTimeInMillis,  
> > > > > > > see if it helps.
> > 
> > > > > > > On Tue, Mar 27, 2012 at 6:43 AM, rusty [rwick...@gmail.com](mailto:rwick...@gmail.com)  
> > > > > > > wrote:
> > > > > > > 
> > > > > > > > I have a question about the update api, I am able to update  
> > > > > > > > fields  
> > > > > > > > that are integers already, but wanted to be able to do a  
> > > > > > > > date  
> > > > > > > > comparison like so: "script" : "now - 5s \<=  
> > > > > > > > ctx.\_source.5sects  
> > > > > > > > ?  
> > > > > > > > ctx.\_source.5seccnt += count : ctx.\_source.5sects=now" ,  
> > > > > > > > es  
> > > > > > > > doen't  
> > > > > > > > accept this, but wondering if it will accept any other type  
> > > > > > > > of  
> > > > > > > > date  
> > > > > > > > arithmetic in the script?  
> > > > > > > > ctx.\_source.5sects is a date field and already mapped before  
> > > > > > > > inserting  
> > > > > > > > any data
> > 
> > > > > > > > Is it possible to do this kind of comparison? do I just have  
> > > > > > > > the  
> > > > > > > > syntax wrong?
> > 
> > > > > > > > Here is the error on 0.19 rc3  
> > > > > > > > {"error":"ElasticSearchIllegalArgumentException[failed to  
> > > > > > > > execute  
> > > > > > > > script]; nested: PropertyAccessException[[Error:  
> > > > > > > > unresolvable  
> > > > > > > > property  
> > > > > > > > or identifier: now]\n[Near : {... now - 5s \<=  
> > > > > > > > ctx.\_source.5sects  
> > > > > > > > ....}]  
> > > > > > > > \n ^\n[Line: 1, Column: 1]]; ","status":400}
> > 
> > > > > > > > Here is the curl call:  
> > > > > > > > curl -XPOST '  
> > > > > > > > [http://localhost:9200/mystats1/stats1/1/\_update'-d'](http://localhost:9200/mystats1/stats1/1/_update'-d'){  
> > > > > > > > "script" : [ "now - 5sec \< = ctx.\_source.5sects ?  
> > > > > > > > ctx.\_source.  
> > > > > > > > 5seccnt += count : ctx.\_source.5sects=now",  
> > > > > > > > "ctx.\_source.1mincnt += count",  
> > > > > > > > "ctx.\_source.10mincnt += count",  
> > > > > > > > "ctx.\_source.1hrcnt += count",  
> > > > > > > > "ctx.\_source.1daycnt += count"
> > 
> > > > > > > > ```
> > > > > > > > ], 
> > > > > > > > 
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > "params" : {  
> > > > > > > > "count" : 1  
> > > > > > > > }  
> > > > > > > > }'
> > 
> > > > > > > > works fine except for when I try to add the date arithmetic  
> > > > > > > > part  
> > > > > > > > of  
> > > > > > > > it.
> > 
> > > > > > > > Any help appeciated,
> > 
> > > > > > > > Thanks,  
> > > > > > > > Rusty
> > 
> > > > > > > > ps. great product, just getting started but love it already.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 3:33am UTC](https://discuss.elastic.co/t/date-comparisons-in-update-api-script-fields/7139/10 "2017-07-06T03:33:55Z")

</div>


