fergiemcdowall / search-index

A persistent, network resilient, full text search library for the browser and Node.js
MIT License
1.39k stars 149 forks source link

No results found after upgrading from 2.4.0 to 3.0.2 #572

Closed tonprince closed 2 years ago

tonprince commented 2 years ago

Hi I tried to update search-index to the newest release with version 3.0.2 but do not get any results for my query anymore.

import si from 'search-index';

test();

async function test() {
  const { PUT, QUERY } = await si({ name: ".test" });

  let data = { destinations: ["phuket town"] };
  await PUT([data]);

  let results = await QUERY({ FIELD: "destinations", VALUE: "phuket town" });
  console.log(JSON.stringify(results));
} 

I have a list of destinations like "phuket town", "southern thailand" etc. for which I create an index for. When querying the index for "phuket town" no results are returned. Before it worked fine.

tonprince commented 2 years ago

Actually I had to change the query to: { AND: ["destinations:phuket", "destinations:town"] }

Is it possible to search by "phuket town" somehow? Otherwise I have to change many query definitions.

fergiemcdowall commented 2 years ago

Does { AND: ["phuket", "town"] } give any hits? (I think it should)

If so maybe like this?: { AND: 'phuket town'.split(' ') }

tonprince commented 2 years ago

Could finally rewrite it, thanks.