# Using wildcards in query\_string fields

**URL:** <https://discuss.elastic.co/t/using-wildcards-in-query-string-fields/17415>\
**Category:** Elasticsearch\
**Created:** [May 8, 2014, 6:19pm UTC](https://discuss.elastic.co/t/using-wildcards-in-query-string-fields/17415 "2014-05-08T18:19:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ltuhuru](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@ltuhuru](https://discuss.elastic.co/u/ltuhuru)\
**Post date:** [May 8, 2014, 6:19pm UTC](https://discuss.elastic.co/t/using-wildcards-in-query-string-fields/17415/1 "2014-05-08T18:19:04Z")

</div>

I'm a new user, so hopefully this is something really simple. I have two "message" objects in my index, "typeA" and "typeB", each of which has a "net" field. I'd like to be able to search for all objects whose net fields match a pattern.

If I specify the fields explicitly, the query returns the appropriate docs. If I use a wildcard in the fields for the query\_string, the query returns no hits. Clearly I don't understand something - can anyone point out what I'm missing?

curl -XPUT localhost:9200/nettest/message/typeA-1 -d '{  
"typeA" : {  
"net" : "NET11\_TEST"  
}  
}'

curl -XPUT localhost:9200/nettest/message/typeB-1 -d '{  
"typeB" : {  
"net" : "NET01\_TEST"  
}  
}'

This query returns both docs:  
curl -XGET localhost:9200/nettest/\_search?pretty=true -d '{  
"query" : {  
"query\_string" : {  
"fields" : ["[message.typeA.net](http://message.typeA.net)", "[message.typeB.net](http://message.typeB.net)"],  
"query" : "NET\*"  
}  
}  
}'

This query returns no docs:  
curl -XGET localhost:9200/nettest/\_search?pretty=true -d '{  
"query" : {  
"query\_string" : {  
"fields" : ["message._.net"],  
"query" : "NET_"  
}  
}  
}'

---

<div class="post-metadata">

**Author:** ![ltuhuru](https://avatars.discourse-cdn.com/v4/letter/l/87869e/32.png) [@ltuhuru](https://discuss.elastic.co/u/ltuhuru)\
**Post date:** [May 8, 2014, 7:02pm UTC](https://discuss.elastic.co/t/using-wildcards-in-query-string-fields/17415/2 "2014-05-08T19:02:01Z")

</div>

Found my problem. Get rid of the leading type "message" in the field path and wildcards in the fields work.

curl -XGET localhost:9200/nettest/\_search?pretty -d '{  
"query" : {  
"query\_string" : {  
"fields" : ["_.ne_"],  
"query" : "NET\*"  
}  
}  
}'

---

<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:** [July 6, 2017, 1:30am UTC](https://discuss.elastic.co/t/using-wildcards-in-query-string-fields/17415/3 "2017-07-06T01:30:42Z")

</div>


