Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this correct behaviour ? #238

Closed
davidhq opened this issue Jul 10, 2021 · 6 comments
Closed

Is this correct behaviour ? #238

davidhq opened this issue Jul 10, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@davidhq
Copy link

davidhq commented Jul 10, 2021

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
Copy link
Author

davidhq commented Jul 10, 2021

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
Copy link
Author

davidhq commented Jul 10, 2021

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

@ts-thomas ts-thomas added the bug Something isn't working label Jul 12, 2021
@yellow1912
Copy link

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
Copy link

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
Copy link

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
Copy link
Contributor

This is fixed in v0.7.23

ts-thomas added a commit that referenced this issue Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants