Comments (15)
@georgyfarniev thanks for your help @Haqverdi I will take a look into it
from flexsearch.
Any updates on this?
from flexsearch.
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.
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.
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.
Doesn't work for me.
A workaround is to replace this
by window
near the end of file /dist/flexsearch.min.js
.
from flexsearch.
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.
@Haqverdi, can you please share details about your issue? Code example, error log, etc.
from flexsearch.
@Haqverdi not sure if it helps, but have you tried import * as FlexSearch from ‘flexsearch’
?
from flexsearch.
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.
@Haqverdi then something wrong with custom compile script probably. @ts-thomas may help with this.
from flexsearch.
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.
@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.
@brunohkbx, it looked promising, but seems abandoned now. I already figured out how to work with elasticsearch (for my case)
from flexsearch.
Please change over to the version >= 0.7.x, thanks a lot.
from flexsearch.
Related Issues (20)
- RangeError: Invalid string length HOT 2
- How to import Document in nodejs with ESNext modules (typescript)?
- Invalid regular expression
- Suggestion and tokenize "forward"
- Webpack cannot resolve flexsearch HOT 1
- `IndexOptions` TS interface is missing some options HOT 1
- Current NPM package is stale HOT 2
- Cloning of flexsearch objects
- new Document causes `.default is not a constructor` error HOT 1
- Benchmark link is broken HOT 1
- Setting a string as "encode" doesn't work (confusing document?)
- How to return context (+ or - few lines) around the hits of given search text
- Enriched document search showing duplicate results
- I have a question about how the results are sorted
- Do not force string in Index#add() when custom encoder
- "Document Indexes" link in readme is broken
- Typo in cdn link
- TypeScript doesn't allow omitting id from the document descriptor while the README says it is allowed
- document search option "pluck" is rejected by TypeScript
- Some documents may appear multiple times in the search result
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexsearch.