Elasticsearch复杂查询,模仿Join查询

发布于 2025-01-18 17:33:23 字数 527 浏览 5 评论 0原文

所以,假设我有 2 个索引用户和产品。

在用户中,我有以下格式:

users:
{
uid:"00001",
name:"Hash",
country:"US"
},

Within the products I have the following format:

product:
{
productname: "Shoes",
.
.
.
uid:"0001"
}

我的问题是,如何链接这两个索引并将其数据连接在一起?就像在 MySQL 中一样,我会执行以下操作:

SELECT * FROM users u JOIN products p ON u.uid = p.uid;

我希望结果与上面的查询相同,我的意思是这样的:

{
name:"Hash",
country:"US",
productname: "Shoes",
.
.
.
uid:"0001"
}

Elasticsearch 查询中有类似的内容吗?请帮忙!

So, let us say I have 2 indices users and products.

Within users I have the following format:

users:
{
uid:"00001",
name:"Hash",
country:"US"
},

Within the products I have the following format:

product:
{
productname: "Shoes",
.
.
.
uid:"0001"
}

My question is, how I can link these 2 indices and join its data together? like in MySQL I would do the following:

SELECT * FROM users u JOIN products p ON u.uid = p.uid;

I want the result to be the same as the above query, I mean like this :

{
name:"Hash",
country:"US",
productname: "Shoes",
.
.
.
uid:"0001"
}

Is there anything similar in Elasticsearch query? please help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文