Problems with aggregations filtering


(Davide) #1

Hi everyone,
I'm trying to implement (using elastic php lib) a group by of 5 fields, filtering for some conditions and next ordering the result. Obviously I need to retrieve a set of all objects.
I think i'm wrong because the order doesn't acts on the result set but on the single aggregation, and I'm not getting back from elastic a single set of object but a set for each aggregation.

Someone can help me please? This is the params I pass to php elastic search function:

{  
   "index":"test",
   "type":"test",
   "body":{  
      "aggs":{  
         "group_by_code":{  
            "terms":{  
               "field":"code.keyword"
            },
            "aggs":{  
               "group_by_article":{  
                  "terms":{  
                     "field":"article.keyword"
                  },
                  "aggs":{  
                     "group_by_color":{  
                        "terms":{  
                           "field":"color.keyword"
                        },
                        "aggs":{  
                           "group_by_attr":{  
                              "terms":{  
                                 "field":"attr.keyword"
                              },
                              "aggs":{  
                                 "top_hits_agg":{  
                                    "top_hits":{  
                                       "sort":[  
                                          {  
                                             "date.keyword":"desc",
                                             "number.keyword":"asc",
                                             "code.keyword":"desc",
                                             "code_2.keyword":"asc"
                                          }
                                       ],
                                       "size":1
                                    }
                                 }
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }
   }
}

(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.