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라는 단어는 빼고 검색합니다.
참고사이트
- 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: