참고
https://oboki.net/workspace/data-engineering/elasticsearch/elasticsearch-index-template/
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html
https://esbook.kimjmin.net/
https://unuseful.tistory.com/21
쿼리 짜기.. 😂
된다고 넘어가지 말고 이해하고 짜자..
_score
점수가 높을수록 문서 관련성이 높아짐.query context
: 점수 계산함. “How well does this document match this query clause?” > match 잘 하고 있니? 얼마나 일치하는지 평가하는데 사용. 유사 검색 (문자 검색)filter context
: 점수 계산하지 않음. “Does this document match this query clause?” > match 하니? 안 하니? 일치하는 문서를 걸러내지만 _score
에 영향을 주지 않음. 정확한 검색.// title 필드에 Search가 포함되고, content는 Elasticsearch가 포함 된 것
// status가 published이고 publish_date가 2015-01-01 이후인 것
GET /_search
{
"query": {
<!-- bool & match > query context -->
"bool": {
"must": [
{ "match": { "title": "Search" }},
{ "match": { "content": "Elasticsearch" }}
],
<!-- fitler > filter context -->
"filter": [
{ "term": { "status": "published" }},
{ "range": { "publish_date": { "gte": "2015-01-01" }}}
]
}
}
}
query context
filter context
query context
filter context
term
match