typeahead.js
typeahead.js copied to clipboard
Option: matchAnyQueryToken (default false)
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 tofalse
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.
@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
@CoreSystemDevelopment sure... thanks for following up Here you go: https://github.com/corejavascript/typeahead.js/pull/2