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

Option: matchAnyQueryToken (default false) #2

Conversation

charlotte-miller
Copy link
Contributor

Bloodhound's tokenizer functions are a really powerful way to tune the search. Unfortunately this flexibility ends at SearchIndex.prototype.search. Currently datums must match ALL query-tokens (with no option to match ANY query-token). This pull request adds the option:

matchAnyQueryToken - By default a search result must match ALL query-tokens.
Instead, this option returns results that match ANY query-tokens.
Defaults to false

Inspired by Elasticsearch's MUST and SHOULD, matching ANY query-token opens up the possibility for more fuzzy search strategies. For more details see the tests and the following example:

var index = new SearchIndex({
  datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
  queryTokenizer: Bloodhound.tokenizers.whitespace,
  matchAnyQueryToken: true,
});

index.add({ value: 'food bar' });
index.search('fod bar'); // return { value: 'food bar' }

Note: Ideally this option could change from search-to-search. But I didn't want to clutter the Bloodhound#search api.

- By default a search result must match ALL query-tokens. Instead, this option returns results that match ANY
@core-system-dev
Copy link
Contributor

LGTM

/cc @Apfeluser

lenovouser pushed a commit that referenced this pull request Sep 25, 2015
Option: matchAnyQueryToken (default false)
@lenovouser lenovouser merged commit 5e62960 into corejavascript:integration-0.11.2 Sep 25, 2015
@lenovouser
Copy link
Contributor

Thanks a lot!

jlbooker pushed a commit that referenced this pull request Dec 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants