# Term query for date type field doesn't work if query is list

**URL:** <https://discuss.elastic.co/t/term-query-for-date-type-field-doesnt-work-if-query-is-list/218140>\
**Category:** Elasticsearch\
**Created:** [February 6, 2020, 10:25am UTC](https://discuss.elastic.co/t/term-query-for-date-type-field-doesnt-work-if-query-is-list/218140 "2020-02-06T10:25:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tnarita](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tnarita/32/62180_2.png) [@tnarita](https://discuss.elastic.co/u/tnarita)\
**Post date:** [February 6, 2020, 10:25am UTC](https://discuss.elastic.co/t/term-query-for-date-type-field-doesnt-work-if-query-is-list/218140/1 "2020-02-06T10:25:53Z")

</div>

Hi,  
I inserted a data whose data type is "date".  
Then I tried to find the data by term query. If search query contains one value, it works but if search query contain a list of value, I get exception.  
If data type of inserted data is keyword, both case works well.

I would like to know whether this is expected behavior or not.  
Thank you in advance.  
======================Below query doesn't work====================  
"term" : {  
"sell\_date" : {  
"value" : [  
"2020-01-01",  
"2020-01-02"  
]  
}  
======================Below query works well====================  
"term" : {  
"sell\_date" : {  
"value" : "2020-01-01"  
}  
}

===============Exception message==================  
"type": "parse\_exception",  
"reason": "failed to parse date field ] with format [strict\_date\_optional\_time||epoch\_millis]: [failed to parse date field] with format [strict\_date\_optional\_time||epoch\_millis]]",

---

<div class="post-metadata">

**Author:** ![elk11](https://avatars.discourse-cdn.com/v4/letter/e/45deac/32.png) [@elk11](https://discuss.elastic.co/u/elk11)\
**Post date:** [February 6, 2020, 3:53pm UTC](https://discuss.elastic.co/t/term-query-for-date-type-field-doesnt-work-if-query-is-list/218140/2 "2020-02-06T15:53:46Z")

</div>

I think you should be using 'terms' instead of 'term' when passing list. [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html)

---

<div class="post-metadata">

**Author:** ![tnarita](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tnarita/32/62180_2.png) [@tnarita](https://discuss.elastic.co/u/tnarita)\
**Post date:** [February 27, 2020, 3:19am UTC](https://discuss.elastic.co/t/term-query-for-date-type-field-doesnt-work-if-query-is-list/218140/3 "2020-02-27T03:19:06Z")

</div>

Sorry for late reply. I tried terms instead of term then it worked. Thank you very much.  
But I feel error message needs to be improved.

---

<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:** [March 26, 2020, 3:19am UTC](https://discuss.elastic.co/t/term-query-for-date-type-field-doesnt-work-if-query-is-list/218140/4 "2020-03-26T03:19:06Z")

</div>

Closed on March 26, 2020, 3:19am UTC

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