Elasticsearch giving query_shard_exception for query_string

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

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

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\"*"
    }
  }
}

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