flexsearch: Multi-fields search in documents is not working

Hi,

Following the doc this sample code should work but it yields an empty array. Any clues about what is done wrong?

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

var index = new Document({
  document: {
    id: "id",
    index: ["title"]
  }
});

index.add({
  id: 0,
  title: "I am a test"
});
index.add({
  id: 1,
  title: "I am also a test"
});

var result = index.search([
  {
    field: "title",
    query: "test"
  },
  {
    field: "title",
    query: "also"
  }
]);
console.log(`result`, JSON.stringify(result));

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

@theguy147 do you have any idea how this works with {enrich: true}? I feel like there’s another bug 😃

Update: @ts-thomas just merged the fix into master, so it should be fixed if you’re on current master now

I think the stable production version should not make such low-level mistakes

@micheljung I had thought about opening a PR but because I didn’t know if my fix is good enough I thought explaining what the problem is and what could be changed might be just as good. I did anyway open that PR now and referenced this issue for the details.

@GanserITService Yes, as @micheljung said, I am not a contributor in this project and therefore have no say in this 😉 Hopefully soon 😃