# Lucene expression query in discover tab

**URL:** <https://discuss.elastic.co/t/lucene-expression-query-in-discover-tab/130632>\
**Category:** Kibana\
**Created:** [May 4, 2018, 1:00pm UTC](https://discuss.elastic.co/t/lucene-expression-query-in-discover-tab/130632 "2018-05-04T13:00:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![madou23](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@madou23](https://discuss.elastic.co/u/madou23)\
**Post date:** [May 4, 2018, 1:00pm UTC](https://discuss.elastic.co/t/lucene-expression-query-in-discover-tab/130632/1 "2018-05-04T13:00:33Z")

</div>

Hi all,  
I'm trying to use lucene expression to get docs that were indexed in a specific range of hours of each day from discover tab.  
I tried this query but it doesn't work  
`doc['@timestamp'].date.hourOfDay: [21 TO 23]`  
but I get this error  
`Failed to parse query [doc['@timestamp'].date.hourOfDay: [21 TO 23]] parse_exception: Encountered " "]" "] "" at line 1, column 16. Was expecting: "TO"`  
Is there any way to do it with only lucene expression query and not query dsl.

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [May 4, 2018, 7:51pm UTC](https://discuss.elastic.co/t/lucene-expression-query-in-discover-tab/130632/2 "2018-05-04T19:51:58Z")

</div>

You can't write scripts inline in the lucene query language. You'll need to create a [scripted field](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html) that represents the `hourOfDay`. Then you can create a filter on that field. It has to be a filter though, the query bar doesn't currently support scripted fields, but that's changing in 6.3 which is our next version.

---

<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:** [June 1, 2018, 8:05pm UTC](https://discuss.elastic.co/t/lucene-expression-query-in-discover-tab/130632/3 "2018-06-01T20:05:45Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
