elasticsearch-查询多个索引是可能的吗? [英] elasticsearch - querying multiple indexes is possible?
问题描述
我有一个带有3个索引的Elasticsearch集群:
I have an elasticsearch cluster with 3 indexes:
/users/user
/events/visit
/events/register
/pages/page
所以,现在我需要运行查询处理多个索引。
So, now I need to run queries processing multiple indexes.
例如:获取在X页中注册的用户的性别。
(要获取此信息,我需要来自多个索引的信息。)
这可能吗?也许集成hadoop?
Is this possible? Maybe integrating hadoop?
推荐答案
在Elasticsearch本身中这很容易!任何时候您指定索引时,都可以用逗号分隔其他索引。
This is quite easy within Elasticsearch itself! Anytime you would specify an index, you can separate additional indices by comma.
curl -XGET 'http://localhost:9200/index1,index2/_search?q=yourQueryHere'
您还可以使用_all搜索所有索引。
You can also search all indices with _all.
curl -XGET 'http://localhost:9200/_all/_search?q=yourQueryHere'
以下是elasticsearch网站上的一些有用文档。 IMO,该站点上有大量信息,但有时很难找到。
Here's some helpful documentation from elasticsearch's website. This site has TONS of info, but it is a bit difficult to find sometimes, IMO.
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html
https://www.elastic.co /guide/zh-CN/elasticsearch/reference/current/multi-index.html
这篇关于elasticsearch-查询多个索引是可能的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!