Elasticsearch Simple Query String Query에 대해서 알아보기

query_string과는 달리 simple_query_string쿼리는 예외를 throw하지 않으며 쿼리의 잘못된 부분을 삭제합니다.

simple_query_string은 특수문자를 통해 연산자를 선언할 수 있습니다.

+ : AND operation

| : OR operation

- : 싱글 토큰을 무시합니다.

: 검색어 구문 그대로 검색하기 위해 사용합니다.

* : 단어의 끝에 선언하는 prefix query

( ) : 구문을 감쌀때 사용

example

$ curl "localhost:9200/sales-records/_search?pretty" -H "Content-Type:application/json" -d '
{
  "query": {
    "simple_query_string": {
      "fields": ["country"],
      "query": "kor* -south"
    }
  }
}'

kor로 시작하는 단어가 들어가며 south라는 단어는 빼고 검색합니다.

참고사이트

  1. https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html



Enjoy Reading This Article?

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

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