Created
March 8, 2012 21:45
Revisions
-
kimchy revised this gist
Mar 8, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -44,7 +44,7 @@ curl 'localhost:9200/test/_search?pretty=1&explain=0' -d '{ }' # Now, combine the two, should clauses are sums of scores, so have the negative boost query boost by a negative factor curl 'localhost:9200/test/_search?pretty=1&explain=0' -d '{ "query" : { "bool" : { "should" : [ -
kimchy created this gist
Mar 8, 2012 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ curl -XPUT localhost:9200/test -d '{ "settings" : { "index.number_of_shards" : 1, "index.number_of_replicas" : 0 } }' curl -XPUT localhost:9200/test/type/1 -d '{ "name" : "Awesometastic 1000", "type" : "TV Remote" }' curl -XPUT localhost:9200/test/type/2 -d '{ "name" : "Awesometastic 1000 TV Remote", "type" : "TV Remote" }' curl -XPOST localhost:9200/test/_refresh # One without negative boosting curl 'localhost:9200/test/_search?pretty=1&explain=0' -d '{ "query" : { "bool" : { "should" : [ { "text" : {"name" : {"query" : "The Awesometastic TV Remote", "boost" : 10}} }, { "text" : {"type" : {"query" : "The Awesometastic TV Remote", "boost" : 5}} }, ] } } }' # The query that gives us ones that try and cheat the system (higher score means that they are trying to cheat more...) curl 'localhost:9200/test/_search?pretty=1&explain=0' -d '{ "query" : { "bool" : { "must" : [ { "text" : {"name" : {"query" : "The Awesometastic TV Remote", "boost" : 1}} }, { "text" : {"type" : {"query" : "The Awesometastic TV Remote", "boost" : 1}} } ], "boost" : 1 } } }' # Now, combine the two, should clauses are sums of scores, so have the negative boost query boost by a negative factor curl 'localhost:9200/test/_search?pretty=1&explain=1' -d '{ "query" : { "bool" : { "should" : [ { "text" : {"name" : {"query" : "The Awesometastic TV Remote", "boost" : 10}} }, { "text" : {"type" : {"query" : "The Awesometastic TV Remote", "boost" : 5}} }, { "bool" : { "must" : [ { "text" : {"name" : {"query" : "The Awesometastic TV Remote", "boost" : 1}} }, { "text" : {"type" : {"query" : "The Awesometastic TV Remote", "boost" : 1}} } ], "boost" : -20 } } ] } } }'