在Elasticsearch php API中使用多个类型或索引

问题描述 投票:7回答:1

我想使用Elasticsearch PHP API查询多个类型和索引。但我不知道怎么做。我应该将一系列类型和索引传递给$params吗? :

$params['index'] = $index;//array of indices
$params['type']  = $types;//array of types
$params['body']  = $q;//query body
//request elasticsearch for matched documents
$results = $client->search($params);
php api search types elasticsearch
1个回答
10
投票

你只需将它们作为字符串添加到$params

$params['index'] = "index1,index2";//array of indices
$params['type']  = "type1,type2";//array of types
$params['body']  = $q;//query body
//request elasticsearch for matched documents
$results = $client->search($params);
© www.soinside.com 2019 - 2024. All rights reserved.