Created
January 26, 2014 21:43
-
-
Save martijnvg/8639841 to your computer and use it in GitHub Desktop.
has_parent with function_score
This file contains 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
curl -XDELETE "http://localhost:9200/_all" | |
curl -XPUT "http://localhost:9200/test1" -d' | |
{ | |
"mappings": { | |
"parent" : { | |
"properties": { | |
"weight" : { | |
"type": "double" | |
} | |
} | |
}, | |
"child" : { | |
"_parent": { | |
"type": "parent" | |
} | |
} | |
} | |
}' | |
curl -XPUT "http://localhost:9200/test1/parent/1" -d' | |
{ | |
"weight" : 5 | |
}' | |
curl -XPUT "http://localhost:9200/test1/child/1?parent=1" -d' | |
{ | |
"field" : "value" | |
}' | |
curl -XPUT "http://localhost:9200/test1/child/2?parent=1" -d' | |
{ | |
"field" : "value" | |
}' | |
curl -XPOST "http://localhost:9200/test1/_search" -d' | |
{ | |
"query" : { | |
"has_parent" : { | |
"query" : { | |
"function_score" : { | |
"script_score" : { | |
"script" : "_score * doc[\"weight\"].value" | |
} | |
} | |
}, | |
"parent_type" : "parent", | |
"score_type" : "score" | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment