공부용

[ElasticSearch] term, match, match_phrase 본문

공부용

[ElasticSearch] term, match, match_phrase

고딕짱! 2021. 5. 10. 18:34

1. term

쿼리의 키워드와 일치하는 녀석이 있는지 찾아준다.

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "field": "data"
          }
        }
      ]
    }
  }
}

 

2. match

쿼리의 키워드를 분석해서, 분석한 결과의 token 들 중 하나라도 일치하면 return 한다.

{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "field": "data"
          }
        }
      ]
    }
  }
}

 

3.match_phrase

match처럼 keyword를 분석하는것은 동일하나 그 결과 token 들이 모두 존재하고, 순서도 순차적으로 동일한 document 만을 검색 결과에 포함

{
  "query": {
    "bool": {
      "must": [
        {
          "match_phrase": {
            "filed" : "data1 data2"
          }
        }
      ]
    }
  }
}

'공부용' 카테고리의 다른 글

[ElasticSearch] AND / OR  (0) 2021.05.10
ES(ElasticSearch) Select/GET/SEARCH 예제  (0) 2021.05.06
Comments