[ElasticSearch] boostring query - negative match 로 최종 스코어 깎기

Woong·2024년 9월 11일
0

ElasticSearch

목록 보기
23/28

boosting query

  • positive query 로 매칭되는 문서에 대해, negative query 로 관련성 relevance score 을 낮추는 형태의 쿼리

    • 필터링이 아닌 score 를 낮춰 검색 순위를 낮추는 방법
    • 필터링이 아니기 때문에 문서 자체를 제외하지 않고 검색 랭킹만 낮출 수 있다.
  • negative 쿼리에 매칭될 경우, negative_boost 로 지정한 boost 값만큼을 곱해 score 를 깎는다.

    • 아래 예제에서는 negative term 쿼리에 매칭될 경우 최종 스코어에서 negative_boost 값인 0.5를 곱한 값이 최종 스코어가 된다.
GET /_search
{
  "query": {
    "boosting": {
      "positive": {
        "term": {
          "text": "apple"
        }
      },
      "negative": {
        "term": {
          "text": "pie tart fruit crumble tree"
        }
      },
      "negative_boost": 0.5
    }
  }
}

reference

0개의 댓글

관련 채용 정보