App Search group by multiple fields

Hi !

Is it possible to group by multiple fields with App Search API ?

Such as :

  "group": {
    "field": "states", "towns"

like an sql query.
it's a common need but I can't find it anywhere as an example.

Thanks you in advance for your answer

Hi @StevenMartins ,

Today, App Search does not have a group-by API. If you have a support relationship with Elastic, you can ask them to file this as an Enhancement Request.

As a work around, since 8.2, App Search has added some support for the Elasticsearch API to query your documents. See: Elasticsearch search for App Search Guide | Elastic App Search Documentation [8.3] | Elastic

From there, you can use Elasticsearch's Aggregations syntax to create your group-by.

Hi @Sean_Story ,

To explain my request, I use App search to be able to search destinations, I use this API -> Search API group with the group by destination : It's works well.
Then when I select a destination I have to find the associated accommodations. I was thinking of using

"group": {
    "field": "destination", "accommodations"

but it's impossible.

Your workaround seems quite complex for my needs. Maybe I'm wrong in the way I use the app search api...

Hi @StevenMartins ,

It's not that you're misusing the API, it's just that the API doesn't have a fully expressive "group by" API like you're wanting - it can only group on the one field. If you want more complex aggregations, you'll need to use the Elastcsearch API, or you'll need to file an Enhancement Request and wait for us to implement your ask.

Sorry I can't get you the exact capabilities you'd like!

Anyway thanks you for your reactivity @Sean_Story :slight_smile:

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