fadion / Bouncy

Map Elasticsearch results to Eloquent models
MIT License
71 stars 26 forks source link

aggregations #22

Open yaofong opened 8 years ago

yaofong commented 8 years ago

Hi everyone,

Can anyone show me how to get aggregations?

I tried to pass in 'aggs' into params but the response never return the aggregations

$params = [
            'query' => [
                'filtered' => [
                    'query' => $where
                ],
            ],
            'sort' => [
                ['id' => ['order' => 'desc']],
                ['rating' => ['order' => 'desc']],
                '_score'
            ],
            'highlight' => [
                'fields' => [
                    'title' => new \stdClass
                ]
            ],
            'aggs' => [
                'loc_meet_types' => [
                    'terms' => [
                        'field' => 'loc_meet_type'

                    ],
                ]
            ],
            'track_scores' => true
        ];

the response always the same no matter i add aggs or remove aggs :+1:

array:7 [▼
  "per_page" => 20
  "current_page" => 1
  "next_page_url" => null
  "prev_page_url" => null
  "from" => 1
  "to" => 10
  "data" => array:10 [▼
    0 => array:40 [▶]
    1 => array:40 [▶]
    2 => array:40 [▶]
    3 => array:40 [▶]
    4 => array:40 [▶]
    5 => array:40 [▶]
    6 => array:40 [▶]
    7 => array:40 [▶]
    8 => array:40 [▶]
    9 => array:40 [▶]
  ]
]

p.s I'm using aws ElasticSearch with version 1.5.3

1034190174 commented 5 years ago

as same as u