While a nested query can always return only the root document as a result, parent and child documents are independent and each can be queried independently. The has_child query allows us to return parents based on data in their children, and the has_parent query returns children based on data in their parents.
nested query는 결과로 root document만 반환하지만, 부모와 자식 document는 독립적이며, 각각 독립적으로 query될 수 있다. has_child query는 자식의 데이터를 기준으로 부모를 반환할 수 있다. 그리고 has_parent query는 부모의 데이터를 기준으로 자식을 반환할 수 있다.
It looks very similar to the has_child query. This example returns employees who work in the UK:
그것은 has_child query와 매우 비슷하다. 아래 예제는 UK에서 일하고 있는 직원을 반환한다.
GET /company/employee/_search { "query": { "has_parent": { "type": "branch","query": { "match": { "country": "UK" } } } } }
The has_parent query also supports the score_mode, but it accepts only two settings: none (the default) and score. Each child can have only one parent, so there is no need to reduce multiple scores into a single score for the child. The choice is simply between using the score (score) or not (none).
has_parent query 또한 score_mode 를 지원한다. 그러나, 2가지 설정만을 가진다. (기본값인 none 과 score) 각 자식은 하나의 부모만을 가질 수 있다. 따라서 자식을 위해 다수의 score를 하나의 score로 줄일 필요가 없다. score를 사용하느냐(score) 아니냐(none)의 선택이다.
'2.X > 6. Modeling Your Data' 카테고리의 다른 글
| 6-3-2. Indexing Parents and Children (0) | 2017.09.23 |
|---|---|
| 6-3-3. Finding Parents by Their Children (0) | 2017.09.23 |
| 6-3-5. Children Aggregation (0) | 2017.09.23 |
| 6-3-6. Grandparents and Grandchildren (0) | 2017.09.23 |
| 6-3-7. Practical Considerations (0) | 2017.09.23 |