1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-09-01 01:51:57 +02:00

ADD profiles

This commit is contained in:
Thomas Wilkerling
2018-03-20 21:58:42 +01:00
parent 54fac055ea
commit c9adfc12ae
8 changed files with 550 additions and 129 deletions

View File

@@ -16,14 +16,13 @@
When it comes to raw search speed <a href="https://jsperf.com/compare-search-libraries" target="_blank">FlexSearch outperforms every single searching library out there</a> and also provides flexible search capabilities like multi-word matching, phonetic transformations or partial matching. When it comes to raw search speed <a href="https://jsperf.com/compare-search-libraries" target="_blank">FlexSearch outperforms every single searching library out there</a> and also provides flexible search capabilities like multi-word matching, phonetic transformations or partial matching.
It also has the __most memory-efficient index__. Keep in mind that updating / removing existing items from the index has a significant cost. When your index needs to be updated continuously then <a href="bulksearch/" target="_blank">BulkSearch</a> may be a better choice. It also has the __most memory-efficient index__. Keep in mind that updating / removing existing items from the index has a significant cost. When your index needs to be updated continuously then <a href="bulksearch/" target="_blank">BulkSearch</a> may be a better choice.
FlexSearch also provides you a non-blocking asynchronous processing model as well as web workers to perform any updates on the index as well as queries through dedicated threads. FlexSearch also provides you a non-blocking asynchronous processing model as well as web workers to perform any updates or queries on the index in parallel through dedicated balanced threads.
<a href="#installation">Installation Guide</a> &ensp;&bull;&ensp; <a href="#api">API Reference</a> &ensp;&bull;&ensp; <a href="#examples">Example Options</a> &ensp;&bull;&ensp; <a href="#builds">Custom Builds</a> <a href="#installation">Installation Guide</a> &ensp;&bull;&ensp; <a href="#api">API Reference</a> &ensp;&bull;&ensp; <a href="#profiles">Example Options</a> &ensp;&bull;&ensp; <a href="#builds">Custom Builds</a>
Comparison: Comparison:
- <a href="https://jsperf.com/compare-search-libraries" target="_blank">Library Benchmarks</a> - <a href="https://jsperf.com/compare-search-libraries" target="_blank">Library Benchmarks</a>
- <a href="https://jsperf.com/flexsearch" target="_blank">BulkSearch vs. FlexSearch Benchmark</a> - <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/matching.html" target="_blank">Library Relevance Scoring</a>
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/matching.html" target="_blank">Relevance Scoring</a>
Supported Platforms: Supported Platforms:
- Browser - Browser
@@ -42,14 +41,14 @@ All Features:
<li>Multiple Words</li> <li>Multiple Words</li>
<li><a href="#phonetic">Phonetic Search</a></li> <li><a href="#phonetic">Phonetic Search</a></li>
<li>Relevance-based Scoring</li> <li>Relevance-based Scoring</li>
<li><a href="contextual">Contextual Indexes</a></li> <li><a href="#contextual">Contextual Indexes</a></li>
<li>Limit Results</li> <li>Limit Results</li>
<li>Supports Caching</li> <li>Supports Caching</li>
<li>Asynchronous Processing</li> <li>Asynchronous Processing</li>
<li>Customizable: Matcher, Encoder, Tokenizer, Stemmer, Stopword-Filter</li> <li>Customizable: Matcher, Encoder, Tokenizer, Stemmer, Stopword-Filter</li>
</ul> </ul>
This features are not available in the 50% smaller <a href="flexsearch.light.js">light version</a>: These features are not available in the 50% smaller <a href="flexsearch.light.js">light version</a>:
- WebWorker - WebWorker
- Async handler - Async handler
@@ -216,6 +215,12 @@ alternatively you can also use:
var index = FlexSearch.create(); var index = FlexSearch.create();
``` ```
##### Create a new index and choosing one of the built-in profiles
```js
var index = new FlexSearch("speed");
```
##### Create a new index with custom options ##### Create a new index with custom options
```js ```js
@@ -223,6 +228,7 @@ var index = new FlexSearch({
// default values: // default values:
profile: "balance",
encode: "icase", encode: "icase",
mode: "ngram", mode: "ngram",
async: false, async: false,
@@ -230,7 +236,8 @@ var index = new FlexSearch({
}); });
``` ```
__Read more:__ <a href="#phonetic">Phonetic Search</a>, <a href="#compare">Phonetic Comparison</a>, <a href="#memory">Improve Memory Usage</a> <a href="#options">Read more about custom options</a>
<a name="index.add"></a> <a name="index.add"></a>
#### Add items to an index #### Add items to an index
@@ -488,7 +495,7 @@ index.search("John Doe", function(results){
<a name="options"></a> <a name="options"></a>
## Options ## Options
FlexSearch ist highly customizable. Make use of the the right options can really improve your results as well as memory economy or query time. FlexSearch ist highly customizable. Make use of the the <a href="#profiles">right options</a> can really improve your results as well as memory economy or query time.
<table> <table>
<tr></tr> <tr></tr>
@@ -498,7 +505,22 @@ FlexSearch ist highly customizable. Make use of the the right options can really
<td align="left">Description</td> <td align="left">Description</td>
</tr> </tr>
<tr> <tr>
<td align="top">mode<br><br><br><br><br></td> <td align="top">profile<br><br><br><br><br><br></td>
<td vertical="top" vertical-align="top">
"memory"<br>
"speed"<br>
"match"<br>
"score"<br>
"balance"<br>
"fastest"
</td>
<td vertical-align="top">
The <a href="#profiles">configuration profile</a>.<br>
</td>
</tr>
<tr></tr>
<tr>
<td align="top">mode<br><br><br><br><br><br></td>
<td vertical="top" vertical-align="top"> <td vertical="top" vertical-align="top">
"strict"<br> "strict"<br>
"foward"<br> "foward"<br>
@@ -872,31 +894,32 @@ The required memory for the index depends on several options:
</tr> </tr>
</table> </table>
<a name="examples"></a> <a name="profiles"></a>
## Example Options ## Built-in Profiles
Memory-optimized: You can pass a built-in profile during creation/initialization. They have these following settings:
Memory-optimized profile: __"memory"__
```js ```js
{ {
encode: "extra", encode: "extra",
mode: "strict", mode: "strict",
threshold: 5 threshold: 7
} }
``` ```
Speed-optimized: Speed-optimized profile: __"speed"__
```js ```js
{ {
encode: "icase", encode: "icase",
mode: "strict", mode: "strict",
threshold: 5, threshold: 7,
depth: 2 depth: 2
} }
``` ```
Matching-tolerant: Matching-tolerant profile: __"match"__
```js ```js
{ {
@@ -905,17 +928,42 @@ Matching-tolerant:
} }
``` ```
Well-balanced: Relevance-optimized profile: __"score"__
```js ```js
{ {
encode: "extra", encode: "extra",
mode: "strict",
threshold: 5,
depth: 4
}
```
Most-balanced profile: __"balanced"__
```js
{
encode: "balanced",
mode: "ngram", mode: "ngram",
threshold: 4, threshold: 6,
depth: 3 depth: 3
} }
``` ```
Absolute fastest profile: __"fastest"__
```js
{
encode: "icase",
threshold: 9,
depth: 1
}
```
Compare these options above:
- <a href="https://jsperf.com/compare-flexsearch-options" target="_blank">Benchmarks</a>
- <a href="https://rawgit.com/nextapps-de/flexsearch/master/test/matching-flexsearch.html" target="_blank">Relevance Scoring</a>
<a name="builds"></a> <a name="builds"></a>
## Custom Builds ## Custom Builds

View File

@@ -1,5 +1,5 @@
;/**! ;/**!
* @preserve FlexSearch v0.2.3 * @preserve FlexSearch v0.2.32
* Copyright 2017-2018 Thomas Wilkerling * Copyright 2017-2018 Thomas Wilkerling
* Released under the Apache 2.0 Licence * Released under the Apache 2.0 Licence
* https://github.com/nextapps-de/flexsearch * https://github.com/nextapps-de/flexsearch
@@ -35,8 +35,9 @@ var SUPPORT_ASYNC = true;
var defaults = { var defaults = {
// bitsize of assigned IDs (data type) // use on of built-in functions
type: 'integer', // or pass custom encoding algorithm
encode: 'icase',
// type of information // type of information
mode: 'forward', mode: 'forward',
@@ -54,11 +55,55 @@ var SUPPORT_ASYNC = true;
threshold: 0, threshold: 0,
// contextual depth // contextual depth
depth: 0, depth: 0
};
// use on of built-in functions /**
// or pass custom encoding algorithm * @struct
encode: 'icase' * @private
* @const
* @final
*/
var profiles = {
"memory": {
encode: "extra",
mode: "strict",
threshold: 7
},
"speed": {
encode: "icase",
mode: "strict",
threshold: 7,
depth: 2
},
"match": {
encode: "extra",
mode: "full"
},
"score": {
encode: "extra",
mode: "strict",
threshold: 5,
depth: 4
},
"balance": {
encode: "balance",
mode: "ngram",
threshold: 6,
depth: 3
},
"fastest": {
encode: "icase",
threshold: 9,
depth: 1
}
}; };
/** /**
@@ -94,7 +139,7 @@ var SUPPORT_ASYNC = true;
* @const {Array<string>} * @const {Array<string>}
*/ */
var filter = SUPPORT_BUILTINS ? [ var filter = [
"a", "a",
"about", "about",
@@ -301,14 +346,13 @@ var SUPPORT_ASYNC = true;
"yourself", "yourself",
"yourselves", "yourselves",
"you've" "you've"
];
] : null;
/** /**
* @const {Object<string, string>} * @const {Object<string, string>}
*/ */
var stemmer = SUPPORT_BUILTINS ? { var stemmer = {
"ational": "ate", "ational": "ate",
"tional": "tion", "tional": "tion",
@@ -356,18 +400,24 @@ var SUPPORT_ASYNC = true;
"ous": "", "ous": "",
"ive": "", "ive": "",
"ize": "" "ize": ""
};
} : null;
/** /**
* @param {Object<string, number|string|boolean|Object|function(string):string>=} options * @param {string|Object<string, number|string|boolean|Object|function(string):string>=} options
* @constructor * @constructor
* @private * @private
*/ */
function FlexSearch(options){ function FlexSearch(options){
if(typeof options === 'string'){
options = profiles[options] || defaults;
}
else{
options || (options = defaults); options || (options = defaults);
}
// generate UID // generate UID
@@ -467,9 +517,11 @@ var SUPPORT_ASYNC = true;
if(options){ if(options){
var custom;
// initialize worker // initialize worker
if(SUPPORT_WORKER && options['worker']){ if(SUPPORT_WORKER && (custom = options['worker'])){
if(typeof Worker === 'undefined'){ if(typeof Worker === 'undefined'){
@@ -485,7 +537,7 @@ var SUPPORT_ASYNC = true;
else{ else{
var self = this; var self = this;
var threads = parseInt(options['worker'], 10) || 4; var threads = parseInt(custom, 10) || 4;
self._current_task = -1; self._current_task = -1;
self._task_completed = 0; self._task_completed = 0;
@@ -536,7 +588,30 @@ var SUPPORT_ASYNC = true;
} }
} }
// apply options // apply profile options
if((custom = options['profile'])) {
this.profile = custom || 'custom';
custom = profiles[custom];
if(custom) {
for(var option in custom){
if(custom.hasOwnProperty(option)){
if(typeof options[option] === 'undefined'){
options[option] = custom[option];
}
}
}
}
}
// apply custom options
this.mode = ( this.mode = (
@@ -580,10 +655,12 @@ var SUPPORT_ASYNC = true;
defaults.depth defaults.depth
); );
custom = options['encode'];
this.encoder = ( this.encoder = (
(options['encode'] && global_encoder[options['encode']]) || (custom && global_encoder[custom]) ||
(typeof options['encode'] === 'function' ? options['encode'] : this.encoder || false) (typeof custom === 'function' ? custom : this.encoder || false)
); );
if(SUPPORT_DEBUG){ if(SUPPORT_DEBUG){
@@ -595,33 +672,33 @@ var SUPPORT_ASYNC = true;
); );
} }
if(options['matcher']) { if(custom = options['matcher']) {
this.addMatcher(/** @type {Object<string, string>} */ (options['matcher'])); this.addMatcher(/** @type {Object<string, string>} */ (custom));
} }
if(options['filter']) { if(SUPPORT_BUILTINS && (custom = options['filter'])) {
this.filter = initFilter( this.filter = initFilter(
(options['filter'] === true ? (custom === true ?
filter filter
: :
/** @type {Array<string>} */ (options['filter']) /** @type {Array<string>} */ (custom)
), this.encoder); ), this.encoder);
} }
if(options['stemmer']) { if(SUPPORT_BUILTINS && (custom = options['stemmer'])) {
this.stemmer = initStemmer( this.stemmer = initStemmer(
(options['stemmer'] === true ? (custom === true ?
stemmer stemmer
: :
/** @type {Object<string, string>} */ (options['stemmer']) /** @type {Object<string, string>} */ (custom)
), this.encoder); ), this.encoder);
} }
@@ -932,7 +1009,7 @@ var SUPPORT_ASYNC = true;
threshold threshold
); );
if(depth && (word_length > 1) && (score > threshold)){ if(depth && (word_length > 1) && (score >= threshold)){
var ctx_map = map[10]; var ctx_map = map[10];
var ctx_dupes = dupes['_ctx'][value] || (dupes['_ctx'][value] = {}); var ctx_dupes = dupes['_ctx'][value] || (dupes['_ctx'][value] = {});
@@ -1476,7 +1553,7 @@ var SUPPORT_ASYNC = true;
/** @const */ /** @const */
var global_encoder_balanced = (function(){ var global_encoder_balance = (function(){
var regex_whitespace = regex('\\s\\s+'), var regex_whitespace = regex('\\s\\s+'),
regex_strip = regex('[^a-z0-9 ]'), regex_strip = regex('[^a-z0-9 ]'),
@@ -1702,16 +1779,7 @@ var SUPPORT_ASYNC = true;
}; };
})(), })(),
'balanced': global_encoder_balanced 'balance': global_encoder_balance
// TODO: provide some common encoder plugins
// soundex
// cologne
// metaphone
// caverphone
// levinshtein
// hamming
// matchrating
} : { } : {
@@ -1722,7 +1790,7 @@ var SUPPORT_ASYNC = true;
return value.toLowerCase(); return value.toLowerCase();
}, },
'balanced': global_encoder_balanced 'balance': global_encoder_balance
}; };
// Xone Async Handler Fallback // Xone Async Handler Fallback
@@ -1846,7 +1914,7 @@ var SUPPORT_ASYNC = true;
dupes[tmp] = score; dupes[tmp] = score;
if(score > threshold){ if(score >= threshold){
var arr = map[score]; var arr = map[score];
arr = arr[tmp] || (arr[tmp] = []); arr = arr[tmp] || (arr[tmp] = []);
@@ -2525,13 +2593,17 @@ var SUPPORT_ASYNC = true;
URL.createObjectURL( URL.createObjectURL(
new Blob( new Blob([
['(' + _worker.toString() + ')()'], {
'var SUPPORT_WORKER = true;' +
'var SUPPORT_BUILTINS = ' + (SUPPORT_BUILTINS ? 'true' : 'false') + ';' +
'var SUPPORT_DEBUG = ' + (SUPPORT_DEBUG ? 'true' : 'false') + ';' +
'var SUPPORT_CACHE = ' + (SUPPORT_CACHE ? 'true' : 'false') + ';' +
'var SUPPORT_ASYNC = ' + (SUPPORT_ASYNC ? 'true' : 'false') + ';' +
'(' + _worker.toString() + ')()'
],{
'type': 'text/javascript' 'type': 'text/javascript'
} })
)
) )
: :

View File

@@ -1,18 +1,18 @@
/* /*
FlexSearch v0.2.3 FlexSearch v0.2.32
Copyright 2017-2018 Thomas Wilkerling Copyright 2017-2018 Thomas Wilkerling
Released under the Apache 2.0 Licence Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch https://github.com/nextapps-de/flexsearch
*/ */
'use strict';(function(h,t,l){var q;(q=l.define)&&q.amd?q([],function(){return t}):(q=l.modules)?q[h.toLowerCase()]=t:"undefined"!==typeof module?module.exports=t:l[h]=t})("FlexSearch",function(){function h(a){a||(a=y);this.id=a.id||C++;this.init(a);t(this,"index",function(){return this.a});t(this,"length",function(){return Object.keys(this.a).length})}function t(a,b,c){Object.defineProperty(a,b,{get:c})}function l(a){return new RegExp(a,"g")}function q(a,b,c){if("undefined"===typeof c){for(c=0;c< 'use strict';(function(d,t,l){var q;(q=l.define)&&q.amd?q([],function(){return t}):(q=l.modules)?q[d.toLowerCase()]=t:"undefined"!==typeof module?module.exports=t:l[d]=t})("FlexSearch",function(){function d(a){"string"===typeof a?a=A[a]||x:a||(a=x);this.id=a.id||D++;this.init(a);t(this,"index",function(){return this.a});t(this,"length",function(){return Object.keys(this.a).length})}function t(a,b,c){Object.defineProperty(a,b,{get:c})}function l(a){return new RegExp(a,"g")}function q(a,b,c){if("undefined"===
b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}return a.replace(b,c)}function w(a,b,c,g,d,e){if("undefined"===typeof b[c]){var f=d.indexOf(c);f=3/d.length*(d.length-f)+6/(f-d.lastIndexOf(" ",f))+.5|0;b[c]=f;f>e&&(a=a[f],a=a[c]||(a[c]=[]),a[a.length]=g)}return f||b[c]}function A(a){var b=[];if(!a)return b;for(var c=0,g=0,d=0,e="",f=a.length,p=0;p<f;p++){var m=a[p];"a"===m||"e"===m||"i"===m||"o"===m||"u"===m||"y"===m?c++:g++;" "!==m&&(e+=m);if(" "===m||1<c&&1<g||2<c||2<g||p===f-1)e&&(b[d]&&2<e.length&& typeof c){for(c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}return a.replace(b,c)}function v(a,b,c,k,g,e){if("undefined"===typeof b[c]){var f=g.indexOf(c);f=3/g.length*(g.length-f)+6/(f-g.lastIndexOf(" ",f))+.5|0;b[c]=f;f>=e&&(a=a[f],a=a[c]||(a[c]=[]),a[a.length]=k)}return f||b[c]}function B(a){var b=[];if(!a)return b;for(var c=0,k=0,g=0,e="",f=a.length,p=0;p<f;p++){var m=a[p];"a"===m||"e"===m||"i"===m||"o"===m||"u"===m||"y"===m?c++:k++;" "!==m&&(e+=m);if(" "===m||1<c&&1<k||2<c||2<k||p===
d++,b[d]=b[d]?b[d]+e:e," "===m&&d++,e=""),g=c=0}return b}function D(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function E(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function F(a,b){var c=[],g=a.length;if(1<g){a.sort(E);for(var d={},e=a[0],f=e.length,p=0;p<f;)d[e[p++]]=1;for(var m,h=0,n=1;n<g;){var r=!1;e=a[n];f=e.length;for(p=0;p<f;)if(d[m=e[p++]]===n){if(n===g-1&&(c[h++]=m,b&&h===b)){r=!1;break}r=!0;d[m]=n+1}if(!r)break;n++}}else g&&(c=a[0],b&&c&&c.length>b&&(c=c.slice(0,b)));return c}var y= f-1)e&&(b[g]&&2<e.length&&g++,b[g]=b[g]?b[g]+e:e," "===m&&g++,e=""),k=c=0}return b}function E(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function F(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function G(a,b){var c=[],k=a.length;if(1<k){a.sort(F);for(var g={},e=a[0],f=e.length,p=0;p<f;)g[e[p++]]=1;for(var m,d=0,n=1;n<k;){var r=!1;e=a[n];f=e.length;for(p=0;p<f;)if(g[m=e[p++]]===n){if(n===k-1&&(c[d++]=m,b&&d===b)){r=!1;break}r=!0;g[m]=n+1}if(!r)break;n++}}else k&&(c=a[0],b&&c&&c.length>b&&(c=
{type:"integer",mode:"forward",cache:!1,async:!1,l:!1,threshold:0,depth:0,encode:"icase"},x=[],C=0,B=l("[ -/]");h.new=function(a){return new this(a)};h.create=function(a){return h.new(a)};h.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(x[x.length]=l(b),x[x.length]=a[b]);return this};h.register=function(a,b){v[a]=b;return this};h.encode=function(a,b){return v[a].call(v,b)};h.prototype.init=function(a){this.c=[];if(a&&(this.mode=a.mode||this.mode||y.mode,this.threshold=a.threshold||this.threshold|| c.slice(0,b)));return c}var x={encode:"icase",mode:"forward",cache:!1,async:!1,l:!1,threshold:0,depth:0},A={memory:{encode:"extra",mode:"strict",threshold:7},speed:{encode:"icase",mode:"strict",threshold:7,depth:2},match:{encode:"extra",mode:"full"},score:{encode:"extra",mode:"strict",threshold:5,depth:4},balance:{encode:"balance",mode:"ngram",threshold:6,depth:3},fastest:{encode:"icase",threshold:9,depth:1}},w=[],D=0,C=l("[ -/]");d.new=function(a){return new this(a)};d.create=function(a){return d.new(a)};
y.threshold,this.depth=a.depth||this.depth||y.depth,this.h=a.encode&&v[a.encode]||("function"===typeof a.encode?a.encode:this.h||!1),a.matcher&&this.addMatcher(a.matcher),a.filter&&(this.i={}),a.stemmer)){a=!0===a.stemmer?null:a.stemmer;var b=this.h,c=[];if(a){var g=0,d;for(d in a)if(a.hasOwnProperty(d)){var e=b?b.call(v,d):d;c[g++]=l("(?=.{"+(e.length+3)+",})"+e+"$");c[g++]=b?b.call(v,a[d]):a[d]}}this.j=c}this.b=[{},{},{},{},{},{},{},{},{},{},{}];this.a={};this.f="";this.g=!0;return this};h.prototype.encode= d.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(w[w.length]=l(b),w[w.length]=a[b]);return this};d.register=function(a,b){y[a]=b;return this};d.encode=function(a,b){return y[a].call(y,b)};d.prototype.init=function(a){this.c=[];if(a){var b;if(b=a.profile)if(b=A[b])for(var c in b)b.hasOwnProperty(c)&&"undefined"===typeof a[c]&&(a[c]=b[c]);this.mode=a.mode||this.mode||x.mode;this.threshold=a.threshold||this.threshold||x.threshold;this.depth=a.depth||this.depth||x.depth;this.h=(b=a.encode)&&
function(a){a&&x.length&&(a=q(a,x));a&&this.c.length&&(a=q(a,this.c));a&&this.h&&(a=this.h.call(v,a));if(a&&this.i){a=a.split(" ");for(var b=0;b<a.length;b++){var c=a[b];this.i[c]&&(a[b]=this.i[c])}a=a.join(" ")}a&&this.j&&(a=q(a,this.j));return a};h.prototype.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(this.c[this.c.length]=l(b),this.c[this.c.length]=a[b]);return this};h.prototype.add=function(a,b){if("string"===typeof b&&b&&(a||0===a))if(this.a[a])this.update(a,b);else{b=this.encode(b); y[b]||("function"===typeof b?b:this.h||!1);(b=a.matcher)&&this.addMatcher(b)}this.b=[{},{},{},{},{},{},{},{},{},{},{}];this.a={};this.f="";this.g=!0;return this};d.prototype.encode=function(a){a&&w.length&&(a=q(a,w));a&&this.c.length&&(a=q(a,this.c));a&&this.h&&(a=this.h.call(y,a));if(a&&this.i){a=a.split(" ");for(var b=0;b<a.length;b++){var c=a[b];this.i[c]&&(a[b]=this.i[c])}a=a.join(" ")}a&&this.j&&(a=q(a,this.j));return a};d.prototype.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&
if(!b.length)return this;for(var c=this.mode,g="function"===typeof c?c(b):"ngram"===c?A(b):b.split(B),d={_ctx:{}},e=this.threshold,f=this.depth,p=this.b,m=g.length,h=0;h<m;h++){var n=g[h];if(n){var r=n.length;switch(c){case "reverse":case "both":for(var u="",k=r-1;1<=k;k--)u=n[k]+u,w(p,d,u,a,b,e);case "forward":u="";for(k=0;k<r;k++)u+=n[k],w(p,d,u,a,b,e);break;case "full":for(k=0;k<r;k++)for(var l=r;l>k;l--)u=n.substring(k,l),w(p,d,u,a,b,e);break;default:if(k=w(p,d,n,a,b,e),f&&1<m&&k>e)for(k=p[10], (this.c[this.c.length]=l(b),this.c[this.c.length]=a[b]);return this};d.prototype.add=function(a,b){if("string"===typeof b&&b&&(a||0===a))if(this.a[a])this.update(a,b);else{b=this.encode(b);if(!b.length)return this;for(var c=this.mode,k="function"===typeof c?c(b):"ngram"===c?B(b):b.split(C),g={_ctx:{}},e=this.threshold,f=this.depth,p=this.b,m=k.length,d=0;d<m;d++){var n=k[d];if(n){var r=n.length;switch(c){case "reverse":case "both":for(var u="",h=r-1;1<=h;h--)u=n[h]+u,v(p,g,u,a,b,e);case "forward":u=
r=d._ctx[n]||(d._ctx[n]={}),n=k[n]||(k[n]=[{},{},{},{},{},{},{},{},{},{}]),k=h-f,l=h+f,0>k&&(k=0),l>m-1&&(l=m-1);k<=l;k++)k!==h&&w(n,r,g[k],a,b,e)}}}this.a[a]="1";this.g=!1}return this};h.prototype.update=function(a,b){"string"===typeof b&&(a||0===a)&&this.a[a]&&(this.remove(a),b&&this.add(a,b));return this};h.prototype.remove=function(a){if(this.a[a]){for(var b=0;10>b;b++)for(var c=Object.keys(this.b[b]),g=0;g<c.length;g++){var d=c[g],e=this.b[b];if((e=e&&e[d])&&e.length)for(var f=0;f<e.length;f++)if(e[f]=== "";for(h=0;h<r;h++)u+=n[h],v(p,g,u,a,b,e);break;case "full":for(h=0;h<r;h++)for(var l=r;l>h;l--)u=n.substring(h,l),v(p,g,u,a,b,e);break;default:if(h=v(p,g,n,a,b,e),f&&1<m&&h>=e)for(h=p[10],r=g._ctx[n]||(g._ctx[n]={}),n=h[n]||(h[n]=[{},{},{},{},{},{},{},{},{},{}]),h=d-f,l=d+f,0>h&&(h=0),l>m-1&&(l=m-1);h<=l;h++)h!==d&&v(n,r,k[h],a,b,e)}}}this.a[a]="1";this.g=!1}return this};d.prototype.update=function(a,b){"string"===typeof b&&(a||0===a)&&this.a[a]&&(this.remove(a),b&&this.add(a,b));return this};d.prototype.remove=
a){e.splice(f,1);break}e.length||delete this.b[b][d]}delete this.a[a];this.g=!1}return this};h.prototype.search=function(a,b,c){var g=[];if(a&&"object"===typeof a){c=a.callback||b;b=a.limit;var d=a.threshold;a=a.query}d||(d=0);"function"===typeof b?(c=b,b=1E3):b||(b=1E3);if(c){var e=this;G(function(){c(e.search(a,b));e=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return g;if(!this.g)this.g=!0;else if(this.f&&0===a.indexOf(this.f))return g;var f=this.encode(a);if(!f.length)return g; function(a){if(this.a[a]){for(var b=0;10>b;b++)for(var c=Object.keys(this.b[b]),k=0;k<c.length;k++){var g=c[k],e=this.b[b];if((e=e&&e[g])&&e.length)for(var f=0;f<e.length;f++)if(e[f]===a){e.splice(f,1);break}e.length||delete this.b[b][g]}delete this.a[a];this.g=!1}return this};d.prototype.search=function(a,b,c){var k=[];if(a&&"object"===typeof a){c=a.callback||b;b=a.limit;var g=a.threshold;a=a.query}g||(g=0);"function"===typeof b?(c=b,b=1E3):b||(b=1E3);if(c){var e=this;H(function(){c(e.search(a,b));
var h=this.mode;f="function"===typeof h?h(f):"ngram"===h?A(f):f.split(B);h=f.length;var m=!0,l=[],n={};if(1<h)if(this.depth){var r=!0,u=f[0];n[u]="1"}else f.sort(D);var k;if(!r||(k=this.b[10])[u])for(var q=r?1:0;q<h;q++){var t=f[q];if(t&&!n[t]){for(var v,x=!1,w=[],y=0,z=9;z>=d;z--)if(v=(r?k[u]:this.b)[z][t])w[y++]=v,x=!0;if(x)l[l.length]=1<y?l.concat.apply([],w):w[0];else{m=!1;break}n[t]="1"}u=t}else m=!1;m&&(g=F(l,b));g.length?this.f="":this.f||(this.f=a);return g};h.prototype.reset=function(){this.destroy(); e=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return k;if(!this.g)this.g=!0;else if(this.f&&0===a.indexOf(this.f))return k;var f=this.encode(a);if(!f.length)return k;var d=this.mode;f="function"===typeof d?d(f):"ngram"===d?B(f):f.split(C);d=f.length;var m=!0,l=[],n={};if(1<d)if(this.depth){var r=!0,u=f[0];n[u]="1"}else f.sort(E);var h;if(!r||(h=this.b[10])[u])for(var q=r?1:0;q<d;q++){var t=f[q];if(t&&!n[t]){for(var w,x=!1,v=[],y=0,z=9;z>=g;z--)if(w=(r?h[u]:this.b)[z][t])v[y++]=
return this.init()};h.prototype.destroy=function(){this.b=this.a=null;return this};var v={icase:function(a){return a.toLowerCase()},balanced:function(){var a=[l("[-/]")," ",l("[^a-z0-9 ]"),"",l("\\s\\s+")," ",l("[aeiouy]"),""];return function(b){b=q(b.toLowerCase(),a);for(var c="",g="",d="",e=0;e<b.length;e++){var f=b[e];if(f!==g)if(e&&"h"===f){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===g||"e"===g||"i"===g||"o"===g||"u"===g||"y"===g)&&d||" "===g)c+=f}else c+=f;d=e===b.length- w,x=!0;if(x)l[l.length]=1<y?l.concat.apply([],v):v[0];else{m=!1;break}n[t]="1"}u=t}else m=!1;m&&(k=G(l,b));k.length?this.f="":this.f||(this.f=a);return k};d.prototype.reset=function(){this.destroy();return this.init()};d.prototype.destroy=function(){this.b=this.a=null;return this};var y={icase:function(a){return a.toLowerCase()},balance:function(){var a=[l("[-/]")," ",l("[^a-z0-9 ]"),"",l("\\s\\s+")," ",l("[aeiouy]"),""];return function(b){b=q(b.toLowerCase(),a);for(var c="",d="",g="",e=0;e<b.length;e++){var f=
1?"":b[e+1];g=f}return c}}()},G=null;return h}(!1),this); b[e];if(f!==d)if(e&&"h"===f){if(g="a"===g||"e"===g||"i"===g||"o"===g||"u"===g||"y"===g,("a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d)&&g||" "===d)c+=f}else c+=f;g=e===b.length-1?"":b[e+1];d=f}return c}}()},H=null;return d}(!1),this);

49
flexsearch.min.js vendored
View File

@@ -1,29 +1,30 @@
/* /*
FlexSearch v0.2.3 FlexSearch v0.2.32
Copyright 2017-2018 Thomas Wilkerling Copyright 2017-2018 Thomas Wilkerling
Released under the Apache 2.0 Licence Released under the Apache 2.0 Licence
https://github.com/nextapps-de/flexsearch https://github.com/nextapps-de/flexsearch
*/ */
'use strict';(function(n,C,f){var p;(p=f.define)&&p.amd?p([],function(){return C}):(p=f.modules)?p[n.toLowerCase()]=C:"undefined"!==typeof module?module.exports=C:f[n]=C})("FlexSearch",function K(n){function f(a){a||(a=u);this.id=a.id||L++;this.init(a);p(this,"index",function(){return this.a});p(this,"length",function(){return Object.keys(this.a).length})}function p(a,b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function v(a,b,c){if("undefined"===typeof c){for(c= 'use strict';(function(n,C,g){var p;(p=g.define)&&p.amd?p([],function(){return C}):(p=g.modules)?p[n.toLowerCase()]=C:"undefined"!==typeof module?module.exports=C:g[n]=C})("FlexSearch",function L(n){function g(a){"string"===typeof a?a=G[a]||v:a||(a=v);this.id=a.id||M++;this.init(a);p(this,"index",function(){return this.a});p(this,"length",function(){return Object.keys(this.a).length})}function p(a,b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function w(a,b,c){if("undefined"===
0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}return a.replace(b,c)}function w(a,b,c,e,h,g){if("undefined"===typeof b[c]){var k=h.indexOf(c);k=3/h.length*(h.length-k)+6/(k-h.lastIndexOf(" ",k))+.5|0;b[c]=k;k>g&&(a=a[k],a=a[c]||(a[c]=[]),a[a.length]=e)}return k||b[c]}function x(a){var b=[];if(!a)return b;for(var c=0,e=0,h=0,g="",k=a.length,B=0;B<k;B++){var d=a[B];"a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d?c++:e++;" "!==d&&(g+=d);if(" "===d||1<c&&1<e||2<c||2<e||B===k-1)g&&(b[h]&&2<g.length&& typeof c){for(c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}return a.replace(b,c)}function t(a,b,c,e,f,k){if("undefined"===typeof b[c]){var h=f.indexOf(c);h=3/f.length*(f.length-h)+6/(h-f.lastIndexOf(" ",h))+.5|0;b[c]=h;h>=k&&(a=a[h],a=a[c]||(a[c]=[]),a[a.length]=e)}return h||b[c]}function x(a){var b=[];if(!a)return b;for(var c=0,e=0,f=0,k="",h=a.length,B=0;B<h;B++){var d=a[B];"a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d?c++:e++;" "!==d&&(k+=d);if(" "===d||1<c&&1<e||2<c||2<e||B===
h++,b[h]=b[h]?b[h]+g:g," "===d&&h++,g=""),e=c=0}return b}function F(a){for(var b="",c="",e="",h=0;h<a.length;h++){var g=a[h];if(g!==c)if(h&&"h"===g){if(e="a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&e||" "===c)b+=g}else b+=g;e=h===a.length-1?"":a[h+1];c=g}return b}function M(a,b){var c={};if(G)for(var e=0;e<a.length;e++){var h=b?b.call(y,a[e]):a[e];c[h]=String.fromCharCode(65E3-a.length+e)}return c}function N(a,b){var c=[];if(a){var e= h-1)k&&(b[f]&&2<k.length&&f++,b[f]=b[f]?b[f]+k:k," "===d&&f++,k=""),e=c=0}return b}function F(a){for(var b="",c="",e="",f=0;f<a.length;f++){var k=a[f];if(k!==c)if(f&&"h"===k){if(e="a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&e||" "===c)b+=k}else b+=k;e=f===a.length-1?"":a[f+1];c=k}return b}function N(a,b){var c={};if(H)for(var e=0;e<a.length;e++){var f=b?b.call(y,a[e]):a[e];c[f]=String.fromCharCode(65E3-a.length+e)}return c}function O(a,
0,h;for(h in a)if(a.hasOwnProperty(h)){var g=b?b.call(y,h):h;c[e++]=d("(?=.{"+(g.length+3)+",})"+g+"$");c[e++]=b?b.call(y,a[h]):a[h]}}return c}function O(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function P(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function Q(a,b){var c=[],e=a.length;if(1<e){a.sort(P);for(var h={},g=a[0],d=g.length,B=0;B<d;)h[g[B++]]=1;for(var f,q=0,m=1;m<e;){var r=!1;g=a[m];d=g.length;for(B=0;B<d;)if(h[f=g[B++]]===m){if(m===e-1&&(c[q++]=f,b&&q===b)){r=!1;break}r=!0;h[f]= b){var c=[];if(a){var e=0,f;for(f in a)if(a.hasOwnProperty(f)){var k=b?b.call(y,f):f;c[e++]=d("(?=.{"+(k.length+3)+",})"+k+"$");c[e++]=b?b.call(y,a[f]):a[f]}}return c}function P(a,b){a=a.length-b.length;return 0>a?1:0<a?-1:0}function Q(a,b){a=a.length-b.length;return 0>a?-1:0<a?1:0}function R(a,b){var c=[],e=a.length;if(1<e){a.sort(Q);for(var f={},k=a[0],d=k.length,B=0;B<d;)f[k[B++]]=1;for(var g,q=0,m=1;m<e;){var r=!1;k=a[m];d=k.length;for(B=0;B<d;)if(f[g=k[B++]]===m){if(m===e-1&&(c[q++]=g,b&&q===
m+1}if(!r)break;m++}}else e&&(c=a[0],b&&c&&c.length>b&&(c=c.slice(0,b)));return c}function E(a){a.B||(a.B=H(function(){a.B=null;var b=a.async;b&&(a.async=!1);if(a.c.length){for(var c=I(),e;(e=a.c.shift())||0===e;){var d=a.h[e];switch(d[0]){case D.add:a.add(d[1],d[2]);break;case D.update:a.update(d[1],d[2]);break;case D.remove:a.remove(d[1])}a.h[e]=null;delete a.h[e];if(100<I()-c)break}a.c.length&&E(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function I(){return"undefined"!==typeof performance?performance.now(): b)){r=!1;break}r=!0;f[g]=m+1}if(!r)break;m++}}else e&&(c=a[0],b&&c&&c.length>b&&(c=c.slice(0,b)));return c}function E(a){a.B||(a.B=I(function(){a.B=null;var b=a.async;b&&(a.async=!1);if(a.c.length){for(var c=J(),e;(e=a.c.shift())||0===e;){var f=a.h[e];switch(f[0]){case D.add:a.add(f[1],f[2]);break;case D.update:a.update(f[1],f[2]);break;case D.remove:a.remove(f[1])}a.h[e]=null;delete a.h[e];if(100<J()-c)break}a.c.length&&E(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function J(){return"undefined"!==
(new Date).getTime()}function R(a,b,c,e){a=n("flexsearch","id"+a,function(){var a,b;self.a=function(c){if(c=c.data)c.search?self.postMessage({result:b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit),id:a,content:c.content,limit:c.limit}):c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.reset?b.reset():c.info?(c=b.info(),c.worker=a,b.C&&console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!0,c.options.worker=!1,b= typeof performance?performance.now():(new Date).getTime()}function S(a,b,c,e){a=n("flexsearch","id"+a,function(){var a,b;self.a=function(c){if(c=c.data)c.search?self.postMessage({result:b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit),id:a,content:c.content,limit:c.limit}):c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.reset?b.reset():c.info?(c=b.info(),c.worker=a,b.C&&console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=
(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}},function(a){(a=a.data)&&a.result?e(a.id,a.content,a.result,a.limit):c.debug&&console.log(a)},b);var d=K.toString();c.id=b;a.postMessage(b,{register:d,options:c,id:b});return a}var u={type:"integer",mode:"forward",cache:!1,async:!1,b:!1,threshold:0,depth:0,encode:"icase"},z=[],L=0,D={add:0,update:1,remove:2},J=d("[ -/]"),S="a about above after again against all also am an and any are aren't as at be because been before being below both but by can cannot can't come could couldn't did didn't do does doesn't doing dont down during each even few first for from further get go had hadn't has hasn't have haven't having he hed her here here's hers herself hes him himself his how how's i id if ill im in into is isn't it it's itself i've just know let's like make me more most mustn't my myself new no nor not now of off on once only or other ought our our's ourselves out over own same say see shan't she she'd shell shes should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through time to too until up us very want was wasn't way we wed well were weren't we've what what's when when's where where's which while who whom who's why why's will with won't would wouldn't you you'd you'll your you're your's yourself yourselves you've".split(" "), !0,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}},function(a){(a=a.data)&&a.result?e(a.id,a.content,a.result,a.limit):c.debug&&console.log(a)},b);var f=L.toString();c.id=b;a.postMessage(b,{register:f,options:c,id:b});return a}var v={encode:"icase",mode:"forward",cache:!1,async:!1,b:!1,threshold:0,depth:0},G={memory:{encode:"extra",mode:"strict",threshold:7},speed:{encode:"icase",mode:"strict",threshold:7,depth:2},
G={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log",icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:"",al:"",ance:"",ence:"",er:"",ic:"",able:"",ible:"",ant:"",ement:"",ment:"",ent:"",ou:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:""};f.new=function(a){return new this(a)};f.create=function(a){return f.new(a)}; match:{encode:"extra",mode:"full"},score:{encode:"extra",mode:"strict",threshold:5,depth:4},balance:{encode:"balance",mode:"ngram",threshold:6,depth:3},fastest:{encode:"icase",threshold:9,depth:1}},z=[],M=0,D={add:0,update:1,remove:2},K=d("[ -/]"),T="a about above after again against all also am an and any are aren't as at be because been before being below both but by can cannot can't come could couldn't did didn't do does doesn't doing dont down during each even few first for from further get go had hadn't has hasn't have haven't having he hed her here here's hers herself hes him himself his how how's i id if ill im in into is isn't it it's itself i've just know let's like make me more most mustn't my myself new no nor not now of off on once only or other ought our our's ourselves out over own same say see shan't she she'd shell shes should shouldn't so some such than that that's the their theirs them themselves then there there's these they they'd they'll they're they've this those through time to too until up us very want was wasn't way we wed well were weren't we've what what's when when's where where's which while who whom who's why why's will with won't would wouldn't you you'd you'll your you're your's yourself yourselves you've".split(" "),
f.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(z[z.length]=d(b),z[z.length]=a[b]);return this};f.register=function(a,b){y[a]=b;return this};f.encode=function(a,b){return y[a].call(y,b)};f.prototype.init=function(a){this.m=[];if(a){if(a.worker)if("undefined"===typeof Worker)a.worker=!1,a.async=!0,this.j=null;else{var b=this,c=parseInt(a.worker,10)||4;b.s=-1;b.o=0;b.i=[];b.w=null;b.j=Array(c);for(var e=0;e<c;e++)b.j[e]=R(b.id,e,a||u,function(a,c,e,d){b.o!==b.b&&(b.i=b.i.concat(e),b.o++, H={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log",icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:"",al:"",ance:"",ence:"",er:"",ic:"",able:"",ible:"",ant:"",ement:"",ment:"",ent:"",ou:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:""};g.new=function(a){return new this(a)};g.create=function(a){return g.new(a)};
d&&b.i.length>=d&&(b.o=b.b),b.w&&b.o===b.b&&(b.i.length?b.f="":b.f||(b.f=c),b.cache&&b.l.set(c,b.i),b.w(b.i),b.i=[]))})}this.mode=a.mode||this.mode||u.mode;this.cache=a.cache||this.cache||u.cache;this.async=a.async||this.async||u.async;this.b=a.worker||this.b||u.b;this.threshold=a.threshold||this.threshold||u.threshold;this.depth=a.depth||this.depth||u.depth;this.v=a.encode&&y[a.encode]||("function"===typeof a.encode?a.encode:this.v||!1);this.C=a.debug||this.C;a.matcher&&this.addMatcher(a.matcher); g.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(z[z.length]=d(b),z[z.length]=a[b]);return this};g.register=function(a,b){y[a]=b;return this};g.encode=function(a,b){return y[a].call(y,b)};g.prototype.init=function(a){this.m=[];if(a){var b;if(b=a.worker)if("undefined"===typeof Worker)a.worker=!1,a.async=!0,this.j=null;else{var c=this;b=parseInt(b,10)||4;c.s=-1;c.o=0;c.i=[];c.w=null;c.j=Array(b);for(var e=0;e<b;e++)c.j[e]=S(c.id,e,a||v,function(a,b,e,f){c.o!==c.b&&(c.i=c.i.concat(e),c.o++,
a.filter&&(this.A=M(!0===a.filter?S:a.filter,this.v));a.stemmer&&(this.D=N(!0===a.stemmer?G:a.stemmer,this.v))}this.g=[{},{},{},{},{},{},{},{},{},{},{}];this.a={};this.h={};this.c=[];this.B=null;this.f="";this.u=!0;this.l=this.cache?new T(3E4,50,!0):!1;return this};f.prototype.encode=function(a){a&&z.length&&(a=v(a,z));a&&this.m.length&&(a=v(a,this.m));a&&this.v&&(a=this.v.call(y,a));if(a&&this.A){a=a.split(" ");for(var b=0;b<a.length;b++){var c=a[b];this.A[c]&&(a[b]=this.A[c])}a=a.join(" ")}a&&this.D&& f&&c.i.length>=f&&(c.o=c.b),c.w&&c.o===c.b&&(c.i.length?c.f="":c.f||(c.f=b),c.cache&&c.l.set(b,c.i),c.w(c.i),c.i=[]))})}if(b=a.profile)if(b=G[b])for(var f in b)b.hasOwnProperty(f)&&"undefined"===typeof a[f]&&(a[f]=b[f]);this.mode=a.mode||this.mode||v.mode;this.cache=a.cache||this.cache||v.cache;this.async=a.async||this.async||v.async;this.b=a.worker||this.b||v.b;this.threshold=a.threshold||this.threshold||v.threshold;this.depth=a.depth||this.depth||v.depth;this.v=(b=a.encode)&&y[b]||("function"===
(a=v(a,this.D));return a};f.prototype.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(this.m[this.m.length]=d(b),this.m[this.m.length]=a[b]);return this};f.prototype.add=function(a,b){if("string"===typeof b&&b&&(a||0===a))if(this.a[a])this.update(a,b);else{if(this.b)return++this.s>=this.j.length&&(this.s=0),this.j[this.s].postMessage(this.s,{add:!0,id:a,content:b}),this.a[a]=""+this.s,this;if(this.async)return this.h[a]||(this.c[this.c.length]=a),this.h[a]=[D.add,a,b],E(this),this;b=this.encode(b); typeof b?b:this.v||!1);this.C=a.debug||this.C;(b=a.matcher)&&this.addMatcher(b);if(b=a.filter)this.A=N(!0===b?T:b,this.v);if(b=a.stemmer)this.D=O(!0===b?H:b,this.v)}this.g=[{},{},{},{},{},{},{},{},{},{},{}];this.a={};this.h={};this.c=[];this.B=null;this.f="";this.u=!0;this.l=this.cache?new U(3E4,50,!0):!1;return this};g.prototype.encode=function(a){a&&z.length&&(a=w(a,z));a&&this.m.length&&(a=w(a,this.m));a&&this.v&&(a=this.v.call(y,a));if(a&&this.A){a=a.split(" ");for(var b=0;b<a.length;b++){var c=
if(!b.length)return this;for(var c=this.mode,e="function"===typeof c?c(b):"ngram"===c?x(b):b.split(J),d={_ctx:{}},g=this.threshold,k=this.depth,f=this.g,n=e.length,q=0;q<n;q++){var m=e[q];if(m){var r=m.length;switch(c){case "reverse":case "both":for(var t="",l=r-1;1<=l;l--)t=m[l]+t,w(f,d,t,a,b,g);case "forward":t="";for(l=0;l<r;l++)t+=m[l],w(f,d,t,a,b,g);break;case "full":for(l=0;l<r;l++)for(var A=r;A>l;A--)t=m.substring(l,A),w(f,d,t,a,b,g);break;default:if(l=w(f,d,m,a,b,g),k&&1<n&&l>g)for(l=f[10], a[b];this.A[c]&&(a[b]=this.A[c])}a=a.join(" ")}a&&this.D&&(a=w(a,this.D));return a};g.prototype.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(this.m[this.m.length]=d(b),this.m[this.m.length]=a[b]);return this};g.prototype.add=function(a,b){if("string"===typeof b&&b&&(a||0===a))if(this.a[a])this.update(a,b);else{if(this.b)return++this.s>=this.j.length&&(this.s=0),this.j[this.s].postMessage(this.s,{add:!0,id:a,content:b}),this.a[a]=""+this.s,this;if(this.async)return this.h[a]||(this.c[this.c.length]=
r=d._ctx[m]||(d._ctx[m]={}),m=l[m]||(l[m]=[{},{},{},{},{},{},{},{},{},{}]),l=q-k,A=q+k,0>l&&(l=0),A>n-1&&(A=n-1);l<=A;l++)l!==q&&w(m,r,e[l],a,b,g)}}}this.a[a]="1";this.u=!1}return this};f.prototype.update=function(a,b){if("string"===typeof b&&(a||0===a)&&this.a[a]){if(this.b){var c=parseInt(this.a[a],10);this.j[c].postMessage(c,{update:!0,id:a,content:b});return this}if(this.async)return this.h[a]||(this.c[this.c.length]=a),this.h[a]=[D.update,a,b],E(this),this;this.remove(a);b&&this.add(a,b)}return this}; a),this.h[a]=[D.add,a,b],E(this),this;b=this.encode(b);if(!b.length)return this;for(var c=this.mode,e="function"===typeof c?c(b):"ngram"===c?x(b):b.split(K),f={_ctx:{}},d=this.threshold,h=this.depth,g=this.g,n=e.length,q=0;q<n;q++){var m=e[q];if(m){var r=m.length;switch(c){case "reverse":case "both":for(var u="",l=r-1;1<=l;l--)u=m[l]+u,t(g,f,u,a,b,d);case "forward":u="";for(l=0;l<r;l++)u+=m[l],t(g,f,u,a,b,d);break;case "full":for(l=0;l<r;l++)for(var A=r;A>l;A--)u=m.substring(l,A),t(g,f,u,a,b,d);break;
f.prototype.remove=function(a){if(this.a[a]){if(this.b){var b=parseInt(this.a[a],10);this.j[b].postMessage(b,{remove:!0,id:a});delete this.a[a];return this}if(this.async)return this.h[a]||(this.c[this.c.length]=a),this.h[a]=[D.remove,a],E(this),this;for(b=0;10>b;b++)for(var c=Object.keys(this.g[b]),d=0;d<c.length;d++){var h=c[d],g=this.g[b];if((g=g&&g[h])&&g.length)for(var k=0;k<g.length;k++)if(g[k]===a){g.splice(k,1);break}g.length||delete this.g[b][h]}delete this.a[a];this.u=!1}return this};f.prototype.search= default:if(l=t(g,f,m,a,b,d),h&&1<n&&l>=d)for(l=g[10],r=f._ctx[m]||(f._ctx[m]={}),m=l[m]||(l[m]=[{},{},{},{},{},{},{},{},{},{}]),l=q-h,A=q+h,0>l&&(l=0),A>n-1&&(A=n-1);l<=A;l++)l!==q&&t(m,r,e[l],a,b,d)}}}this.a[a]="1";this.u=!1}return this};g.prototype.update=function(a,b){if("string"===typeof b&&(a||0===a)&&this.a[a]){if(this.b){var c=parseInt(this.a[a],10);this.j[c].postMessage(c,{update:!0,id:a,content:b});return this}if(this.async)return this.h[a]||(this.c[this.c.length]=a),this.h[a]=[D.update,
function(a,b,c){var d=[];if(a&&"object"===typeof a){c=a.callback||b;b=a.limit;var h=a.threshold;a=a.query}h||(h=0);"function"===typeof b?(c=b,b=1E3):b||(b=1E3);if(this.b){this.w=c;this.o=0;this.i=[];for(d=0;d<this.b;d++)this.j[d].postMessage(d,{search:!0,limit:b,threshold:h,content:a});return null}if(c){var g=this;H(function(){c(g.search(a,b));g=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return d;var k=a;if(!this.u)this.cache&&(this.f="",this.l.reset()),this.u=!0;else if(this.cache){var f= a,b],E(this),this;this.remove(a);b&&this.add(a,b)}return this};g.prototype.remove=function(a){if(this.a[a]){if(this.b){var b=parseInt(this.a[a],10);this.j[b].postMessage(b,{remove:!0,id:a});delete this.a[a];return this}if(this.async)return this.h[a]||(this.c[this.c.length]=a),this.h[a]=[D.remove,a],E(this),this;for(b=0;10>b;b++)for(var c=Object.keys(this.g[b]),e=0;e<c.length;e++){var d=c[e],k=this.g[b];if((k=k&&k[d])&&k.length)for(var h=0;h<k.length;h++)if(k[h]===a){k.splice(h,1);break}k.length||
this.l.get(a);if(f)return f}else if(this.f&&0===a.indexOf(this.f))return d;k=this.encode(k);if(!k.length)return d;f=this.mode;k="function"===typeof f?f(k):"ngram"===f?x(k):k.split(J);f=k.length;var n=!0,q=[],m={};if(1<f)if(this.depth){var r=!0,t=k[0];m[t]="1"}else k.sort(O);var l;if(!r||(l=this.g[10])[t])for(var A=r?1:0;A<f;A++){var p=k[A];if(p&&!m[p]){for(var v,w=!1,u=[],y=0,z=9;z>=h;z--)if(v=(r?l[t]:this.g)[z][p])u[y++]=v,w=!0;if(w)q[q.length]=1<y?q.concat.apply([],u):u[0];else{n=!1;break}m[p]= delete this.g[b][d]}delete this.a[a];this.u=!1}return this};g.prototype.search=function(a,b,c){var e=[];if(a&&"object"===typeof a){c=a.callback||b;b=a.limit;var d=a.threshold;a=a.query}d||(d=0);"function"===typeof b?(c=b,b=1E3):b||(b=1E3);if(this.b){this.w=c;this.o=0;this.i=[];for(e=0;e<this.b;e++)this.j[e].postMessage(e,{search:!0,limit:b,threshold:d,content:a});return null}if(c){var k=this;I(function(){c(k.search(a,b));k=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return e;
"1"}t=p}else n=!1;n&&(d=Q(q,b));d.length?this.f="":this.f||(this.f=a);this.cache&&this.l.set(a,d);return d};f.prototype.info=function(){if(this.b)for(var a=0;a<this.b;a++)this.j[a].postMessage(a,{info:!0,id:this.id});else{for(var b,c,d=0,f=0,g=0,k=0;10>k;k++)for(b=Object.keys(this.g[k]),a=0;a<b.length;a++)c=this.g[k][b[a]].length,d+=c+2*b[a].length+4,f+=c,g+=2*b[a].length;b=Object.keys(this.a);c=b.length;for(a=0;a<c;a++)d+=2*b[a].length+2;return{id:this.id,memory:d,items:c,sequences:f,chars:g,status:this.u, var h=a;if(!this.u)this.cache&&(this.f="",this.l.reset()),this.u=!0;else if(this.cache){var g=this.l.get(a);if(g)return g}else if(this.f&&0===a.indexOf(this.f))return e;h=this.encode(h);if(!h.length)return e;g=this.mode;h="function"===typeof g?g(h):"ngram"===g?x(h):h.split(K);g=h.length;var n=!0,q=[],m={};if(1<g)if(this.depth){var r=!0,u=h[0];m[u]="1"}else h.sort(P);var l;if(!r||(l=this.g[10])[u])for(var A=r?1:0;A<g;A++){var p=h[A];if(p&&!m[p]){for(var v,w=!1,t=[],y=0,z=9;z>=d;z--)if(v=(r?l[u]:this.g)[z][p])t[y++]=
cache:this.c.length,matcher:z.length,worker:this.b}}};f.prototype.reset=function(){this.destroy();return this.init()};f.prototype.destroy=function(){this.cache&&this.l.reset();this.g=this.a=this.l=null;return this};var y={icase:function(a){return a.toLowerCase()},simple:function(){var a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"), v,w=!0;if(w)q[q.length]=1<y?q.concat.apply([],t):t[0];else{n=!1;break}m[p]="1"}u=p}else n=!1;n&&(e=R(q,b));e.length?this.f="":this.f||(this.f=a);this.cache&&this.l.set(a,e);return e};g.prototype.info=function(){if(this.b)for(var a=0;a<this.b;a++)this.j[a].postMessage(a,{info:!0,id:this.id});else{for(var b,c,d=0,f=0,g=0,h=0;10>h;h++)for(b=Object.keys(this.g[h]),a=0;a<b.length;a++)c=this.g[h][b[a]].length,d+=c+2*b[a].length+4,f+=c,g+=2*b[a].length;b=Object.keys(this.a);c=b.length;for(a=0;a<c;a++)d+=
"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s\\s+")," "];return function(b){b=v(b.toLowerCase(),a);return" "!==b?b:""}}(),advanced:function(){var a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=v(b,a));c||1< 2*b[a].length+2;return{id:this.id,memory:d,items:c,sequences:f,chars:g,status:this.u,cache:this.c.length,matcher:z.length,worker:this.b}}};g.prototype.reset=function(){this.destroy();return this.init()};g.prototype.destroy=function(){this.cache&&this.l.reset();this.g=this.a=this.l=null;return this};var y={icase:function(a){return a.toLowerCase()},simple:function(){var a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),
b.length&&(b=F(b));return b}}(),extra:function(){var a=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+v(d.substring(1),a))}b=b.join(" ");b=F(b)}return b}}(),balanced:function(){var a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s\\s+")," ",d("[aeiouy]"),""];return function(b){return F(v(b.toLowerCase(),a))}}()},H= "o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s\\s+")," "];return function(b){b=w(b.toLowerCase(),a);return" "!==b?b:""}}(),advanced:function(){var a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,
function(){var a={};return function(b,c,d){var e=a[d];e&&clearTimeout(e);return a[d]=setTimeout(b,c)}}(),T=function(){function a(){this.cache={}}a.prototype.reset=function(){this.cache={}};a.prototype.set=function(a,c){this.cache[a]=c};a.prototype.get=function(a){return this.cache[a]};return a}();return f}(function(){var n={},C=!("undefined"===typeof Blob||"undefined"===typeof URL||!URL.createObjectURL);return function(f,p,d,v,w){var x=f;f=C?URL.createObjectURL(new Blob(["("+d.toString()+")()"],{type:"text/javascript"})): c){if(!b)return b;b=this.simple(b);2<b.length&&(b=w(b,a));c||1<b.length&&(b=F(b));return b}}(),extra:function(){var a=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+w(d.substring(1),a))}b=b.join(" ");b=F(b)}return b}}(),balance:function(){var a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s\\s+")," ",d("[aeiouy]"),
"../"+x+".js";x+="-"+p;n[x]||(n[x]=[]);n[x][w]=new Worker(f);n[x][w].onmessage=v;console.log("Register Worker: "+x+"@"+w);return{postMessage:function(d,f){n[x][d].postMessage(f)}}}}()),this); ""];return function(b){return F(w(b.toLowerCase(),a))}}()},I=function(){var a={};return function(b,c,d){var e=a[d];e&&clearTimeout(e);return a[d]=setTimeout(b,c)}}(),U=function(){function a(){this.cache={}}a.prototype.reset=function(){this.cache={}};a.prototype.set=function(a,c){this.cache[a]=c};a.prototype.get=function(a){return this.cache[a]};return a}();return g}(function(){var n={},C=!("undefined"===typeof Blob||"undefined"===typeof URL||!URL.createObjectURL);return function(g,p,d,w,t){var x=
g;g=C?URL.createObjectURL(new Blob(["var SUPPORT_WORKER = true;var SUPPORT_BUILTINS = true;var SUPPORT_DEBUG = true;var SUPPORT_CACHE = true;var SUPPORT_ASYNC = true;("+d.toString()+")()"],{type:"text/javascript"})):"../"+x+".js";x+="-"+p;n[x]||(n[x]=[]);n[x][t]=new Worker(g);n[x][t].onmessage=w;console.log("Register Worker: "+x+"@"+t);return{postMessage:function(d,g){n[x][d].postMessage(g)}}}}()),this);

View File

@@ -1,6 +1,6 @@
{ {
"name": "flexsearch", "name": "flexsearch",
"version": "0.2.3", "version": "0.2.32",
"description": "World's fastest and most memory efficient full text search library.", "description": "World's fastest and most memory efficient full text search library.",
"keywords": [], "keywords": [],
"bugs": { "bugs": {

File diff suppressed because one or more lines are too long

View File

@@ -152,6 +152,18 @@ var text_data = "LIBRARY OF THE FUTURE (R) First Edition Ver. 4.02 Gulliver's Tr
<td>wait ...</td> <td>wait ...</td>
</tr> </tr>
<tr id="test-10"> <tr id="test-10">
<td>"matical sical strument"</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
<td>wait ...</td>
</tr>
<tr id="test-11">
<td>"lalkon the camberlayhn"</td> <td>"lalkon the camberlayhn"</td>
<td>wait ...</td> <td>wait ...</td>
<td>wait ...</td> <td>wait ...</td>
@@ -166,11 +178,13 @@ var text_data = "LIBRARY OF THE FUTURE (R) First Edition Ver. 4.02 Gulliver's Tr
</table> </table>
</div> </div>
<br> <br>
<b>Red:</b> No results.<br>
<b>Yellow:</b> Most relevant result is not on the first place.<br>
<b>Green:</b> Most relevant result was was successfully found on the first place.<br><br>
<b>Note:</b> Open console and type e.g. <i>data[493]</i> <b>Note:</b> Open console and type e.g. <i>data[493]</i>
<script> <script>
var data = []; var data = [];
var queries = [];
setTimeout(function(){ setTimeout(function(){
@@ -192,14 +206,6 @@ var text_data = "LIBRARY OF THE FUTURE (R) First Edition Ver. 4.02 Gulliver's Tr
} }
} }
// for(var i = 0; i < 1000; i++){
//
// var pos = text_data.indexOf(' ', Math.random() * (text_data.length - 64) | 0) + 1,
// len = text_data.indexOf(' ', pos + Math.random() * 32 | 0);
//
// queries.push(text_data.substring(pos, pos + len));
// }
var bulksearch = new BulkSearch({ var bulksearch = new BulkSearch({
type: 'short', // this type specifies the maximum bitlength of assigned IDs! type: 'short', // this type specifies the maximum bitlength of assigned IDs!
encode: 'advanced', encode: 'advanced',
@@ -219,7 +225,7 @@ var text_data = "LIBRARY OF THE FUTURE (R) First Edition Ver. 4.02 Gulliver's Tr
var flexsearch = new FlexSearch({ var flexsearch = new FlexSearch({
encode: 'extra', encode: 'extra',
mode: 'strict', mode: 'strict',
threshold: 4, threshold: 5,
depth: 3, depth: 3,
filter: true, filter: true,
stemmer: true, stemmer: true,
@@ -279,15 +285,15 @@ var text_data = "LIBRARY OF THE FUTURE (R) First Edition Ver. 4.02 Gulliver's Tr
payload[i] = {id: i, content: data[i]}; payload[i] = {id: i, content: data[i]};
} }
// Note: fuse adds async // Note: fuse adds async?
//console.time('fuse'); console.time('fuse');
var fuse = new Fuse(payload.slice(0), { var fuse = new Fuse(payload.slice(0), {
keys: ['id', 'content'], keys: ['id', 'content'],
id: 'id' id: 'id'
}); });
//console.timeEnd('fuse'); console.timeEnd('fuse');
var jssearch = new JsSearch.Search('id'); var jssearch = new JsSearch.Search('id');
jssearch.addIndex('content'); jssearch.addIndex('content');
@@ -330,7 +336,8 @@ var text_data = "LIBRARY OF THE FUTURE (R) First Edition Ver. 4.02 Gulliver's Tr
do_test('test-7', 'take that to the rocks', '175'); do_test('test-7', 'take that to the rocks', '175');
do_test('test-8', 'bignes of splaknuk', '146'); do_test('test-8', 'bignes of splaknuk', '146');
do_test('test-9', 'matematikal musikal instruments', '267'); do_test('test-9', 'matematikal musikal instruments', '267');
do_test('test-10', 'lalkon the camberlayhn', '99'); do_test('test-10', 'matical sical strument', '267');
do_test('test-11', 'lalkon the camberlayhn', '99');
// --------------------------------------- // ---------------------------------------

View File

@@ -353,11 +353,12 @@ describe('Apply Sort by Scoring', function(){
expect(flexsearch_reverse.search("xxx").length).to.equal(1); expect(flexsearch_reverse.search("xxx").length).to.equal(1);
expect(flexsearch_reverse.search("yyy").length).to.equal(1); expect(flexsearch_reverse.search("yyy").length).to.equal(1);
expect(flexsearch_reverse.search("zzz").length).to.equal(0); expect(flexsearch_reverse.search("zzz").length).to.equal(1);
expect(flexsearch_reverse.search({query: "xxx", threshold: 2}).length).to.equal(1); expect(flexsearch_reverse.search({query: "xxx", threshold: 2}).length).to.equal(1);
expect(flexsearch_reverse.search({query: "xxx", threshold: 5}).length).to.equal(0); expect(flexsearch_reverse.search({query: "xxx", threshold: 5}).length).to.equal(0);
expect(flexsearch_reverse.search({query: "yyy", threshold: 2}).length).to.equal(0); expect(flexsearch_reverse.search({query: "yyy", threshold: 2}).length).to.equal(0);
expect(flexsearch_reverse.search({query: "zzz", threshold: 0}).length).to.equal(0); expect(flexsearch_reverse.search({query: "zzz", threshold: 1}).length).to.equal(0);
expect(flexsearch_reverse.search({query: "zzz", threshold: 0}).length).to.equal(1);
}); });
}); });
@@ -576,7 +577,7 @@ describe('Add (Worker)', function(){
flexsearch_worker = new FlexSearch({ flexsearch_worker = new FlexSearch({
encode: false, encode: 'icase',
mode: 'strict', mode: 'strict',
async: true, async: true,
worker: 4 worker: 4
@@ -594,10 +595,12 @@ describe('Add (Worker)', function(){
expect(flexsearch_worker.length).to.equal(3); expect(flexsearch_worker.length).to.equal(3);
expect(flexsearch_worker.index).to.have.keys([0, 1, 2]); expect(flexsearch_worker.index).to.have.keys([0, 1, 2]);
setTimeout(function(){ flexsearch_worker.search("foo", function(result){
expect(flexsearch_worker.length).to.equal(3); expect(result).to.have.length(0);
expect(flexsearch_worker.index).to.have.keys([0, 1, 2]); });
setTimeout(function(){
done(); done();
@@ -643,7 +646,7 @@ describe('Search (Worker)', function(){
flexsearch_worker.search("foobar", function(result){ flexsearch_worker.search("foobar", function(result){
expect(result).to.include(1); expect(result).to.have.members([1]);
}); });
setTimeout(function(){ setTimeout(function(){
@@ -720,14 +723,14 @@ describe('Update (Worker)', function(){
flexsearch_worker.search("foobar", function(results){ flexsearch_worker.search("foobar", function(results){
expect(results).to.include(2); expect(results).to.have.members([2]);
}); });
setTimeout(function(){ setTimeout(function(){
done(); done();
}, 25); }, 50);
}); });
}); });