クエリの半分を変数$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}