nextapps-de / flexsearch

Next-Generation full text search library for Browser and Node.js
Apache License 2.0
12.53k stars 491 forks source link

Is this correct behaviour ? #238

Closed davidhq closed 2 years ago

davidhq commented 3 years ago
import flexsearch from 'flexsearch';

const { Index } = flexsearch;

const index = new Index({ tokenize: 'full' });

index.add(0, 'ac');
index.add(1, 'ca');

console.log(index.search('a'));
// -> [ 0 ]

is this expected?

I want to match entries 0 and 1 on this search query. I thought tokenize: 'full' would enable this but no luck. What am I missing?

Also is this a small typo here: https://github.com/nextapps-de/flexsearch#tokenizer

"reverse" | incrementally index words in both directions

should it not be "in reverse direction" ?

thank you for your help, I'm just starting with this library, learning it. david

davidhq commented 3 years ago

So I guess (Prefix Search) might have something to do with not being able to match any entries where search query does not appear in the start of words (prefix)... but still: is it possible to actually search in the way I described?

davidhq commented 3 years ago

So I think I answered my own question that this is the expected behaviour assuming prefix search, now the question is: is it possible to use other 'strategies' with FlexSearch as of now?

I checked https://github.com/bvaughn/js-search and on the bottom it explains exactly all of this. Is there something similar planned (or already working) here? I looked in the docs but cannot find any info on that option still.

Thank you again for the library and looking forward to the answer

yellow1912 commented 3 years ago

I'm not sure if my issue is the same, but lets say I have the phrase "home page", I want "ho" to match this phrase, is there a way to do it? Right now only "home" works. I tried changing resolution and depth but did not work well. I think the documents on resolution and depth are quire lacking as well.

cheap-glitch commented 3 years ago

I'm not sure if my issue is the same, but lets say I have the phrase "home page", I want "ho" to match this phrase, is there a way to do it? Right now only "home" works. I tried changing resolution and depth but did not work well.

I had the same problem, you need to set the tokenize option to something other than 'strict' (see https://github.com/nextapps-de/flexsearch#tokenizer-prefix-search).

I think the documents on resolution and depth are quire lacking as well.

I agree that the docs could be a little clearer. Also, maybe having 'forward' as a default value for tokenize would make more sense, since (I guess) most people want partial matching in their search.

ibnishak commented 3 years ago

To add to this stream, I was looking to match "Rules of thumb" and "Ruling of King" with the query "rule". Lunr.js successfully showed both. In flexsearch, setting language with complete options to "us" and tokenizer to "full" matches "Rules of thumb".

Any combination of setting I am missing or a stemmer function someone can point to?

ts-thomas commented 2 years ago

This is fixed in v0.7.23