Bläddra i källkod

Document that bool.filter assigns scores of 1.0

Clinton Gormley 9 år sedan
förälder
incheckning
b1ee074921
1 ändrade filer med 71 tillägg och 0 borttagningar
  1. 71 0
      docs/reference/query-dsl/bool-query.asciidoc

+ 71 - 0
docs/reference/query-dsl/bool-query.asciidoc

@@ -70,3 +70,74 @@ final `_score` for each document.
     }
 }
 --------------------------------------------------
+
+==== Scoring with `bool.filter` 
+
+Queries specified under the `filter` element have no effect on scoring --
+scores are returned as `0`.  Scores are only affected by the query that has
+been specified.  For instance, all three of the following queries return 
+all documents where the `status` field contains the term `active`. 
+
+This first query assigns a score of `0` to all documents, as no scoring
+query has been specified: 
+
+[source,json]
+---------------------------------
+GET _search
+{
+  "query": {
+    "bool": {
+      "filter": {
+        "term": {
+          "status": "active"
+        }
+      }
+    }
+  }
+}
+---------------------------------
+// AUTOSENSE
+
+This `bool` query has a `match_all` query, which assigns a score of `1.0` to 
+all documents.
+
+[source,json]
+---------------------------------
+GET _search
+{
+  "query": {
+    "bool": {
+      "query": {
+        "match_all": {}
+      },
+      "filter": {
+        "term": {
+          "status": "active"
+        }
+      }
+    }
+  }
+}
+---------------------------------
+// AUTOSENSE
+
+This `constant_score` query behaves in exactly the same way as the second example above.  
+The `constant_score` query assigns a score of `1.0` to all documents matched
+by the filter. 
+
+[source,json]
+---------------------------------
+GET _search
+{
+  "query": {
+    "constant_score": {
+      "filter": {
+        "term": {
+          "status": "active"
+        }
+      }
+    }
+  }
+}
+---------------------------------
+// AUTOSENSE