Last active
August 29, 2015 14:01
-
-
Save zwrss/aeaf2828f6dd35a1e888 to your computer and use it in GitHub Desktop.
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/t" | |
curl -XPUT "http://localhost:9200/t" -d' | |
{ | |
"mappings": { | |
"P": { | |
"properties": { | |
"parstr": { | |
"type": "string" | |
} | |
} | |
}, | |
"T": { | |
"_parent": { | |
"type": "P" | |
}, | |
"_boost": { | |
"name": "boosting", | |
"null_value": 1 | |
}, | |
"properties": { | |
"boosting": { | |
"type": "double" | |
}, | |
"str": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
}' | |
curl -XPOST "http://localhost:9200/t/P/1" -d' | |
{ | |
"parstr": "parent one" | |
}' | |
curl -XPOST "http://localhost:9200/t/P/2" -d' | |
{ | |
"parstr": "parent two" | |
}' | |
curl -XPOST "http://localhost:9200/t/P/3" -d' | |
{ | |
"parstr": "parent three" | |
}' | |
curl -XPOST "http://localhost:9200/t/T?parent=1" -d' | |
{ | |
"boosting": 1.0, | |
"str": "one behind another stays the same" | |
}' | |
curl -XPOST "http://localhost:9200/t/T?parent=2" -d' | |
{ | |
"boosting": 2.0, | |
"str": "one behind another stays the ugly" | |
}' | |
curl -XPOST "http://localhost:9200/t/T?parent=3" -d' | |
{ | |
"boosting": 1.0, | |
"str": "one behind another stays the true" | |
}' | |
curl -XPOST "http://localhost:9200/t/P/_search?pretty=true" -d' | |
{ | |
"query": { | |
"top_children": { | |
"type": "T", | |
"query": { | |
"query_string": { | |
"query": "one behind another" | |
} | |
} | |
} | |
} | |
}' |
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/t" | |
curl -XPUT "http://localhost:9200/t" -d' | |
{ | |
"mappings": { | |
"P": { | |
"properties": { | |
"parstr": { | |
"type": "string" | |
} | |
} | |
}, | |
"T": { | |
"_parent": { | |
"type": "P" | |
}, | |
"properties": { | |
"boosting": { | |
"type": "double" | |
}, | |
"str": { | |
"type": "string" | |
} | |
} | |
} | |
} | |
}' | |
curl -XPOST "http://localhost:9200/t/P/1" -d' | |
{ | |
"parstr": "parent one" | |
}' | |
curl -XPOST "http://localhost:9200/t/P/2" -d' | |
{ | |
"parstr": "parent two" | |
}' | |
curl -XPOST "http://localhost:9200/t/P/3" -d' | |
{ | |
"parstr": "parent three" | |
}' | |
curl -XPOST "http://localhost:9200/t/T?parent=1" -d' | |
{ | |
"boosting": 1.0, | |
"str": "one behind another stays the same" | |
}' | |
curl -XPOST "http://localhost:9200/t/T?parent=2" -d' | |
{ | |
"boosting": 2.0, | |
"str": "one behind another stays the ugly" | |
}' | |
curl -XPOST "http://localhost:9200/t/T?parent=3" -d' | |
{ | |
"boosting": 1.0, | |
"str": "one behind another stays the true" | |
}' | |
curl -XPOST "http://localhost:9200/t/P/_search" -d' | |
{ | |
"query": { | |
"top_children": { | |
"type": "T", | |
"query": { | |
"function_score": { | |
"query": { | |
"query_string": { | |
"query": "one behind another" | |
} | |
}, | |
"functions": [ | |
{ | |
"script_score": { | |
"script": "_score * doc['boosting'].value" | |
} | |
} | |
], | |
"score_mode": "multiply" | |
} | |
} | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment