# Range search query with term

**URL:** <https://discuss.elastic.co/t/range-search-query-with-term/150949>\
**Category:** Elasticsearch\
**Created:** [October 3, 2018, 11:56pm UTC](https://discuss.elastic.co/t/range-search-query-with-term/150949 "2018-10-03T23:56:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![albeniz71](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@albeniz71](https://discuss.elastic.co/u/albeniz71)\
**Post date:** [October 3, 2018, 11:56pm UTC](https://discuss.elastic.co/t/range-search-query-with-term/150949/1 "2018-10-03T23:56:43Z")

</div>

Hi

Below is my range with aggregation search query. It gives me an error but runs well if I remove the "term" sentence.

GET /esi\_elb\_log-\*/\_search  
{  
"size" : 0,  
"query" : {  
"constant\_score" : {  
"filter" : {  
**"term" : { "service\_name" : "AUTH"},**  
"range" : {  
"@timestamp" : {  
"gt" : "now-2h"  
}  
}  
}  
}  
},  
"aggs": {  
"my\_date\_histo" : {  
"date\_histogram" : {  
"field" : "@timestamp",  
"interval" : "1m"  
},  
"aggs":{  
"the\_movavg" : {  
"moving\_avg" : {  
"buckets\_path": "\_count" ,  
"window" : 30,  
"model" : "simple"  
}  
}  
}  
}  
}  
}

# result

{  
"error": {  
"root\_cause": [  
{  
"type": "parsing\_exception",  
"reason": "[term] malformed query, expected [END\_OBJECT] but found [FIELD\_NAME]",  
"line": 7,  
"col": 17  
}  
],  
"type": "parsing\_exception",  
"reason": "[term] malformed query, expected [END\_OBJECT] but found [FIELD\_NAME]",  
"line": 7,  
"col": 17  
},  
"status": 400  
}

But I can't find any syntax error on it.

Thanks.

---

<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:** [October 31, 2018, 11:56pm UTC](https://discuss.elastic.co/t/range-search-query-with-term/150949/2 "2018-10-31T23:56:46Z")

</div>

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