nextapps-de / flexsearch

Next-Generation full text search library for Browser and Node.js
Apache License 2.0
12.53k stars 491 forks source link

Document Search does not return any result if only `enrich` option is set #223

Closed 13ogrammer closed 3 years ago

13ogrammer commented 3 years ago

I am unable to get search results on Documents when only enrich: true option is set.

Here is the code I am using to test this:

var { Document } = require(`flexsearch`);

var index = new Document({
  id: "objectID",
  index: ["firstname", "lastname"],
  store: true
});

index.add({
  firstname: "Jimmie something",
  lastname: "Barninger",
  objectID: "myID1"
});
index.add({
  firstname: "Warren",
  lastname: "jimmie",
  objectID: "myID2"
});

var result = index.search("jimmie", { enrich: true });
console.log(`result`, JSON.stringify(result));
// result [] 

var resultWithIndex = index.search("jimmie", {
  index: "firstname",
  enrich: true
});
console.log(`result`, JSON.stringify(resultWithIndex));
// result [{"field":"firstname","result":[{"id":"myID1","doc":{"firstname":"Jimmie something","lastname":"Barninger","objectID":"myID1"}}]}] 

Here is the link to codesandbox: https://codesandbox.io/s/flexsearch-search-tests-2quf3

ts-thomas commented 3 years ago

Thanks for the report. This bug is now fixed in 0.7.1

13ogrammer commented 3 years ago

Thanks @ts-thomas