mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 09:28:27 +00:00
Document that bool.filter assigns scores of 1.0
This commit is contained in:
parent
d5e20fb763
commit
b1ee074921
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user