*Hi kazoompa,*

*Suppose I have below Data in index=cars and type=transactions*
[
  {
    "price": 20000,
    "color": "red",
    "make": "honda",
    "sold": "2014-11-05"
  },
  {
    "price": 12000,
    "color": "green",
    "make": "toyota",
    "sold": "2014-08-19"
  },
  {
    "price": 80000,
    "color": "red",
    "make": "bmw",
    "sold": "2014-01-01"
  },
  {
    "price": 20000,
    "color": "red",
    "make": "honda",
    "sold": "2014-11-05"
  },
  {
    "price": 30000,
    "color": "green",
    "make": "ford",
    "sold": "2014-05-18"
  },
  {
    "price": 15000,
    "color": "blue",
    "make": "toyota",
    "sold": "2014-07-02"
  },
  {
    "price": 10000,
    "color": "red",
    "make": "honda",
    "sold": "2014-10-28"
  },
  {
    "price": 25000,
    "color": "blue",
    "make": "ford",
    "sold": "2014-02-12"
  },
  {
    "price": "50000",
    "color": "yellow",
    "make": "Maruti",
    "sold": "2014-10-11"
  }
]

Now I am Querying for getting aggregate data based on date_range, like 
below**


    "aggs": {
            "range": {
                "date_range": {
                    "field": "sold",
                    "ranges": [
                        {  "from": "2014-11-01", "to": "2014-11-30" }
                    ]
                }
            }
        }
 i.e. date range from 1st nov to 30th nov , for this I am getting this 
output

 
 "aggregations": {
        "range": {
          "buckets": [
            {
              "key": "2014-11-01T00:00:00.000Z-2014-11-30T00:00:00.000Z",
              "from": 1414800000000,
              "from_as_string": "2014-11-01T00:00:00.000Z",
              "to": 1417305600000,
              "to_as_string": "2014-11-30T00:00:00.000Z",
              "doc_count": 2
            }
          ]
        }
      }

from output I am getting that I have two data(doc_count) which come under 
this range,ok

But if i have required those data which satisfies this condition or range 
like below

  {
    "price": 20000,
    "color": "red",
    "make": "honda",
    "sold": "2014-11-05"
  }

 {
    "price": 20000,
    "color": "red",
    "make": "honda",
    "sold": "2014-11-05"
  }

What I have required to do for this????please help???

On Thursday, November 6, 2014 8:27:05 AM UTC+5:30, kazoompa wrote:
>
> What do you mean by " I have also required complete aggregate data", you 
> result is based on the type of the aggregation you use.
>
> may be you can elaborate more.
>
> Ramin
>
> On Monday, November 3, 2014 11:33:55 PM UTC-5, Rajit Garg wrote:
>>
>> **I am Querying for getting aggregate data based on date_range, like 
>> below**
>>
>>     "aggs": {
>>             "range": {
>>                 "date_range": {
>>                     "field": "sold",
>>                     "ranges": [
>>                         {  "from": "2014-11-01", "to": "2014-11-30" },
>>                         {  "from": "2014-08-01", "to": "2014-08-31" } 
>>                     ]
>>                 }
>>             }
>>         }
>>
>>
>> **using this I am getting this response**
>>
>>
>>  
>>
>>     "aggregations": {
>>         "range": {
>>           "buckets": [
>>             {
>>               "key": "2014-08-01T00:00:00.000Z-2014-08-31T00:00:00.000Z",
>>               "from": 1406851200000,
>>               "from_as_string": "2014-08-01T00:00:00.000Z",
>>               "to": 1409443200000,
>>               "to_as_string": "2014-08-31T00:00:00.000Z",
>>               "doc_count": 1
>>             },
>>             {
>>               "key": "2014-11-01T00:00:00.000Z-2014-11-30T00:00:00.000Z",
>>               "from": 1414800000000,
>>               "from_as_string": "2014-11-01T00:00:00.000Z",
>>               "to": 1417305600000,
>>               "to_as_string": "2014-11-30T00:00:00.000Z",
>>               "doc_count": 2
>>             }
>>           ]
>>         }
>>       }
>>
>> **but instead of only doc_count, I have also required complete aggregate 
>> data that satisfy this range,
>> is threre any way to get this..please help**
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/8a51d4f1-c848-41eb-a221-ed546ab14129%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to