Last active
September 19, 2017 14:29
-
-
Save xeraa/64dad26d96ed76bfdb47d6452b9e5142 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE companies | |
PUT companies | |
{ | |
"mappings": { | |
"company" : {}, | |
"employee" : { | |
"_parent": { | |
"type": "company" | |
} | |
} | |
} | |
} | |
PUT companies/company/c1 | |
{ | |
"name" : "Stark Enterprises" | |
} | |
PUT companies/company/c2 | |
{ | |
"name" : "NBC Universal" | |
} | |
PUT companies/company/c3 | |
{ | |
"name" : "No children" | |
} | |
PUT companies/employee/emp1?parent=c1 | |
{ | |
"first_name" : "Tony", | |
"last_name" : "Stark" | |
} | |
PUT companies/employee/emp2?parent=c1 | |
{ | |
"first_name" : "Virginia", | |
"last_name" : "Potts" | |
} | |
PUT companies/employee/emp3?parent=c2 | |
{ | |
"first_name" : "Tony", | |
"last_name" : "Potts" | |
} | |
GET companies/_search | |
GET companies/company/_search | |
{ | |
"query": { | |
"has_child": { | |
"type": "employee", | |
"query": { | |
"match": { | |
"last_name": "Stark" | |
} | |
}, | |
"inner_hits" : {} | |
} | |
} | |
} | |
GET companies/employee/_search | |
{ | |
"query": { | |
"has_parent": { | |
"parent_type": "company", | |
"query": { | |
"match": { | |
"name": "NBC" | |
} | |
} | |
} | |
} | |
} | |
GET companies/company/_search | |
{ | |
"query": { | |
"has_child": { | |
"type": "employee", | |
"query": { | |
"match_all": {} | |
}, | |
"inner_hits" : {} | |
} | |
} | |
} | |
GET companies/company/_search | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"has_child": { | |
"type": "employee", | |
"query": { | |
"match_all": {} | |
}, | |
"inner_hits": {} | |
} | |
}, | |
{ | |
"match": { | |
"name": "stark" | |
} | |
} | |
] | |
} | |
} | |
} | |
GET companies/company/_search | |
{ | |
"query": { | |
"bool": { | |
"must_not": [ | |
{ | |
"has_child": { | |
"type": "employee", | |
"query": { | |
"match_all": {} | |
}, | |
"inner_hits": {} | |
} | |
} | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment