# Using a @timestamp field in elasticsearch-dsl-py

**URL:** <https://discuss.elastic.co/t/using-a-timestamp-field-in-elasticsearch-dsl-py/20364>\
**Category:** Elasticsearch\
**Created:** [October 21, 2014, 2:32pm UTC](https://discuss.elastic.co/t/using-a-timestamp-field-in-elasticsearch-dsl-py/20364 "2014-10-21T14:32:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antonio\_Augusto\_Sant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antonio_augusto_sant/32/82851_2.png) [@Antonio\_Augusto\_Sant](https://discuss.elastic.co/u/Antonio_Augusto_Sant)\
**Post date:** [October 21, 2014, 2:32pm UTC](https://discuss.elastic.co/t/using-a-timestamp-field-in-elasticsearch-dsl-py/20364/1 "2014-10-21T14:32:31Z")

</div>

Hi,

I'm trying to start using ES-DSL-PY to do some quick tests on my  
environment and I've faced one problem.  
Whats the correct way to use it in a range filter? I plain json the Syntax  
would be something like:

"range": {  
"@timestamp": {  
"from": 1413815328968,  
"to": 1413901728968  
}  
}

When I try to convert it to python I'd end with something like

F("range", @timestamp={"from":1413815328968, "to":1413901728968})

But the \*@timestamp \*is a wrong Python Syntax.  
Any recommendations on how to do it, while still using EDP syntax?

Thanks in advance.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/e10ca84b-c1b5-4ea6-9db6-004c5c5c6fb9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e10ca84b-c1b5-4ea6-9db6-004c5c5c6fb9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Honza\_Kral](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/honza_kral/32/876_2.png) [@Honza\_Kral](https://discuss.elastic.co/u/Honza_Kral)\
**Post date:** [October 21, 2014, 3:26pm UTC](https://discuss.elastic.co/t/using-a-timestamp-field-in-elasticsearch-dsl-py/20364/2 "2014-10-21T15:26:56Z")

</div>

Hi Antonio,  
you might dave to use:  
F("range", \*\*{'@timestamp': {"from":1413815328968, "to":1413901728968}})

or

F({"range": {@timestamp: {"from":1413815328968, "to":1413901728968}}})

both of these should work.

On Tue, Oct 21, 2014 at 4:32 PM, Antonio Augusto Santos  
[mkhaos7@gmail.com](mailto:mkhaos7@gmail.com) wrote:

> Hi,
> 
> I'm trying to start using ES-DSL-PY to do some quick tests on my environment  
> and I've faced one problem.  
> Whats the correct way to use it in a range filter? I plain json the Syntax  
> would be something like:
> 
> "range": {  
> "@timestamp": {  
> "from": 1413815328968,  
> "to": 1413901728968  
> }  
> }
> 
> When I try to convert it to python I'd end with something like
> 
> F("range", @timestamp={"from":1413815328968, "to":1413901728968})
> 
> But the @timestamp is a wrong Python Syntax.  
> Any recommendations on how to do it, while still using EDP syntax?
> 
> Thanks in advance.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/e10ca84b-c1b5-4ea6-9db6-004c5c5c6fb9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e10ca84b-c1b5-4ea6-9db6-004c5c5c6fb9%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CABfdDiqZftD8B-wOP6oOC0BHXNtkRrPineLyF%3DAZwDs%2BU41EQA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CABfdDiqZftD8B-wOP6oOC0BHXNtkRrPineLyF%3DAZwDs%2BU41EQA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Antonio\_Augusto\_Sant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antonio_augusto_sant/32/82851_2.png) [@Antonio\_Augusto\_Sant](https://discuss.elastic.co/u/Antonio_Augusto_Sant)\
**Post date:** [October 21, 2014, 4:46pm UTC](https://discuss.elastic.co/t/using-a-timestamp-field-in-elasticsearch-dsl-py/20364/3 "2014-10-21T16:46:28Z")

</div>

Thanks Honza, worked like a charm!

Just as a pointer to other people, your second code only worked when  
putting the @timestamp between quotes (you probably forgot it there).

Thanks.

On Tuesday, October 21, 2014 12:27:04 PM UTC-3, Honza Král wrote:

> Hi Antonio,  
> you might dave to use:  
> F("range", \*\*{'@timestamp': {"from":1413815328968, "to":1413901728968}})
> 
> or
> 
> F({"range": {@timestamp: {"from":1413815328968, "to":1413901728968}}})
> 
> both of these should work.
> 
> On Tue, Oct 21, 2014 at 4:32 PM, Antonio Augusto Santos  
> \<[mkh...@gmail.com](mailto:mkh...@gmail.com) \<javascript:\>\> wrote:
> 
> > Hi,
> > 
> > I'm trying to start using ES-DSL-PY to do some quick tests on my  
> > environment  
> > and I've faced one problem.  
> > Whats the correct way to use it in a range filter? I plain json the  
> > Syntax  
> > would be something like:
> > 
> > "range": {  
> > "@timestamp": {  
> > "from": 1413815328968,  
> > "to": 1413901728968  
> > }  
> > }
> > 
> > When I try to convert it to python I'd end with something like
> > 
> > F("range", @timestamp={"from":1413815328968, "to":1413901728968})
> > 
> > But the @timestamp is a wrong Python Syntax.  
> > Any recommendations on how to do it, while still using EDP syntax?
> > 
> > Thanks in advance.
> > 
> > --  
> > You received this message because you are subscribed to the Google  
> > Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send  
> > an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit
> 
> [https://groups.google.com/d/msgid/elasticsearch/e10ca84b-c1b5-4ea6-9db6-004c5c5c6fb9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e10ca84b-c1b5-4ea6-9db6-004c5c5c6fb9%40googlegroups.com).
> 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a81e568a-efa4-48e0-9f4c-b9b43fc92c47%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a81e568a-efa4-48e0-9f4c-b9b43fc92c47%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:54am UTC](https://discuss.elastic.co/t/using-a-timestamp-field-in-elasticsearch-dsl-py/20364/4 "2017-07-06T00:54:39Z")

</div>


