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 in the intersect function #170

Open
simonquest opened this issue Nov 20, 2017 · 2 comments
Open

bug in the intersect function #170

simonquest opened this issue Nov 20, 2017 · 2 comments
Labels
Milestone

Comments

@simonquest
Copy link

There is a small bug in the getIntersection function used for filtering results: the two input arrays don't get sorted correctly if arrays contain numeric values as javascript sort function sorts alphabetically. This will affect searches involving multiple tokens.

I suggest sorting array like this

.sort((a, b) => (a - b));

@cimbul
Copy link

cimbul commented May 18, 2018

This should be fixed by #159, if someone can merge it in.

Note to anyone else encountering this: the workaround for us was to coerce the IDs to a string. Something like this:

var engine = new Bloodhound({
  identify: function(datum) {
    return datum.id + "";
  },
});

This will make the > and < comparisons in getIntersection() consistent with the Array#sort() ordering.

@jlbooker jlbooker added the bug label May 22, 2018
@jlbooker jlbooker added this to the v1.2.0 milestone May 22, 2018
@ezr-ondrej
Copy link

? :)

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

No branches or pull requests

4 participants