kbrsh/wade

Searching for "this" returns arbitrary results

Closed this issue · 2 comments

Hello @kingpixil

Here’s a simplified test case that hopefully clarifies the issue:

const wade = require("wade");

const data = ["George", "John", "Ringo", "Paul"];
const search = wade(data);

const results = search("this").map(({ index }) => data[index]);
console.log(results); //  ["george", "john", "ringo", "paul"]

Expected behaviour
search("this") returns an empty array and does not mutate the data array.

Actual behaviour
search("this") returns a mutated version of the data array.

Platforms:

  • Windows 10
  • node 8.1.3
  • Chrome 56.0.2924.87
kbrsh commented

Ahh, the problem here is that the data is being run through Wade's preprocessor, making all letters lowercase, removing punctuation, and removing stop words. This is the same process done for search queries (causing the query to be empty, resulting in all items being returned).

Right now the expected behavior is that the data is preprocessed and the array is mutated, although I guess this isn't the best behavior. I'm working on a new version now.

kbrsh commented

Fixed in v0.3.1