# Elasticsearch giving query\_shard\_exception for query\_string

**URL:** <https://discuss.elastic.co/t/elasticsearch-giving-query-shard-exception-for-query-string/268556>\
**Category:** Elasticsearch\
**Created:** [March 27, 2021, 10:43am UTC](https://discuss.elastic.co/t/elasticsearch-giving-query-shard-exception-for-query-string/268556 "2021-03-27T10:43:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![surajdalvi](https://avatars.discourse-cdn.com/v4/letter/s/85f322/32.png) [@surajdalvi](https://discuss.elastic.co/u/surajdalvi)\
**Post date:** [March 27, 2021, 10:43am UTC](https://discuss.elastic.co/t/elasticsearch-giving-query-shard-exception-for-query-string/268556/1 "2021-03-27T10:43:28Z")

</div>

I am storing URL in the elastic search and I making the following request to get a result for elastic search:

```
{
                        "query_string": {
                            "query": "*http://localhost:8000/v3/assets/dt1234/dt3335/605f068b5e124230eadea17a/my.png*",
                            "fields": ["url"],
                            "default_operator": "OR"
                        }
                    }

```

but elastic search giving Me the following error:

```
   {
"error": {
	"root_cause": [{
		"type": "query_shard_exception",
		"reason": "Failed to parse query [*http://localhost:8000/v3/assets/dt1234/dt3335/605f068b5e124230eadea17a/my.png*]",
		"index_uuid": "-061pFHDRvmeN_-FWT8ZEg",
		"index": "demo"
	}],
	"type": "search_phase_execution_exception",
	"reason": "all shards failed",
	"phase": "query",
	"grouped": true,
	"failed_shards": [{
		"shard": 0,
		"index": "demo",
		"node": "je7xKjGTTfWn1rKbuVBbhA",
		"reason": {
			"type": "query_shard_exception",
			"reason": "Failed to parse query [*http://localhost:8000/v3/assets/dt1234/dt3335/605f068b5e124230eadea17a/my.png*]",
			"index_uuid": "-061pFHDRvmeN_-FWT8ZEg",
			"index": "demo",
			"caused_by": {
				"type": "parse_exception",
				"reason": "Cannot parse '*http://localhost:8000/v3/assets/dt1234/dt3335/605f068b5e124230eadea17a/my.png*': Encountered \" \":\" \": \"\" at line 1, column 5.\nWas expecting one of:\n <EOF> \n <AND> ...\n <OR> ...\n <NOT> ...\n \"+\" ...\n \"-\" ...\n <BAREOPER> ...\n \"(\" ...\n \"*\" ...\n \"^\" ...\n <QUOTED> ...\n <TERM> ...\n <FUZZY_SLOP> ...\n <PREFIXTERM> ...\n <WILDTERM> ...\n <REGEXPTERM> ...\n \"[\" ...\n \"{\" ...\n <NUMBER> ...\n ",
				"caused_by": {
					"type": "parse_exception",
					"reason": "Encountered \" \":\" \": \"\" at line 1, column 5.\nWas expecting one of:\n <EOF> \n <AND> ...\n <OR> ...\n <NOT> ...\n \"+\" ...\n \"-\" ...\n <BAREOPER> ...\n \"(\" ...\n \"*\" ...\n \"^\" ...\n <QUOTED> ...\n <TERM> ...\n <FUZZY_SLOP> ...\n <PREFIXTERM> ...\n <WILDTERM> ...\n <REGEXPTERM> ...\n \"[\" ...\n \"{\" ...\n <NUMBER> ...\n "
				}
			}
		}
	}]
},
"status": 400

```

}

What is the meaning of this error? and How I resolve it? kindly help me here

---

<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:** [March 31, 2021, 8:01am UTC](https://discuss.elastic.co/t/elasticsearch-giving-query-shard-exception-for-query-string/268556/2 "2021-03-31T08:01:47Z")

</div>

I reproduced the problem with the following script and fixed it. See:

```auto
DELETE test 
PUT test 
{
  "mappings": {
    "properties": {
      "url": {
        "type": "keyword"
      }
    }
  }
}
POST test/_doc
{
  "url": "http://localhost:8000/v3/assets/dt1234/dt3335/605f068b5e124230eadea17a/my.png"
}
GET test/_search
{
  "query": {
    "query_string": {
      "query": "*\"http://localhost:8000/v3/assets/dt1234/dt3335/605f068b5e124230eadea17a/my.png\"*"
    }
  }
}

```

---

<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:** [April 28, 2021, 8:02am UTC](https://discuss.elastic.co/t/elasticsearch-giving-query-shard-exception-for-query-string/268556/3 "2021-04-28T08:02:08Z")

</div>

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