elasticsearch 在Elastic Search中像表连接一样连接两个索引

zf9nrax1  于 2023-04-20  发布在  ElasticSearch
关注(0)|答案(1)|浏览(191)

我对这种ElasticSearch相对较新。所以,我有一个名为***post***的索引,其中包含这样的文档:

{
"id": 1,
"link": "https:www.instagram.com/p/XXXXX/",
"profile_id": 11,
"like_count": 100,
"comment_count": 12
}

我有另一个名为***profile***的索引,其中包含这样的文档:

{
"id": 11,
"username": "superman",
"name": "Superman",
"followers": 12312
}

所以,正如大家所看到的,我把所有的profiles数据都放在了名为***profile***的索引下,把所有的posts数据都放在了名为***post***的索引下。post文档中的***“profile_id”与profile文档中的“id”链接在一起。
有没有什么方法,当我查询文章索引并过滤出文章文档时,配置文件数据也会根据文章文档中存在的
“profile_id”***与文章文档沿着出现?或者以某种方式获取两个数据进行多索引搜索?
提前感谢,任何帮助都将不胜感激。

798qvoo8

798qvoo81#

为了提高性能,Elasticsearch鼓励你去规范化你的数据,并根据你希望从查询中得到的响应来建模你的文档。然而,在你的情况下,我建议通过使用Join数据类型(链接到Elastic documentation)和使用parent-join查询来运行你的搜索(链接到Elastic documentation)来定义关系post-profile。

相关问题