我想将查询的一半放在变量$query
中,并将其放在$params
的ElasticSearch中。
这是我的$query
:
if (Input::has('_id')) {
$_id = $this->input['_id'];
$path = 'data';
$field = 'data.city';
// Querying city
if (Input::has('city')) {
$city = $this->input['city'];
$query = array('query'=> [
'bool' => [
'must' => [
[
'match' => [
'_id' => $_id
]
],
[
'nested' => [
'path' => $path,
'query' => [
'bool' => [
'must' => [
[
'match' => [
$field => $city
]
]
]
]
]
]
]
]
]
]);
}
我想把这个变量放在$params
中,如下所示:
$params = [
'index' => 'channels',
'type' => 'users',
'body' => [
'from' => $defaultPerPage * ($page - 1),
'size' => $defaultPerPage,
$query
]
];
我尝试print_r($params)
并获得了正确的结果。
但是在尝试查询时我总是收到错误通知。
谁知道怎么做?
由于
错误:
{"error":"SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[6fZ0ud3kSTSYsMI-o-mg4w][channels][0]: SearchParseException[[channels][0]: from[0],size[10]: Parse Failure [Failed to parse source [{\"from\":0,\"size\":10,\"0\":{\"query\":{\"bool\":{\"must\":[{\"match\":{\"_id\":\"9121200asda121\"}},{\"nested\":{\"path\":\"data\",\"query\":{\"bool\":{\"must\":[{\"match\":{\"data.city\":\"california\"}}]}}}}]}}}}]]]; nested: SearchParseException[[channels][0]: from[0],size[10]: Parse Failure [No parser for element [0]]]; }{[W5E62t0EQ16lckCUnf8atw][channels][1]: RemoteTransportException[[Bima][inet[/10.200.7.69:9300]][indices:data/read/search[phase/query]]]; nested: SearchParseException[[channels][1]: from[0],size[10]: Parse Failure [Failed to parse source [{\"from\":0,\"size\":10,\"0\":{\"query\":{\"bool\":{\"must\":[{\"match\":{\"_id\":\"9121200asda121\"}},{\"nested\":{\"path\":\"data\",\"query\":{\"bool\":{\"must\":[{\"match\":{\"data.city\":\"california\"}}]}}}}]}}}}]]]; nested: SearchParseException[[channels][1]: from[0],size[10]: Parse Failure [No parser for element [0]]]; }{[6fZ0ud3kSTSYsMI-o-mg4w][channels][2]: SearchParseException[[channels][2]: from[0],size[10]: Parse Failure [Failed to parse source [{\"from\":0,\"size\":10,\"0\":{\"query\":{\"bool\":{\"must\":[{\"match\":{\"_id\":\"9121200asda121\"}},{\"nested\":{\"path\":\"data\",\"query\":{\"bool\":{\"must\":[{\"match\":{\"data.city\":\"california\"}}]}}}}]}}}}]]]; nested: SearchParseException[[channels][2]: from[0],size[10]: Parse Failure [No parser for element [0]]]; }]","status":400}