일래스틱서치 검색시, 개수만 구하고 내용은 보고 싶지 않을 때가 있다. 이 때는 size 매개변수 값을 0으로 설정하면 쉽게 결과를 볼 수 있다. size 매개변수를 전달하지 않으면 기본 값인 10이 전달되어 결과 값을 다 봐야 한다. 속도를 조금이나, 구구절절한 내용을 안보려면 size 매개변수를 활용하는 것도 좋을 것 같다. 



curl -XGET http://search.google.com:9200/index_name/type_name/_search?pretty=true\&size=0 -d '{

  "query": {

    "filtered": {

      "query": {

        "match_all": {}

      },

      "filter": {

        "range": {

          "@timestamp": {

            "from": "now-31d/d",

            "to": "now-1d/d"

          }

        }

      }

    }

  }

}'

<결과>

{

  "took" : 5,

  "timed_out" : false,

  "_shards" : {

    "total" : 20,

    "successful" : 20,

    "failed" : 0

  },

  "hits" : {

    "total" : 184821,

    "max_score" : 0.0,

    "hits" : [ ]

  }

}






Posted by '김용환'
,