appbaseio / appbaseio/reactivesearch

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

Offen
#1,392 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
enhancement
Vorherrschende Sprache
JavaScript
Sterne
4.9k
Forks
478
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**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

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.