“加入查询”;在ElasticSearch中 [英] "Join query" in ElasticSearch

查看:64
本文介绍了“加入查询”;在ElasticSearch中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我们有两种索引类型:成员和餐厅。两者都包含城市属性。

Let's say we have two index types: members and restaurants. Both contain city attribute.

我想过滤成员(例如,按姓名),并希望在结果中包括来自成员的家乡/城市的餐馆名称列表。

I want to filter members (e.g. by name) and would like to include list of restaurant names from the members' hometown/city in the results.

是否可以仅使用一个ES查询来执行此操作?我想它应该类似于数据库联接。

Is it possible to do this using just one ES query? I guess it should be similar to DB join.

谢谢。

推荐答案

ES没有联接的概念。这是因为它是索引而不是关系数据库。最好打两个电话。一个获取会员的文件,然后另一个获取餐厅。

ES doesn't have the concepts of joins. This is due to it being an index rather than a relational database. Your best best to make two calls. One to get the member's documents, then another to get the restaurants.

除非您有特殊情况,否则这仍然非常有效。

Unless you have odd circumstances, this should still be very efficient.

这篇关于“加入查询”;在ElasticSearch中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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