flexsearch icon indicating copy to clipboard operation
flexsearch copied to clipboard

how can I use flexsearch in my next project?

Open imhalid opened this issue 2 years ago • 7 comments

import FlexSearch from 'flexsearch'

const index = FlexSearch.create({
  encode: 'icase',
  tokenize: 'forward',
  depth: 3,
})

image

I want to add a search feature for a document project.

where am I making a mistake now

imhalid avatar Feb 09 '23 05:02 imhalid

same problem :/

productdevbook avatar Feb 15 '23 16:02 productdevbook

Same here, using vite

Internal server error: __vite_ssr_import_0__.default.create is not a function

howesteve avatar Feb 19 '23 18:02 howesteve

same here

hunght avatar Feb 25 '23 07:02 hunght

I think this is the same problem as #341. See my comment in #333 for an explanation.

hanneskuettner avatar Feb 28 '23 19:02 hanneskuettner

import { Index } from 'flexsearch'

export function buildIndex(data) {
  const index = new Index({
    charset: 'latin:extra',
    tokenize: 'full',
    resolution: 9,
    cache: true,
  })

  data.forEach((posts, i) => {
    const pattern = posts.content
    index.add(i, pattern)
  })
  return index
}

I solved my problem by doing it this way.

imhalid avatar Mar 06 '23 05:03 imhalid

Whats the point of getting the best performance library which just can't work with ESM.

ShivamJoker avatar Mar 28 '23 08:03 ShivamJoker

This is what i had to do to get it to work:

import Flexsearch from "flexsearch";

const Index= Flexsearch.Index ?? Flexsearch;
const index = Index({
  tokenize: 'forward',
});

...

bmccorm2 avatar Jul 20 '23 19:07 bmccorm2