如何解决org.elasticsearch.action.search.SearchPhaseExecutionException:所有分片均失败

时间:2018-11-09 07:38:33

标签: spring-boot elasticsearch

我正在使用Elasticsearch

{
  "name" : "Angela Cairn",
  "cluster_name" : "prod-elastic",
  "cluster_uuid" : "iKkcI5FwTsGMtXacl3Qg-g",
  "version" : {
    "number" : "2.4.4",
    "build_hash" : "fcbb46dfd45562a9cf00c604b30849a6dec6b017",
    "build_timestamp" : "2017-01-03T11:33:16Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}

有时我发现以下错误,但无法找到发生此错误的原因以及解决该问题的方法

错误

Failed to execute phase [dfs], all shards failed; shardFailures {[3MNt6HxYSGiyfoZZhB20lw][catalog][0]: RemoteTransportException[[Angela Cairn][172.31.28.194:9300][indices:data/read/search[phase/dfs]]]; nested: SearchParseException[failed to parse search source [{"from":0,"size":15,"query_binary":"eyAiYm9vbCI6ICB7ICJtdXN0X25vdCIgOiBbIHsgICAibWF0Y2giOnsgICAic3RhdHVzIjoiSW5hY3RpdmUifSB9LCB7ICAibWF0Y2giOnsgICAic3RhdHVzIjoiUGVuZGluZyJ9IH1dLCAibXVzdCI6IFt7ICJtYXRjaCI6IHsgImxvY2F0aW9uIjogIkRlbGhpIiB9IH0seyAiYm9vbCI6eyAic2hvdWxkIjogWyB7ICJtdWx0aV9tYXRjaCIgOiB7ICJxdWVyeSI6ICJ0aGlvbmFpZCBcXFxcXFxcXFxcXFxcXFxcXCIsICJ0eXBlIjogImJlc3RfZmllbGRzIiwgImZpZWxkcyI6IFsgIm5hbWVeNSIsICJicmFuZF4zIiBdLCAiYm9vc3QiOjEsICJmdXp6aW5lc3MiIDogIkFVVE8iLCAicHJlZml4X2xlbmd0aCI6IDIgfSB9LCB7ICJtdWx0aV9tYXRjaCIgOiB7ICJxdWVyeSI6ICJ0aGlvbmFpZCBcXFxcXFxcXFxcXFxcXFxcXCIsICJ0eXBlIjogInBocmFzZV9wcmVmaXgiLCAiZmllbGRzIjogWyAibmFtZV41IiwgImJyYW5kXjMiIF0sICJib29zdCI6IDMgfSB9LHsgIm11bHRpX21hdGNoIiA6IHsgInF1ZXJ5IjogInRoaW9uYWlkIFxcXFxcXFxcXFxcXFxcXFxcIiwgInR5cGUiOiAicGhyYXNlX3ByZWZpeCIsICJmaWVsZHMiOiBbICJza3UiIF0sICJib29zdCI6IDUgfSB9XSB9IH1dIH0gfQ=="}]]; nested: QueryParsingException[Failed to parse]; nested: JsonParseException[Unexpected character ('t' (code 116)): was expecting comma to separate Object entries
     at [Source: [B@6f430fbe; line: 1, column: 238]]; }{[3MNt6HxYSGiyfoZZhB20lw][catalog][1]: RemoteTransportException[[Angela Cairn][172.31.28.194:9300][indices:data/read/search[phase/dfs]]]; nested: SearchParseException[failed to parse search source [{"from":0,"size":15,"query_binary":"eyAiYm9vbCI6ICB7ICJtdXN0X25vdCIgOiBbIHsgICAibWF0Y2giOnsgICAic3RhdHVzIjoiSW5hY3RpdmUifSB9LCB7ICAibWF0Y2giOnsgICAic3RhdHVzIjoiUGVuZGluZyJ9IH1dLCAibXVzdCI6IFt7ICJtYXRjaCI6IHsgImxvY2F0aW9uIjogIkRlbGhpIiB9IH0seyAiYm9vbCI6eyAic2hvdWxkIjogWyB7ICJtdWx0aV9tYXRjaCIgOiB7ICJxdWVyeSI6ICJ0aGlvbmFpZCBcXFxcXFxcXFxcXFxcXFxcXCIsICJ0eXBlIjogImJlc3RfZmllbGRzIiwgImZpZWxkcyI6IFsgIm5hbWVeNSIsICJicmFuZF4zIiBdLCAiYm9vc3QiOjEsICJmdXp6aW5lc3MiIDogIkFVVE8iLCAicHJlZml4X2xlbmd0aCI6IDIgfSB9LCB7ICJtdWx0aV9tYXRjaCIgOiB7ICJxdWVyeSI6ICJ0aGlvbmFpZCBcXFxcXFxcXFxcXFxcXFxcXCIsICJ0eXBlIjogInBocmFzZV9wcmVmaXgiLCAiZmllbGRzIjogWyAibmFtZV41IiwgImJyYW5kXjMiIF0sICJib29zdCI6IDMgfSB9LHsgIm11bHRpX21hdGNoIiA6IHsgInF1ZXJ5IjogInRoaW9uYWlkIFxcXFxcXFxcXFxcXFxcXFxcIiwgInR5cGUiOiAicGhyYXNlX3ByZWZpeCIsICJmaWVsZHMiOiBbICJza3UiIF0sICJib29zdCI6IDUgfSB9XSB9IH1dIH0gfQ=="}]]; nested: QueryParsingException[Failed to parse]; nested: JsonParseException[Unexpected character ('t' (code 116)): was expecting comma to separate Object entries

1 个答案:

答案 0 :(得分:1)

提供了主要线索:

  

QueryParsingException [无法解析];嵌套:JsonParseException [意外字符('t'(代码116)):期望逗号分隔对象条目

ElasticSearch告诉您您要执行的查询是无效的JSON文档。

上述查询是这样的:

{ 
  "bool": { 
    "must_not" : [
      { "match":{ "status":"Inactive"} } ,
      { "match":{ "status":"Pending"} }
    ],
    "must": [
      { "match": { "location": "Delhi" } },
      { "bool": {
        "should": [
        { 
          "multi_match" : { 
            "query": "thionaid \\\\\\\\\\\\\\\\\",
            "type": "best_fields",
            "fields": [ "name^5", "brand^3" ],
            "boost":1,
            "fuzziness" : "AUTO",
            "prefix_length": 2
          }
        },
        { 
          "multi_match" : { 
            "query": "thionaid \\\\\\\\\\\\\\\\\",
            "type": "phrase_prefix",
            "fields": [ "name^5", "brand^3" ],
            "boost": 3
          }
        },
        { 
          "multi_match" : { 
            "query": "thionaid \\\\\\\\\\\\\\\\\",
            "type": "phrase_prefix",
            "fields": [ "sku" ],
            "boost": 5
          }
        }
      ]
    }
  }
  ]
 }
}

问题在于这些字符串:"thionaid \\\\\\\\\\\\\\\\\"(反斜杠太多)