-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BooleanFacet does not work with Elasticsearch connector #851
Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Here is a workaround for the async onSearch(requestState, queryConfig) {
const response = await fetch("/api/search", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
requestState,
queryConfig,
}),
});
const { facets, ...rest } = await response.json();
/**
* Alter incoming facet data as a workaround for @elastic/search-ui issue.
* See https://github.com/elastic/search-ui/issues/851
*/
const alteredFacets = {
...facets,
...Object.fromEntries(
Object.entries(facets)
// Only process facets starting with "is".
// Change this to suit the boolean field naming in your index!
.filter(([facetName]) => facetName.startsWith("is"))
.map(([facetName, facetValues]) => [
facetName,
facetValues?.map((facetValue) => ({
...facetValue,
data:
facetValue.data?.map((item) => {
// Map 0, 1 values to "false" and "true" strings.
if (item.value === 0) return { ...item, value: "false" };
if (item.value === 1) return { ...item, value: "true" };
return item;
}) ?? [],
})) ?? [],
])
),
};
return {
...rest,
facets: alteredFacets,
};
} |
@MarttiR Thanks for posting this workaround, spent a while trying to get to the bottom why my boolean facets weren't working! Hoping the workaround can be removed in a future release. |
Describe the bug
See discussion here. https://discuss.elastic.co/t/search-ui-issues-with-elastic-search-connector-and-boolean-aggregations/312183/2
The BooleanFacet component does not work correctly with the Elasticsearch connector, because it's use of 0/1 values instead of true/false.
The text was updated successfully, but these errors were encountered: