在Elasticsearch php API中使用多种类型或索引 [英] Using multiple types or indexes in Elasticsearch php API

查看:74
本文介绍了在Elasticsearch php API中使用多种类型或索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Elasticsearch PHP API 查询多种类型和索引.但我不知道如何我应该将类型和索引的数组传递给 $ params 吗?:

I want to query multiple types and indices using Elasticsearch PHP API. but I don't Know how. should I pass an array of types and indices to $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);

推荐答案

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

You just add them as a string to $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);

这篇关于在Elasticsearch php API中使用多种类型或索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆