Closed msabramo closed 2 years ago
The problem is that aggregations
in the Elasticsearch response looks like this:
and "true"
and "false"
are what are used in the app code:
<SingleDataList
componentId="favorites"
dataField="favorite"
title="Favorite"
showRadio={true}
showCount={true}
showSearch={false}
data={[
{ label: "Favorite", value: "true" },
{ label: "Not favorite", value: "false" },
]}
/>
The problem is the app code is using "true"
and "false"
for the value but the code in SingleDataList.js
is looking only at key
(and not key_as_string
) in the ES response and the values for key
are 0
and 1
.
(Note that I tried changing the app code to use 0
and 1
for the value
s in data
and that makes the counts work, but it breaks the search results themselves, which is a much worse problem)
So my thought is that maybe it's better for the code in SingleDataList.js
to look at both key
and key_as_string
in the ES response, which is what I did in #1798.
Affected Projects React (
@appbaseio/reactivesearch
)Library Version: x.y.z 3.24.3 (
@appbaseio/reactivesearch@3.24.3
)Describe the bug The
showCount
feature ofSingleDataList
(originally added in https://github.com/appbaseio/reactivesearch/pull/658) doesn't render counts for fields of typeboolean
.To Reproduce
Genre
filter properly shows counts.Favorite
filter does not show counts.Expected behavior The
Favorite
filter should show the counts next toFavorite
andNot favorite
.Screenshots
Desktop (please complete the following information): N/A
Smartphone (please complete the following information): N/A
Additional context The data for this codesandbox.io demo is hosted at: https://6692428591fa:c8d5ae7e-8625-410c-97d8-ce19c3708edd@reactivesearch-test-ceyfyhm-arc.searchbase.io/reactive-search-test-1/_search
From https://reactivesearch-test-ceyfyhm-arc.searchbase.io/reactive-search-test-1, you can see the follow field types:
In particular, note that the field
favorite
is of typeboolean
.