简体   繁体   English

Elasticsearch推向新类型

[英]Elasticsearch projections onto new type

Is it possible to get a projection as a query result in elasticsearch? 在Elasticsearch中是否可以获取投影作为查询结果?

For example: 例如:

I have 3 types in my index: 我的索引中有3种类型:

User { Id, Name, Groups[], Location { Lat, Lon } }
Group { Id, Name, Topics[] }
Message { Id, UserId, GroupId, Content}

And I want to get the number of messages and users in a group in a given area, so my input would be: 我想获取给定区域中某个组中的消息和用户数,因此我的输入将是:

{ Lat, Lon, Distance, GroupId }

and the output would be: 输出将是:

Group { Id, Name, Topics, NumberOfUsers, NumberOfMessages }

where the actual output of the query is a combination of data returned by the query and aggregations within that data. 查询的实际输出是查询返回的数据与该数据中的汇总的组合。

Is this possible? 这可能吗?

There are no JOINs in Elasticsearch (except for parent-child, but those shouldn't be used for heavy joining either). Elasticsearch中没有JOIN(父子级除外,但也不应该用于重联接)。 With your current data model you'll only be able to to application-side JOINs and depending on your actual data that might be a lot of roundtrips. 使用当前的数据模型,您将只能进行应用程序端的JOIN,并且取决于您的实际数据,这可能需要很多往返。 I don't think this will work out too well. 我认为这样做不会太好。

PS: Generally, please provide some simple test documents with usable data. PS:通常,请提供一些简单的测试文档以及可用数据。 If I have to put together a test data set to try out your problem, your chances that anybody will actually try it will get rather slim. 如果我必须整理一个测试数据集来尝试解决您的问题,那么任何人实际尝试它的机会都会变得很小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM