상황 : 특정필드도 존재해야되고, 값도 존재하는 데이터를 찾고싶다
chat GTP Q : Validate the presence of values in the field in ElasticSearch
GET /my_index/_search
{
"query": {
"exists": {
"field": "찾고자하는 필드"
}
}
}
query문의 exists를 사용하여 특정필드의 존재여부를 확인할 수 있다.
첨언으로
match
or term
query instead.match
or term
조회를 사용할 수 있습니다라고 답해주었다.
chat GTP Q : Then show me an example using match.
GET /my_index/_search
{
"query": {
"match": {
"my_field": "example"
}
}
}
위의 두 질문을 합하여 원하는 쿼리인 필드존재 여부 & 특정값 존재여부를 찾고자 한다