# Elasticsearch QueryStringBuilder using wildcards

**URL:** <https://discuss.elastic.co/t/elasticsearch-querystringbuilder-using-wildcards/107870>\
**Category:** Elasticsearch\
**Created:** [November 16, 2017, 6:40am UTC](https://discuss.elastic.co/t/elasticsearch-querystringbuilder-using-wildcards/107870 "2017-11-16T06:40:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ganapathy](https://avatars.discourse-cdn.com/v4/letter/g/bbe5ce/32.png) [@Ganapathy](https://discuss.elastic.co/u/Ganapathy)\
**Post date:** [November 16, 2017, 6:40am UTC](https://discuss.elastic.co/t/elasticsearch-querystringbuilder-using-wildcards/107870/1 "2017-11-16T06:40:49Z")

</div>

I am using elasticsearch2.3.2 in which I stumbled on the following use case where we are not getting the expected result while using QueryStringBuilder.  
Following is an example of what we did,

**1) Created an index with following settings**

curl -XPUT '[http://localhost:9200/test/](http://localhost:9200/test/)' -d '{  
"mappings": { 1: {"dynamic": "strict","properties": {"field": {"type": "string","index": "not\_analyzed","fielddata": {"format": "doc\_values"}}}}},  
"settings" : { "index" : { "number\_of\_shards" : 1,"number\_of\_replicas" : 1 } }  
}'

**2) Indexed a document**

curl -XPUT '[http://localhost:9200/test/1/1](http://localhost:9200/test/1/1)' -d '{ "field" : "(/sheet|)/published/(o|e)/(([0-9]{1,19})|([a-zA-Z0-9\.\_\*\-%]+))" }'

**3) Ran a search on the index**

curl -XGET '[http://localhost:9200/test/1/\_search](http://localhost:9200/test/1/_search)'?pretty -d '{  
"query": {  
"bool": {  
"must": [  
{  
"query\_string": {  
"query": " ((field:\(\/sheet|\)\/published\/\(o|e\)\/\(\(\[0\-9\]\{1,19\}\)|\(\[a\-z\*))"  
}  
}  
],  
"minimum\_should\_match": "1"  
}  
}  
}'

gives the following result

{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "test",  
"\_type" : "1",  
"\_id" : "1",  
"\_score" : 1.0,  
"_source" : {  
"field" : "(/sheet|)/published/(o|e)/(([0-9]{1,19})|([a-zA-Z0-9\._\*\-%]+))"  
}  
} ]  
}  
}

**4) While running another query**

curl -XGET '[http://localhost:9200/test/1/\_search](http://localhost:9200/test/1/_search)'?pretty -d '{  
"query": {  
"bool": {  
"must": [  
{  
"query\_string": {  
"query": " ((field:\(\/sheet|\)\/published\/\(o|e\)\/\(\(\[0\-9\]\{1,19\}\)|\(\[a\-zA\*))"  
}  
}  
],  
"minimum\_should\_match": "1"  
}  
}  
}'

gives no matched result

{  
"took" : 3,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 1,  
"successful" : 1,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}

Am I missing anything here?

---

<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:** [December 14, 2017, 6:53am UTC](https://discuss.elastic.co/t/elasticsearch-querystringbuilder-using-wildcards/107870/2 "2017-12-14T06:53:41Z")

</div>

Closed on December 14, 2017, 6:53am UTC

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