# Query string query - including relation in range

**URL:** <https://discuss.elastic.co/t/query-string-query-including-relation-in-range/196222>\
**Category:** Elasticsearch\
**Created:** [August 22, 2019, 3:21am UTC](https://discuss.elastic.co/t/query-string-query-including-relation-in-range/196222 "2019-08-22T03:21:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![krish3](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@krish3](https://discuss.elastic.co/u/krish3)\
**Post date:** [August 22, 2019, 3:21am UTC](https://discuss.elastic.co/t/query-string-query-including-relation-in-range/196222/1 "2019-08-22T03:21:39Z")

</div>

I have an index with this mapping:

{  
"iprange\_index": {  
"mappings": {  
"properties": {  
"iplist": {  
"type": "ip\_range"  
}  
}  
}  
}  
}

Now I want to do the following query using query string query.  
{  
"query": {  
"range": {  
"iplist": {  
"gte": "12.168.1.0",  
"lte": "12.168.1.255",  
"relation":"contains"  
}  
}  
}  
}

Something like this:

{  
"query": {  
"query\_string": {  
"query": "iplist:[12.168.1.0 TO 12.168.1.255]"  
}  
}  
}

But I don't know how to incorporate "relation":"contains" in query string query above. Can we do this?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 22, 2019, 12:20pm UTC](https://discuss.elastic.co/t/query-string-query-including-relation-in-range/196222/2 "2019-08-22T12:20:01Z")

</div>

hey,

please take the time to properly format your code snippets. This forums supports markdown so please make use of that. Thanks!

You need to use a `range` query, as the query string query does not support specifying a relation.

---

<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:** [September 19, 2019, 12:28pm UTC](https://discuss.elastic.co/t/query-string-query-including-relation-in-range/196222/3 "2019-09-19T12:28:11Z")

</div>

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