我想使用 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);
最佳答案
您只需将它们作为 string 添加到 $params
中:
$params['index'] = "index1,index2";// a comma-separated list of index names, without any extra space
$params['type'] = "type1, type2";//array of types
$params['body'] = $q;//query body
//request elasticsearch for matched documents
$results = $client->search($params);
关于php - 在 Elasticsearch php API 中使用多种类型或索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27021693/