flexsearch icon indicating copy to clipboard operation
flexsearch copied to clipboard

Enrich search not working (typescript)

Open jonasbetareader opened this issue 3 years ago • 0 comments

I'm trying to retrieve enriched documents from the Document index, but only getting the non-enriched id back.

Example code:

import { Document } from 'flexsearch';

type TestDocument = {
  foo: number;
  bar: string;
}

const docIndex = new Document<
      TestDocument,
      true
    >({
      document: {
        id: 'foo',
        store: true,
      },
    });

docIndex.add({ foo: 1, bar: 'test-document' });

console.log(docIndex.search<true>(1));

The above results in the following result:

Array [
  Object {
    "field": "foo",
    "result": Array [
      "1",
    ],
  },
]

I would have expected something like the following: Array [ Object { "field": "foo", "result": Array [ { foo: 1, bar: 'test-document' }, ], }, ]

Am I missing or misunderstanding something? Using "flexsearch: "^0.7.21", and "@types/flexsearch": "^0.7.3",

jonasbetareader avatar Jun 09 '22 06:06 jonasbetareader