无法为弹性搜索查询计算错误400

时间:2016-05-21 03:44:02

标签: elasticsearch

我只是尝试使用弹性搜索,并运行了此查询:

curl -XPOST "http://host/logstash-2016.05.19/_search" -d'

{
  "query": {
        { "match": { "serviceName": "systemA" } }
  }
}'

但不断收到此错误:

{
   "error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[hTYqYg0RSt2XZrYWxwMQ3g][logstash-2016.05.19][0]: RemoteTransportException[[es1][inet[/10.149.76.25:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[logstash-2016.05.19][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"query\": {\n        { \"match\": { \"serviceName\": \"bsHolds\" } }\n  }\n}\n]]]; nested: QueryParsingException[[logstash-2016.05.19] Failed to parse]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: UNKNOWN; line: 3, column: 10]]; }{[asrIxDjBSJeKvDTT7zfgMQ][logstash-2016.05.19][1]: RemoteTransportException[[es5][inet[/10.149.76.155:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[logstash-2016.05.19][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"query\": {\n        { \"match\": { \"serviceName\": \"bsHolds\" } }\n  }\n}\n]]]; nested: QueryParsingException[[logstash-2016.05.19] Failed to parse]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: UNKNOWN; line: 3, column: 10]]; }{[asrIxDjBSJeKvDTT7zfgMQ][logstash-2016.05.19][2]: RemoteTransportException[[es5][inet[/10.149.76.155:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[logstash-2016.05.19][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"query\": {\n        { \"match\": { \"serviceName\": \"bsHolds\" } }\n  }\n}\n]]]; nested: QueryParsingException[[logstash-2016.05.19] Failed to parse]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: UNKNOWN; line: 3, column: 10]]; }{[PwDi_CIiQHmOHp34KdWk0A][logstash-2016.05.19][3]: RemoteTransportException[[es3][inet[/10.149.76.97:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[logstash-2016.05.19][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"query\": {\n        { \"match\": { \"serviceName\": \"bsHolds\" } }\n  }\n}\n]]]; nested: QueryParsingException[[logstash-2016.05.19] Failed to parse]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: UNKNOWN; line: 3, column: 10]]; }{[PwDi_CIiQHmOHp34KdWk0A][logstash-2016.05.19][4]: RemoteTransportException[[es3][inet[/10.149.76.97:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[logstash-2016.05.19][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"query\": {\n        { \"match\": { \"serviceName\": \"bsHolds\" } }\n  }\n}\n]]]; nested: QueryParsingException[[logstash-2016.05.19] Failed to parse]; nested: JsonParseException[Unexpected character ('{' (code 123)): was expecting either valid name character (for unquoted name) or double-quote (for quoted) to start field name\n at [Source: UNKNOWN; line: 3, column: 10]]; }]",
   "status": 400
}

不确定这意味着什么,但我试图按照elastic.co上的指南进行操作,但我在任何查询中都会遇到400错误...

1 个答案:

答案 0 :(得分:3)

你有太多的花括号。请尝试此查询

for (keys(%h)) {
   $_ = uc($_);  # Has no effect on the hash.
}

for (values(%h)) {
   $_ = uc($_);  # Effects the hash.
}

如果您正在使用Sense,则需要按照以下方式进行查询:

curl -XPOST "http://host/logstash-2016.05.19/_search" -d'{
  "query": {
     "match": { "serviceName": "systemA" }
  }
}'