relationship 6

6-1. Handling Relationships

In the real world, relationships matter: blog posts have comments, bank accounts have transactions, customers have bank accounts, orders have order lines, and directories have files and subdirectories.현실 세계에서, 관계는 중요하다. 블로그 포스트는 댓글을 가지고 있고, 은행 계좌는 거래 내역을 가지고 있고, 고객은 은행 계좌를 가지고 있고, 명령은 명령 체계를 가지고 있고, 디렉토리는 파일과 하위 디렉토리를 가지고 있다.Relational databases are specifically designed—and this will not come a..

6-3. Parent-Child Relationship

The parent-child relationship is similar in nature to the nested model: both allow you to associate one entity with another. The difference is that, with nested objects, all entities live within the same document while, with parent-child, the parent and children are completely separate documents.parent-child relationship(부모-자식 관계)은 본질적으로 nested model과 유사하다. 둘 모두는 어떤 entity와 또 다른 것을 관련짓는다. 차이점은 n..

6-3-2. Indexing Parents and Children

Indexing parent documents is no different from any other document. Parents don’t need to know anything about their children:부모 document를 색인 하는 것은 다른 document와 다르지 않다. 부모는 그들의 자식에 대해 아무것도 알 필요가 없다.POST /company/branch/_bulk { "index": { "_id": "london" }} { "name": "London Westminster", "city": "London", "country": "UK" } { "index": { "_id": "liverpool" }} { "name": "Liverpool Central", "city": "..

6-3-3. Finding Parents by Their Children

The has_child query and filter can be used to find parent documents based on the contents of their children. For instance, we could find all branches that have employees born after 1980 with a query like this:has_child query와 filter는 자식의 내용으로 부모 document를 찾는데 사용될 수 있다. 예를 들어, 1980년 이후에 태어난 직원을 가진, 모든 지점을 찾을 수 있다. query는 아래와 같다.GET /company/branch/_search { "query": { "has_child": { "type": "empl..

6-3-5. Children Aggregation

Parent-child supports a children aggregation as a direct analog to the nested aggregation discussed in Nested Aggregations. A parent aggregation (the equivalent of reverse_nested) is not supported.부모-자식은, Nested Aggregations에서 언급했던, nested aggregation과 정확히 닮은, children aggregation를 지원한다. parent aggregation(reverse_nested 와 비슷한)는 지원되지 않는다.This example demonstrates how we could determine the favor..

6-3-7. Practical Considerations

Parent-child joins can be a useful technique for managing relationships when index-time performance is more important than search-time performance, but it comes at a significant cost. Parent-child queries can be 5 to 10 times slower than the equivalent nested query!부모-자식의 join은, 색인 시의 성능이 검색 시의 성능보다 중요한 경우에, 관계를 관리하는 유용한 기술이다. 그러나 상당한 비용이 발생한다. 부모-자식 query는 동급의 nested query에 비해 5 ~ 10배 정도 더 느릴 수..