elasticsearch/docs/reference/query-languages/query-dsl-boosting-query.md
Colleen McGinnis b7e3a1e14b
[docs] Migrate docs from AsciiDoc to Markdown (#123507)
* delete asciidoc files

* add migrated files

* fix errors

* Disable docs tests

* Clarify release notes page titles

* Revert "Clarify release notes page titles"

This reverts commit 8be688648d.

* Comment out edternal URI images

* Clean up query languages landing pages, link to conceptual docs

* Add .md to url

* Fixes inference processor nesting.

---------

Co-authored-by: Liam Thompson <32779855+leemthompo@users.noreply.github.com>
Co-authored-by: Liam Thompson <leemthompo@gmail.com>
Co-authored-by: Martijn Laarman <Mpdreamz@gmail.com>
Co-authored-by: István Zoltán Szabó <szabosteve@gmail.com>
2025-02-27 17:56:14 +01:00

1.7 KiB

navigation_title mapped_pages
Boosting
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html

Boosting query [query-dsl-boosting-query]

Returns documents matching a positive query while reducing the relevance score of documents that also match a negative query.

You can use the boosting query to demote certain documents without excluding them from the search results.

Example request [boosting-query-ex-request]

GET /_search
{
  "query": {
    "boosting": {
      "positive": {
        "term": {
          "text": "apple"
        }
      },
      "negative": {
        "term": {
          "text": "pie tart fruit crumble tree"
        }
      },
      "negative_boost": 0.5
    }
  }
}

Top-level parameters for boosting [boosting-top-level-params]

positive
(Required, query object) Query you wish to run. Any returned documents must match this query.
negative
(Required, query object) Query used to decrease the relevance score of matching documents.

If a returned document matches the positive query and this query, the boosting query calculates the final relevance score for the document as follows:

  1. Take the original relevance score from the positive query.
  2. Multiply the score by the negative_boost value.
negative_boost
(Required, float) Floating point number between 0 and 1.0 used to decrease the relevance scores of documents matching the negative query.