flexsearch icon indicating copy to clipboard operation
flexsearch copied to clipboard

FlexSearch v0.7.0 (Beta is now available)

Open ts-thomas opened this issue 3 years ago • 9 comments

FlexSearch v0.7.0 (Beta)

Beta is now available. Please test the new version and post back issues and suggestions. The Beta will pushed to the master branch in 2 weeks.

Read the documentation of new features and changes:
https://github.com/nextapps-de/flexsearch/blob/0.7.0/doc/0.7.0.md

Read the documentation of new language encoding features:
https://github.com/nextapps-de/flexsearch/blob/0.7.0/doc/0.7.0-lang.md

Source Code v0.7.0-beta available here:
https://github.com/nextapps-de/flexsearch/tree/0.7.0/src

Some of my questions are:

  • do we need ES5 support?
  • do you see any improvements about the naming of properties, members, methods etc.?
  • do you think the new result-set (document search) gives you more flexibility to process the results?
  • did you miss something fundamentally?

ts-thomas avatar May 19 '21 10:05 ts-thomas

I'm so happy to hear about 0.7.0 (Beta) 🥳 Couldn't resist to try it out instantly.

Sadly I'm unable to import via import Index from "flexsearch/src/index.js" (as described in https://github.com/nextapps-de/flexsearch/blob/0.7.0/doc/0.7.0.md) with Vue CLI 4.5.12 (Webpack 4.46.0 / Babel 7.13.16). The import seems to work, but there is the following Error at runtime (Chromium 90.0.4430.212):

Uncaught TypeError: Object(...) is not a function
    at Module../common/temp/node_modules/.pnpm/github.com+nextapps-de+flexsearch@e391e2bbd67044433e32f991c73b6ba1712283d4/node_modules/flexsearch/src/document.js (document.js:730)
    at __webpack_require__ (bootstrap:853)
    at fn (bootstrap:150)
    at Module../common/temp/node_modules/.pnpm/github.com+nextapps-de+flexsearch@e391e2bbd67044433e32f991c73b6ba1712283d4/node_modules/flexsearch/src/async.js (async.js:1)
    at __webpack_require__ (bootstrap:853)
    at fn (bootstrap:150)
    at Module../common/temp/node_modules/.pnpm/github.com+nextapps-de+flexsearch@e391e2bbd67044433e32f991c73b6ba1712283d4/node_modules/flexsearch/src/index.js (index.js:1)
    at __webpack_require__ (bootstrap:853)
    at fn (bootstrap:150)
    at src/store/search/actions.js (actions.js:1)

But I was able to import Flexsearch globally with import("flexsearch/dist/flexsearch.min.js");. But then i realized that the "lang" files are not part of 0.7.0/dist and I get the same error as posted above by importing import { encode } from "flexsearch/src/lang/latin/advanced.js";

Maybe it's a Vue CLI thing... I am eagerly awaiting further feedback from other users.

And regarding your questions: I don't need ES5 support. Will provide more feedback if I get 0.7.0 working.

boardend avatar May 19 '21 16:05 boardend

@boardend Thanks for your support. It looks like this line fail:

https://github.com/nextapps-de/flexsearch/blob/e391e2bbd67044433e32f991c73b6ba1712283d4/src/document.js#L730

apply_async is a function exported from async.js. Please try the latest commit, probably the issue is gone. But it's really strange that the function will export as an object.

ts-thomas avatar May 19 '21 17:05 ts-thomas

Updating to the latest commit (79fe061) didn't help...

The problem was the import of async.js which imports back document.js. So there is a circular dependency, which Webpack 4 seems unable to handle. (Did a test with a new Webpack 5.37.1 project according to the "Getting Started" guide which was working just fine with the latest commit of 0.7.0). Then nailed it down with a new Vue CLI Project with Webpack 4.46.0 (with and without Babel) which caused the same error as I got in my (rather complex) setup).

The PR https://github.com/nextapps-de/flexsearch/pull/218 will resolve this.

boardend avatar May 20 '21 06:05 boardend

Ok I understand. The imports are there because of the type definition. I will provide an replacement for this definition and this problem is fixed then.

ts-thomas avatar May 20 '21 10:05 ts-thomas

I got FlexSearch 0.7.0 working with Webpack 4 with the fix provided above, but then ran into more issues with circular module imports while trying to switch to the WorkerIndex with the Webpack worker-plugin: adapter.js > worker.js > index.js > serialize.js > document.js (and then back to adapter.js).

Below you find the output of npx madge --circular src/index.js:

index.js > cache.js
index.js > lang.js
index.js > serialize.js
index.js > serialize.js > document.js
index.js > lang/latin/default.js
serialize.js > document.js
adapter.js > worker.js > index.js > serialize.js > document.js

I will try to update to Vue CLI v5.0.0-alpha.0 at some point which uses Webpack 5 internally (which wil probably resolve those issues).

But it would still make sense to prevent circular module imports whenever possible. Also I would suggest to avoid logic on the module level (e.g. the apply_async line from document.js) and switch to named exports whenever possible.

Let me know if I can help. Otherwise I will do further testing without workers and provide feedback in this issue.

boardend avatar May 20 '21 11:05 boardend

I pushed an update to the branch "0.7.0", this should solve the issue.

ts-thomas avatar May 20 '21 12:05 ts-thomas

Great news ! it's so cool to see this new version. I wanted to test it in my Proof Of Concept app made with Angular. To answer one of your question :

  • do we need ES5 support? Not sure. It would help to a large adoption, but in fact, we are in 2021 !

I was wondering if there was a typescript defintion file, and ... yes there is one, so it's great !

Thanks for the works. I will try to test it

Rebolon avatar May 25 '21 11:05 Rebolon

The typescript def needs an update for 0.7.0. e.g. There is no more create and registerMatcher in FlexSearch.

andyli avatar Jun 13 '21 09:06 andyli

@ts-thomas Were the Typescript definitions removed in v7? After updating to v7, VSCode complains about the type definitions missing.

laurensnl avatar Jun 28 '21 14:06 laurensnl