|
@@ -41,13 +41,13 @@ For example:
|
|
|
|
|
|
[source,js]
|
|
|
--------------------------------------------------
|
|
|
-curl -s -XPOST 'localhost:9200/_search' -d '{
|
|
|
+POST /_search
|
|
|
+{
|
|
|
"query" : {
|
|
|
"match" : {
|
|
|
- "field1" : {
|
|
|
+ "message" : {
|
|
|
"operator" : "or",
|
|
|
- "query" : "the quick brown",
|
|
|
- "type" : "boolean"
|
|
|
+ "query" : "the quick brown"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -55,10 +55,9 @@ curl -s -XPOST 'localhost:9200/_search' -d '{
|
|
|
"window_size" : 50,
|
|
|
"query" : {
|
|
|
"rescore_query" : {
|
|
|
- "match" : {
|
|
|
- "field1" : {
|
|
|
+ "match_phrase" : {
|
|
|
+ "message" : {
|
|
|
"query" : "the quick brown",
|
|
|
- "type" : "phrase",
|
|
|
"slop" : 2
|
|
|
}
|
|
|
}
|
|
@@ -68,8 +67,9 @@ curl -s -XPOST 'localhost:9200/_search' -d '{
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-'
|
|
|
--------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+// TEST[setup:twitter]
|
|
|
|
|
|
The way the scores are combined can be controlled with the `score_mode`:
|
|
|
[cols="<,<",options="header",]
|
|
@@ -86,15 +86,16 @@ for <<query-dsl-function-score-query,`function query`>> rescores.
|
|
|
==== Multiple Rescores
|
|
|
|
|
|
It is also possible to execute multiple rescores in sequence:
|
|
|
+
|
|
|
[source,js]
|
|
|
--------------------------------------------------
|
|
|
-curl -s -XPOST 'localhost:9200/_search' -d '{
|
|
|
+POST /_search
|
|
|
+{
|
|
|
"query" : {
|
|
|
"match" : {
|
|
|
- "field1" : {
|
|
|
+ "message" : {
|
|
|
"operator" : "or",
|
|
|
- "query" : "the quick brown",
|
|
|
- "type" : "boolean"
|
|
|
+ "query" : "the quick brown"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -102,10 +103,9 @@ curl -s -XPOST 'localhost:9200/_search' -d '{
|
|
|
"window_size" : 100,
|
|
|
"query" : {
|
|
|
"rescore_query" : {
|
|
|
- "match" : {
|
|
|
- "field1" : {
|
|
|
+ "match_phrase" : {
|
|
|
+ "message" : {
|
|
|
"query" : "the quick brown",
|
|
|
- "type" : "phrase",
|
|
|
"slop" : 2
|
|
|
}
|
|
|
}
|
|
@@ -121,8 +121,7 @@ curl -s -XPOST 'localhost:9200/_search' -d '{
|
|
|
"function_score" : {
|
|
|
"script_score": {
|
|
|
"script": {
|
|
|
- "lang": "painless",
|
|
|
- "inline": "Math.log10(doc['numeric'].value + 2)"
|
|
|
+ "inline": "Math.log10(doc.likes.value + 2)"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -130,8 +129,9 @@ curl -s -XPOST 'localhost:9200/_search' -d '{
|
|
|
}
|
|
|
} ]
|
|
|
}
|
|
|
-'
|
|
|
--------------------------------------------------
|
|
|
+// CONSOLE
|
|
|
+// TEST[setup:twitter]
|
|
|
|
|
|
The first one gets the results of the query then the second one gets the
|
|
|
results of the first, etc. The second rescore will "see" the sorting done
|