Elasticsearch는 강력한 풀 텍스트 검색 기능을 제공하며, 다양한 쿼리 방식이 있습니다.
주요 쿼리 종류
match_all: 전체 문서 검색
match: 부분 일치 검색 (OR / AND 조건 가능)
match_phrase: 순서 포함 정확한 구문 검색
query_string: 복잡한 검색 연산자 지원
예제 데이터 입력
my_index 인덱스에 _bulk API를 사용하여 데이터 입력
POST my_index/_bulk
{"index":{"_id":1}}
{"message":"The quick brown fox"}
{"index":{"_id":2}}
{"message":"The quick brown fox jumps over the lazy dog"}
{"index":{"_id":3}}
{"message":"The quick brown fox jumps over the quick dog"}
{"index":{"_id":4}}
{"message":"Brown fox brown dog"}
{"index":{"_id":5}}
{"message":"Lazy jumping dog"}
message 필드에 다양한 단어가 포함된 문서 5개 입력됨
match_all 쿼리 (모든 문서 검색)
✅ 쿼리 없이 실행하면 match_all 적용
GET my_index/_search
✅ 명시적으로 match_all 사용
GET my_index/_search
{
"query": {
"match_all": {}
}
}