Updated:

1 minute read

Query

  • score를 계산


Filter

  • score를 계산하지 않음
  • 상황에 따라 성능 향상 가능


예제

  • 데이터
     POST test/_bulk
     {"index":{"_id":"1"}}
     {"text":"aaa"}
     {"index":{"_id":"2"}}
     {"text":"aaa bbb "}
    
  • Query
    • 요청
       GET test/_search
       {
       "query": {
         "match": {
           "text": "aaa"
         }
       }
       }
      
    • 응답
       {
       "took" : 0,
       "timed_out" : false,
       "_shards" : {
         "total" : 1,
         "successful" : 1,
         "skipped" : 0,
         "failed" : 0
       },
       "hits" : {
         "total" : {
           "value" : 2,
           "relation" : "eq"
         },
         "max_score" : 0.21110919,
         "hits" : [
           {
             "_index" : "test",
             "_type" : "_doc",
             "_id" : "1",
             "_score" : 0.21110919,
             "_source" : {
               "text" : "aaa"
             }
           },
           {
             "_index" : "test",
             "_type" : "_doc",
             "_id" : "2",
             "_score" : 0.160443,
             "_source" : {
               "text" : "aaa bbb "
             }
           }
         ]
       }
       }
      
  • Filter
    • 요청
       GET test/_search
       {
       "query": {
         "bool": {
           "filter": [
         {
               "match": {
                 "text": "aaa"
               }
             }
           ]
         }
       }
       }
      
    • 응답
       {
       "took" : 0,
       "timed_out" : false,
       "_shards" : {
         "total" : 1,
         "successful" : 1,
         "skipped" : 0,
         "failed" : 0
       },
       "hits" : {
         "total" : {
           "value" : 2,
           "relation" : "eq"
         },
         "max_score" : 0.0,
         "hits" : [
           {
             "_index" : "test",
             "_type" : "_doc",
             "_id" : "1",
             "_score" : 0.0,
             "_source" : {
               "text" : "aaa"
             }
           },
           {
             "_index" : "test",
             "_type" : "_doc",
             "_id" : "2",
             "_score" : 0.0,
             "_source" : {
               "text" : "aaa bbb "
             }
           }
         ]
       }
       }