typeahead.js icon indicating copy to clipboard operation
typeahead.js copied to clipboard

Option: matchAnyQueryToken (default false)

Open charlotte-miller opened this issue 9 years ago • 3 comments

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.

charlotte-miller avatar Sep 12 '15 18:09 charlotte-miller

@chip-miller could you please re-submit this PR to github:corejavascript/typeahead.js. This project pretty much has been abandoned, and we continue now on a new fork. For more information please see #1320

core-system-dev avatar Sep 24 '15 13:09 core-system-dev

@CoreSystemDevelopment sure... thanks for following up Here you go: https://github.com/corejavascript/typeahead.js/pull/2

charlotte-miller avatar Sep 24 '15 18:09 charlotte-miller

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 18 '19 15:07 CLAassistant