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

时间:2014-11-19 16:17:29

标签: php api search types elasticsearch

我想使用 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);

1 个答案:

答案 0 :(得分: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);