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:

  • 데이터베이스 관계키(FK) 는 꼭 사용해야 할까?
  • 데이터베이스 LIKE문 제대로 이해하고 사용하기
  • 데이터베이스 인덱스 동작방식 그리고 최적화
  • 대용량 디비에 파티션을 활용해야 하는 이유
  • 무료 프록시, 크롤러 실패의 지름길, 유료 프록시가 필수인 7가지 기술적 이유