Skip to content

Instantly share code, notes, and snippets.

@martijnvg
Created January 19, 2014 22:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martijnvg/8511859 to your computer and use it in GitHub Desktop.
Save martijnvg/8511859 to your computer and use it in GitHub Desktop.
curl -XPUT "http://localhost:9200/index2" -d'
{
"mappings": {
"child" : {
"_parent": {
"type": "child"
}
}
}
}'
curl -XPUT "http://localhost:9200/index2/parent/1" -d'
{
"field" : "value"
}'
curl -XPUT "http://localhost:9200/index2/child/1?parent=1" -d'
{
"field" : "value"
}'
curl -XPUT "http://localhost:9200/index2/parent/2" -d'
{
"field" : "value"
}'
curl -XPUT "http://localhost:9200/index2/child/2?parent=2" -d'
{
"field" : "value"
}'
curl -XPUT "http://localhost:9200/index2/child/3?parent=2" -d'
{
"field" : "value"
}'
# Only return parent 2, since the minimum of required of 2 child match.
curl -XPOST "http://localhost:9200/index2/_search" -d'
{
"query": {
"has_child": {
"type": "child",
"query": {
"constant_score": {
"query": {
"match": {
"field": "value"
}
}
}
},
"score_type": "sum"
}
},
"min_score" : 2
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment