Giter Site home page Giter Site logo

Comments (15)

ts-thomas avatar ts-thomas commented on May 5, 2024 4

@georgyfarniev thanks for your help @Haqverdi I will take a look into it

from flexsearch.

brunohkbx avatar brunohkbx commented on May 5, 2024 3

Any updates on this?

from flexsearch.

jer-sen avatar jer-sen commented on May 5, 2024 2

One can also rebuild the dist files by changing the browser entry in package.json from
"browser": "dist/flexsearch.min.js",
to
"browser": "flexsearch.js",

from flexsearch.

yaneq avatar yaneq commented on May 5, 2024 2

This seems to be working with the standard npm package without modifications

typescript:

const FlexSearch = require('flexsearch/flexsearch.js')
import { Index } from 'flexsearch'

const index: Index<string> = FlexSearch.create()
// [...]

javascript:

const FlexSearch = require('flexsearch/flexsearch.js')

const index = FlexSearch.create()
// [...]

from flexsearch.

Haqverdi avatar Haqverdi commented on May 5, 2024 1

Yes, of course, I tried in the environment of nodejs, it works fine there, when I want to use it with the react native, the problem arises in the initialization stage, even when only import is done without use

undefined is not an object (evaluating 'v.define')
<unknown>
    flexsearch.min.js:8:41
<unknown>
    flexsearch.min.js:8:170
loadModuleImplementation
    require.js:331:6
<unknown>
    searchTest.js:3
loadModuleImplementation
    require.js:331:6
<unknown>
    Search.js:17
loadModuleImplementation
    require.js:331:6
<unknown>
    Navigation.js:16
loadModuleImplementation
    require.js:331:6
<unknown>
    App.js:3
loadModuleImplementation
    require.js:331:6
<unknown>
    index.js:7
loadModuleImplementation
    require.js:331:6
guardedLoadModule
    require.js:197:45
global code
    <unknown file>:0

code example:

import FlexSearch from 'flexsearch';
import { Sureler } from '../data/Sureler';

const index = new FlexSearch({
  encode: 'balance',
  tokenize: 'forward',
});

export function initFlex() {
  for (const key in Sureler) {
    const element = Sureler[key].az;
    index.add(key, element.join(' '));
  }
}
/**
 * @param {String} key
 * @returns {Array} returns search results
 */
export function flexS(key) {
  index.search(key, 15, result => result);
}

from flexsearch.

jer-sen avatar jer-sen commented on May 5, 2024 1

Doesn't work for me.
A workaround is to replace this by window near the end of file /dist/flexsearch.min.js.

from flexsearch.

id13 avatar id13 commented on May 5, 2024 1

To anyone using react-native, and wanting to leverage this library, the “window workaround” still works as of today.
Look at the last characters of the min.js file and replace

onmessage=W;return K[w][P]}}()),w); by onmessage=W;return K[w][P]}}()),window);

Many thanks to the contributors for this impressive package 😄

from flexsearch.

georgyfarniev avatar georgyfarniev commented on May 5, 2024

@Haqverdi, can you please share details about your issue? Code example, error log, etc.

from flexsearch.

georgyfarniev avatar georgyfarniev commented on May 5, 2024

@Haqverdi not sure if it helps, but have you tried import * as FlexSearch from ‘flexsearch’?

from flexsearch.

Haqverdi avatar Haqverdi commented on May 5, 2024

Yes, I also tried it so it did not work either, but when I downloaded and used a non-minified version I took it from the source so it worked, may be problem with minified version
** edit
i tested and minified myself source code and it worked too, so problem with minify version - that's for sure

from flexsearch.

georgyfarniev avatar georgyfarniev commented on May 5, 2024

@Haqverdi then something wrong with custom compile script probably. @ts-thomas may help with this.

from flexsearch.

gotenxds avatar gotenxds commented on May 5, 2024

Just stumbled across here but the issue seems to be that if you
import * as FlexSearch from 'flexsearch'
You will try and import the nodejs version of the library, instead just do this:
import FlexSearch from 'flexsearch/dist/flexsearch.min';

from flexsearch.

saurabhinfoworks avatar saurabhinfoworks commented on May 5, 2024

@ts-thomas can we see any fix for this but in near future. I am trying to use flexsearch with npm and similar issue i am facing with minified version of the file. defined is undefined. as soon as i add require, it throws this error in browser.

from flexsearch.

georgyfarniev avatar georgyfarniev commented on May 5, 2024

@brunohkbx, it looked promising, but seems abandoned now. I already figured out how to work with elasticsearch (for my case)

from flexsearch.

ts-thomas avatar ts-thomas commented on May 5, 2024

Please change over to the version >= 0.7.x, thanks a lot.

from flexsearch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.