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

标签 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);

最佳答案

您只需将它们作为 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/

相关文章:

api - 美国政府 API?

php - 在 POSTMAN 上使用 PUT 方法上传文件

search - 如何在Vertica中搜索column_names?

javascript - 将 PHP 脚本返回的数据传递到 Highcharts data[] block 中?

php - 通过 PHP Mailer 使用实时服务器 SMTP 服务器发送电子邮件不起作用

mysql - C MySQL API 准备语句限制

java - JDialog 中的复选框列表

matlab - 查找矩阵中多个项目的索引?

javascript - 从 URL 中删除 UTM 参数

php - 将 insert_id() 从一个函数获取到另一个函数