Skip to content

Instantly share code, notes, and snippets.

@kimchy
Created October 18, 2011 21:26
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimchy/1296774 to your computer and use it in GitHub Desktop.
Save kimchy/1296774 to your computer and use it in GitHub Desktop.
curl -XPUT http://localhost:9200/twitter/foo/1 -d '{"message": "hello world"}'
curl -XPUT http://localhost:9200/twitter/bar/1 -d '{"message": "hello world"}'
# Use bool query with should clause, which ends up aggregating the scores if matching
# several clauses
curl -XGET 'http://localhost:9200/twitter/_search?pretty=1' -d '{
"query" : {
"bool" : {
"should" : [
{ "text" : { "message" : "hello"} },
{ "term" : { "_type" : {"value" : "foo", "boost" : 2.0} } }
]
}
}
}'
# faster option, use custom filters score, since the _type filter can be heavily
# cached, and boosting has more fine grained control
curl -XGET 'http://localhost:9200/twitter/_search?pretty=1' -d '{
"query" : {
"custom_filters_score" : {
"query" : {
"text" : { "message" : "hello" }
},
"filters" : [
{
"filter" : { "term" : {"_type" : "foo"} },
"boost" : 2
}
]
}
}
}'
@MolloKhan
Copy link

After looking for a while on how to boost a specific index type I found this gist, but I'm wondering how can I make it work in ES 5.6?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment