小编典典

elasticsearch-查询多个索引是可能的吗?

elasticsearch

我有一个带有3个索引的elasticsearch集群:

/users/user
/events/visit
/events/register
/pages/page

因此,现在我需要运行处理多个索引的查询。

例如: 获取在页面X中注册的用户的性别。要获取此信息,我需要来自多个索引的信息。

这可能吗?也许整合Hadoop?


阅读 1349

收藏
2020-06-22

共1个答案

小编典典

在Elasticsearch本身中,这非常容易!任何时候您指定索引时,都可以用逗号分隔其他索引。

curl -XGET 'http://localhost:9200/index1,index2/_search?q=yourQueryHere'

您也可以使用_all搜索所有索引。

curl -XGET 'http://localhost:9200/_all/_search?q=yourQueryHere'

这是来自Elasticsearch网站的一些有用文档。该站点具有大量信息,但IMO有时很难找到。

https://www.elastic.co/guide/zh-CN/elasticsearch/reference/current/search-
search.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/multi-
index.html

2020-06-22