Elasticsearch Match Phrase Prefix Query에 대해서 알아보기

Match Phrase Query 와 같지만 약간 다른 Match Phrase Prefix Query에 대해서 알아보겠습니다.

Match Phrase Query와 동일하게 동작하지만 마지막 term을 접두어로 일치하는 Document를 검색합니다.

example

max_expansions는 prefix를 확장할 최대값을 지정합니다.

curl "localhost:9200/sales-records/_search?pretty" -H "Content-Type:application/json" -d '
{
  "query": {
    "match_phrase_prefix": {
      "country": {
        "query":"south ko", "max_expansions": 10      }
    }
  }}'

match_phrase_prefix로 “south ko”를 검색하면 “south”는 필수로 들어가며 “ko”는 prefix로서 “south ko”이 일치하는 document를 검색합니다.

{
  "took" : 5,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 8104,
      "relation" : "eq"
    },
    "max_score" : 11.504026,
    "hits" : [
      ...
    ]
  }
}



Enjoy Reading This Article?

Here are some more articles you might like to read next:

  • 백엔드 개발자가 리액트 네이티브로 달력 앱을 배포해보았습니다.
  • MySQL 실시간 쿼리 확인하기
  • MySQL 트랜잭션 격리수준 Isolation level 알아보기
  • 레디스에 대한 간단한 설명과 성능향상시키기
  • Apple login 사용해보기