# Wildcard failed under query\_string

**URL:** <https://discuss.elastic.co/t/wildcard-failed-under-query-string/133781>\
**Category:** Elasticsearch\
**Created:** [May 30, 2018, 3:25am UTC](https://discuss.elastic.co/t/wildcard-failed-under-query-string/133781 "2018-05-30T03:25:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![qqdb75](https://avatars.discourse-cdn.com/v4/letter/q/a88e57/32.png) [@qqdb75](https://discuss.elastic.co/u/qqdb75)\
**Post date:** [May 30, 2018, 3:25am UTC](https://discuss.elastic.co/t/wildcard-failed-under-query-string/133781/1 "2018-05-30T03:25:13Z")

</div>

i want to query es like this:  
curl -H 'Content-Type: application/json' -XGET '[http://172.19.1.252:9200/logstash-apache\_access2018-05\*/\_search?pretty&ignore\_unavailable=true&size=0](http://172.19.1.252:9200/logstash-apache_access2018-05*/_search?pretty&ignore_unavailable=true&size=0)' -d '{  
"aggs": {  
"counts": {  
"terms": {  
"field": "geoip.ip",  
"size": 50  
}  
}  
},  
"query": {  
"bool": {  
"filter": {  
"bool": {  
"must": [  
{  
"range": {  
"@timestamp": {  
"gt": "2018-05-30T01:35:19.668263Z",  
"lte": "2018-05-30T01:36:09.599633Z"  
}  
}  
},  
{  
"query\_string": {  
"query": "_"  
}  
},  
{  
"query\_string": {  
"query": "NOT geoip.ip:1.2.3.4"  
}  
},  
{  
"query\_string": {  
"query": "NOT geoip.ip: a.b.c._"  
}  
}  
]  
}  
}  
}  
}  
}'  
what i want is to exclude a ip 1.2.3.4 and ip \_range from a.b.c.1 to a.b.c.254 in my information,when i query,i found the ip  
1.2.3.4 is not in my info any more,but the ips who is under a.b.c.\* is still stay in my info but it is not what i want.  
so,i want to learn how to write my query rules if using wildcard in "query": "NOT geoip.ip: a.b.c.\*"

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 30, 2018, 5:05am UTC](https://discuss.elastic.co/t/wildcard-failed-under-query-string/133781/2 "2018-05-30T05:05:35Z")

</div>

It mostly depends on the mapping you have.

Why not using a range query on a `ip` type field?

---

<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 27, 2018, 5:10am UTC](https://discuss.elastic.co/t/wildcard-failed-under-query-string/133781/3 "2018-06-27T05:10:06Z")

</div>

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