elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
865 stars 24.81k forks source link

top_hits, date_histogram : allow not serializing some of the fields. #7350

Closed shanielh closed 10 years ago

shanielh commented 10 years ago

Hi.

I would like not to get some of the fields from the response of an API request, since it's killing my CPU time at deserialization of the JSON in the client, I commented the fields that I don't want to receive, Is it possible?

First aggregation is date_histogram, inner aggregation is top_hits, What i've tried to do is to take the last value from every 30 minutes within a date range.

{
   "took" : 21,
   "timed_out" : false,
   "_shards" : {
     "total" : 5,
     "successful" : 5,
     "failed" : 0
   },
   "hits" : {
     "total" : 1715,
     "max_score" : 0.0,
     "hits" : [ ]
   },
   "aggregations" : {
     "my_agg" : {
       "buckets" : [ {
         //"key_as_string" : "2014-08-20T12:00:00.000Z",
         "key" : 1408536000000,
         //"doc_count" : 64,
         "found_hits" : {
           "hits" : {
             // "total" : 64,
             // "max_score" : null,
             "hits" : [ {
               //"_index" : "feed_history",
               // "_type" : "feed_history",
               // "_id" : "de1ea495-13d1-422d-ad44-a96fb0c36af8",
               // "_score" : null,
               "_source":{"value":1.30655,"relatedId":2,"serverTime":"2014-08-20T12:29:59.4410307Z"},
               // "sort" : [ 1408537799441 ]
             } ]
           }
         }
       }, ... ]
     }
   }
 }
clintongormley commented 10 years ago

The key_as_string will no longer be shown by default, thanks to https://github.com/elasticsearch/elasticsearch/pull/6830

Discussion is happening about removing the metadata. See https://github.com/elasticsearch/elasticsearch/issues/2149

shanielh commented 10 years ago

Thanks. Closing due to duplication.