我想将嵌套查询从我的laravel Controller 传递给elasticsearch。
我的简单查询就像
简单查询
$params = [
'index' => 'my_index',
'type' => 'product',
'body' => [
'query'=>[
'match'=>[
'title'=>'first'
]
]
]
];
$response = \Es::Search($params); //passing query from here
它工作完美。
如何将以下嵌套查询传递给
\Es::Search($params);
?我的嵌套查询:
{
"query": {
"nested": {
"path": "sku",
"query": {
"bool": {
"must": [
{ "match": {"sku.price": "50"}}
]
}
}
}
}
}
我是Elasticsearch的新手,请提出一些建议。
最佳答案
您可以传递嵌套搜索查询,例如:
$params = [
'index' => 'my_index',
'type' => 'product',
'body' => [
'query'=>[
'nested'=> [
'path'=> 'category',
'query'=> [
'bool'=> [
'must'=> [
'match'=>[
'category.title'=> $catagory
]
]
]
]
]
]
]
];
$response = \Es::Search($params);
希望对您有所帮助。
关于php - 如何从laravel Controller 传递搜索查询到elasticsearch?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35665879/