我的索引弹性搜索文档包含一个数组字段。例如汽车的功能。
{
"features": [ "Anti-Lock Brakes",
"Alarm",
"Air Bag Driver",
"Cruise Control",
"Satellite Navigation"'
}
如何搜索包含给定数组中的值的文档。例如:我想检查包含“卫星导航”和“巡航控制”等功能的汽车。
我尝试了以下方法,但它不起作用(php代码)
public function index(Request $request, Client $search, SerializerInterface $serializer): JsonResponse
...
$search_query = ["Satellite Navigation", "Cruise Control"]
$filters = [];
$filters[] = [
'terms' => [
'features' => $search_query,
]
];
$results = $search->search([
'index' => 'cars',
'body' => [
'from' => $offset,
'size' => self::PAGE_WINDOW,
'query' => [
"bool" => [
"must" => [
"match_all" => new \stdClass()
],
"filter" => $filters
]
]
]
]);
...
我想获得有关如何设置 $filters 的提示,以便获得所需的结果。
慕丝7291255