Skip to content

Instantly share code, notes, and snippets.

@plusjade
Created February 19, 2013 18:38
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 plusjade/4988626 to your computer and use it in GitHub Desktop.
Save plusjade/4988626 to your computer and use it in GitHub Desktop.
Elasticsearch curl example for ranking by individual token boosts. You can copy this full input and paste it directly into the command-line. Expected results: The result set should be sorted perfectly by the boost value for the skill "ruby". Please note term-frequencies WILL affect scoring and it's only because these documents have the exact sam…
curl -XDELETE 'http://localhost:9200/p'
curl -XPOST 'http://localhost:9200/p'
curl -XPOST 'localhost:9200/p/profile/_mapping' -d '
{
"profile": {
"properties": {
"skills": {
"type": "string",
"omit_term_freq_and_positions" : true,
"index" : "not_analyzed"
}
}
}
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 5 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 4 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 1 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 3 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "ruby", "_boost": 2 } ]
}'
curl -XPOST localhost:9200/p/profile -d '{
"skills": [ { "_value": "python", "_boost": 100 } ]
}'
curl -XPOST "http://localhost:9200/p/_refresh"
curl -XGET 'localhost:9200/p/_search?&search_type=dfs_query_then_fetch&pretty=true' -d '{
"query": {
"query_string": {
"query": "ruby"
}
},
"sort": [{"_score": "desc"}],
"explain": false
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment