Created
October 18, 2011 21:26
-
-
Save kimchy/1296774 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 -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 | |
} | |
] | |
} | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?