Skip to content
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

bug with selected value for boolean facet #119

Open
SergeyRe opened this issue Aug 16, 2022 · 3 comments
Open

bug with selected value for boolean facet #119

SergeyRe opened this issue Aug 16, 2022 · 3 comments

Comments

@SergeyRe
Copy link
Contributor

SergeyRe commented Aug 16, 2022

to reproduce:

const data = [{ "boolean": true, "string": "true" }]
const itemsjs = require('itemsjs')(data, {
    aggregations: {
        boolean: {},
        string: {}
    }
});

const aggs = itemsjs.search({
    filters: {
        boolean: [true],
        string: ["true"]
    }
}).data.aggregations

console.log(aggs.boolean.buckets, aggs.string.buckets)

//[{ key: 'true', doc_count: 1, selected: false }][{ key: 'true', doc_count: 1, selected: true }]`

for comparison there 2 fields : boolean and string . Both are aggregations and search made under both of them
in first case we have "selected:false" for boolean ( looks like a bug) and "selected:true" for string ( its OK)

@mulquin
Copy link
Contributor

mulquin commented Aug 16, 2022

This is happening because of line 370 in helpers.js.

Currently to check if something is selected, filters.indexOf(v2[0]) !== -1 is used.

v2[0] is the result of lodash chain().toPairs().map() but it is actually a string, so the indexOf above fails.

@cigolpl cigolpl added the bug label Aug 18, 2022
@cigolpl
Copy link
Member

cigolpl commented Mar 9, 2023

Thank you for bringing this issue. After reviewing the issue, I have determined that this is not a bug, but rather an improvement request. At this time, ItemsJS does not support boolean filters, but using strings can serve as a temporary workaround. Please let me know if this workaround is limiting you in any way

@cigolpl cigolpl added enhancement and removed bug labels Mar 9, 2023
@SergeyRe
Copy link
Contributor Author

Yes. Its actually not big trouble at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants