appbaseio / appbaseio/reactivesearch

[Lists] Count top-level documents instead of nested documents when using nestedField

Abierto
#1,392 1 comentario 2 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
JavaScript
Estrellas
4.9k
Forks
478
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**Affected Projects**
React / All

**Is your feature request related to a problem? Please describe.**
Nested fields count is based on nested documents. Would be great to have a way to switch it to count on the top-level document. This would apply to all lists with a count.

Example:
```
bookshelf1.books : [
{ book1: {author: "John Doe} },
{ book2: {author: "Rick Doe} },
{ book3: {author: "John Doe} },
],
bookshelf2.books : [
{ book1: {author: "Jane Doe} },
{ book2: {author: "Jane Doe} },
{ book3: {author: "John Doe} },
]
```
Currently, if filtering on `bookshelf.books.author`, one would get the following counts on "books":
```
John Doe 3
Jane Doe 2
Rick Doe 1
```
would be great to be able to switch to a count on "bookshelf":
```
John Doe 2
Jane Doe 1
Rick Doe 1
```

Ultimately, the results returns (unless using `inner_hits`) are based on the top-level document (`bookshelf`) in this example. Therefore, I think it feels more natural to display the count on them in many cases.

**Describe the solution you'd like**
One way would be to add a boolean prop e.g `reverseNestedCount` which would then change the aggregation method. To my knowledge there is currently no way to modify the aggregation used for counting but I could be wrong (?).

In ES, this would be achieved using a [reverse nested aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-reverse-nested-aggregation.html).

**Describe alternatives you've considered**
I guess the alternative would be to write a component from scratch

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.