我是 Elasticsearch 的新手,并且正在使用数据库。我想做这样的查询:
curl -X GET http://localhost:9200/project/flat_order/_search?pretty=true -d'
{ query:{
bool:{
must:{range:{created_at:{gte:"2012-01-01 00:00:00",lte:"2012-02-01 00:00:00"}}}},
{should:[{term:{status:"canceled"}}],minimum_number_should_match:1}
}
}
}'
我得到一个错误。
"error" : "SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[YfeNrRnOTOqLOtQt65uPVw][project][1]: SearchParseException[[project][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [ { query:{ bool:{ must:{range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}}}, {should:[{term:{status:\"canceled\"}}],minimum_number_should_match:1} } } }]]]; nested: QueryParsingException[[project] 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: [B@3742925a; line: 1, column: 102]]; }{[YfeNrRnOTOqLOtQt65uPVw][project][2]: SearchParseException[[project][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [ { query:{ bool:{ must:{range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}}}, {should:[{term:{status:\"canceled\"}}],minimum_number_should_match:1} } } }]]]; nested: QueryParsingException[[project] 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: [B@3742925a; line: 1, column: 102]]; }]",
"status" : 500
}
该怎么办?提前致谢。
这是我在没有那些大括号的情况下得到的错误(封闭应该)
"error" : "SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[YfeNrRnOTOqLOtQt65uPVw][project][0]: SearchParseException[[project][0]: query[created_at:[1325376000000 TO 1328054400999]],from[-1],size[-1]: Parse Failure [Failed to parse source [ { query:{ bool:{ must:{range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}}}, should:[{term:{status:\"canceled\"}}],minimum_number_should_match:1 } } }]]]; nested: SearchParseException[[project][0]: query[created_at:[1325376000000 TO 1328054400999]],from[-1],size[-1]: Parse Failure [No parser for element [term]]]; }{[YfeNrRnOTOqLOtQt65uPVw][project][4]: SearchParseException[[project][4]: query[created_at:[1325376000000 TO 1328054400999]],from[-1],size[-1]: Parse Failure [Failed to parse source [ { query:{ bool:{ must:{range:{created_at:{gte:\"2012-01-01 00:00:00\",lte:\"2012-02-01 00:00:00\"}}}}, should:[{term:{status:\"canceled\"}}],minimum_number_should_match:1 } } }]]]; nested: SearchParseException[[project][4]: query[created_at:[1325376000000 TO 1328054400999]],from[-1],size[-1]: Parse Failure [No parser for element [term]]]; }]",
"status" : 500
}