opensearch-docs-cn/_query-dsl/compound/disjunction-max.md

106 lines
3.1 KiB
Markdown
Raw Permalink Normal View History

---
layout: default
Add score normalization and combination documentation (#4985) * Add search phase results processor Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add hybrid query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Normalization processor additions Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add more details Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Continue writing Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add more query then fetch details and diagram Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Small rewording Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Leaner left nav headers Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Tech review feedback Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add semantic search tutorial Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Reworded prerequisites Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Removed comma Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Rewording advanced prerequisites Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Changed searching for ML model to shorter request Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update task type in register model response Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Changing example Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added huggingface prefix to model names Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Change example responses Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added note about huggingface prefix Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Update _ml-commons-plugin/semantic-search.md Co-authored-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented doc review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * List weights under parameters Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Remove one-shard warning for normalization processor Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Nathan Bower <nbower@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Change links Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * More editorial feedback Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Change model-serving framework to ML framework Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Use get model API to check model status Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implemented tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added neural search description and diagram Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * More editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add link to profile API Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Addressed more tech review comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Implemented editorial comments on changes Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Naarcha-AWS <97990722+Naarcha-AWS@users.noreply.github.com> Co-authored-by: Nathan Bower <nbower@amazon.com>
2023-09-22 17:29:58 -04:00
title: Disjunction max
parent: Compound queries
grand_parent: Query DSL
nav_order: 50
redirect_from:
- /query-dsl/query-dsl/compound/disjunction-max/
---
Add full-text query documentation (#5428) * Refactor full-text query documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add examples and parameter descriptions Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add multi-match query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add query string field format Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Query string examples Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add regular expressions and fuzziness Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add wildcard and regex warning Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added more query string format Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added multi-field sections Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Rewrite minimum should match section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added allow expensive queries section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add simple query string query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Small rewrites Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add intervals query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Include discover in query string syntax Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Link and index page fix Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com>
2023-11-01 09:29:13 -04:00
# Disjunction max query
A disjunction max (`dis_max`) query returns any document that matches one or more query clauses. For documents that match multiple query clauses, the relevance score is set to the highest relevance score from all matching query clauses.
When the relevance scores of the returned documents are identical, you can use the `tie_breaker` parameter to give more weight to documents that match multiple query clauses.
## Example
Consider an index with two documents that you index as follows:
```json
PUT testindex1/_doc/1
{
"title": " The Top 10 Shakespeare Poems",
"description": "Top 10 sonnets of England's national poet and the Bard of Avon"
}
```
Add full-text query documentation (#5428) * Refactor full-text query documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add examples and parameter descriptions Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add multi-match query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add query string field format Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Query string examples Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add regular expressions and fuzziness Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add wildcard and regex warning Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added more query string format Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added multi-field sections Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Rewrite minimum should match section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added allow expensive queries section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add simple query string query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Small rewrites Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add intervals query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Include discover in query string syntax Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Link and index page fix Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com>
2023-11-01 09:29:13 -04:00
{% include copy-curl.html %}
```json
PUT testindex1/_doc/2
{
"title": "Sonnets of the 16th Century",
"body": "The poems written by various 16-th century poets"
}
```
Add full-text query documentation (#5428) * Refactor full-text query documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add examples and parameter descriptions Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add multi-match query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add query string field format Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Query string examples Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add regular expressions and fuzziness Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add wildcard and regex warning Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added more query string format Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added multi-field sections Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Rewrite minimum should match section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added allow expensive queries section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add simple query string query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Small rewrites Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add intervals query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Include discover in query string syntax Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Link and index page fix Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com>
2023-11-01 09:29:13 -04:00
{% include copy-curl.html %}
Add full-text query documentation (#5428) * Refactor full-text query documentation Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add examples and parameter descriptions Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add multi-match query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add query string field format Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Query string examples Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add regular expressions and fuzziness Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add wildcard and regex warning Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added more query string format Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added multi-field sections Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Rewrite minimum should match section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Added allow expensive queries section Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add simple query string query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Small rewrites Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Add intervals query Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Include discover in query string syntax Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Link and index page fix Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> * Apply suggestions from code review Co-authored-by: Melissa Vagi <vagimeli@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> * Implemented editorial comments Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> --------- Signed-off-by: Fanit Kolchina <kolchfa@amazon.com> Signed-off-by: kolchfa-aws <105444904+kolchfa-aws@users.noreply.github.com> Co-authored-by: Melissa Vagi <vagimeli@amazon.com>
2023-11-01 09:29:13 -04:00
Use a `dis_max` query to search for documents that contain the words "Shakespeare poems":
```json
GET testindex1/_search
{
"query": {
"dis_max": {
"queries": [
{ "match": { "title": "Shakespeare poems" }},
{ "match": { "body": "Shakespeare poems" }}
]
}
}
}
```
{% include copy-curl.html %}
The response contains both documents:
```json
{
"took": 8,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": 1.3862942,
"hits": [
{
"_index": "testindex1",
"_id": "1",
"_score": 1.3862942,
"_source": {
"title": " The Top 10 Shakespeare Poems",
"description": "Top 10 sonnets of England's national poet and the Bard of Avon"
}
},
{
"_index": "testindex1",
"_id": "2",
"_score": 0.2876821,
"_source": {
"title": "Sonnets of the 16th Century",
"body": "The poems written by various 16-th century poets"
}
}
]
}
}
```
## Parameters
The following table lists all top-level parameters supported by `dis_max` queries.
Parameter | Description
:--- | :---
`queries` | An array of one or more query clauses that are used to match documents. A document must match at least one query clause to be returned in the results. If a document matches multiple query clauses, the relevance score is set to the highest relevance score from all matching query clauses. Required.
`tie_breaker` | A floating-point factor between 0 and 1.0 that is used to give more weight to documents that match multiple query clauses. In this case, the relevance score of a document is calculated using the following algorithm: Take the highest relevance score from all matching query clauses, multiply the scores from all other matching clauses by the `tie_breaker` value, and add the relevance scores together, normalizing them. Optional. Default is 0 (which means only the highest score counts).