flexsearch
Advanced tools
Comparing version 0.1.28 to 0.1.29
@@ -1,2 +0,2 @@ | ||
/**! | ||
;/**! | ||
* FlexSearch - Superfast lightweight full text search engine | ||
@@ -10,3 +10,3 @@ * ---------------------------------------------------------- | ||
;(function(){ | ||
(function(){ | ||
@@ -46,6 +46,3 @@ provide('FlexSearch', (function factory(register_worker){ | ||
// or pass custom encoding algorithm | ||
encode: false, | ||
// debug flag | ||
debug: true | ||
encode: false | ||
}; | ||
@@ -314,9 +311,11 @@ | ||
this.debug = ( | ||
//if(DEBUG){ | ||
options['debug'] || | ||
this.debug || | ||
defaults.debug | ||
); | ||
this.debug = ( | ||
options['debug'] || | ||
this.debug | ||
); | ||
//} | ||
if(options['matcher']) { | ||
@@ -501,3 +500,3 @@ | ||
case 'inverse': | ||
case 'reverse': | ||
case 'both': | ||
@@ -883,9 +882,4 @@ | ||
if(value){ | ||
if(value && !check_words[value]){ | ||
if(check_words[value]){ | ||
continue; | ||
} | ||
var map; | ||
@@ -902,7 +896,7 @@ var map_found = false; | ||
if(map.length){ | ||
//if(map.length){ | ||
map_check[count++] = map; | ||
map_found = true; | ||
} | ||
//} | ||
} | ||
@@ -918,2 +912,4 @@ } | ||
// TODO: handle by intersection | ||
check[check.length] = ( | ||
@@ -933,17 +929,5 @@ | ||
if(found){ | ||
if(found /*&& check.length*/){ | ||
length = check.length; | ||
// sort by length | ||
if(length > 1){ | ||
check.sort(sort_by_length_up); | ||
} | ||
if(length > 0){ | ||
result = intersect(check, limit); | ||
} | ||
result = intersect(check, limit); | ||
} | ||
@@ -1148,2 +1132,3 @@ | ||
regex_ph = regex('ph'), | ||
regex_pf = regex('pf'), | ||
regex_ou = regex('ou'), | ||
@@ -1170,2 +1155,3 @@ regex_uo = regex('uo'); | ||
regex_ph, 'f', | ||
regex_pf, 'f', | ||
regex_ou, 'o', | ||
@@ -1211,5 +1197,6 @@ regex_uo, 'u' | ||
var soundex_b = regex('p'), | ||
soundex_c = regex('[sz]'), | ||
soundex_k = regex('[gq]'), | ||
soundex_i = regex('[jy]'), | ||
//soundex_c = regex('[sz]'), | ||
soundex_s = regex('z'), | ||
soundex_k = regex('[cgq]'), | ||
//soundex_i = regex('[jy]'), | ||
soundex_m = regex('n'), | ||
@@ -1220,3 +1207,3 @@ soundex_t = regex('d'), | ||
/** @const {RegExp} */ | ||
var regex_vowel = regex('[aeiouy]'); | ||
var regex_vowel = regex('[aeiouy]'); // [aeiouy] | ||
@@ -1227,5 +1214,5 @@ /** @const {Array} */ | ||
soundex_b, 'b', | ||
soundex_c, 'c', | ||
soundex_s, 's', | ||
soundex_k, 'k', | ||
soundex_i, 'i', | ||
//soundex_i, 'i', | ||
soundex_m, 'm', | ||
@@ -1522,3 +1509,3 @@ soundex_t, 't', | ||
if((i > 0) && (char !== ' ') && (char === 'h')){ | ||
if((i > 0) && (char === 'h')){ | ||
@@ -1572,4 +1559,4 @@ var char_prev_is_vowel = ( | ||
/** | ||
* @param {!Array|string} a | ||
* @param {!Array|string} b | ||
* @param {string} a | ||
* @param {string} b | ||
* @returns {number} | ||
@@ -1598,4 +1585,4 @@ */ | ||
/** | ||
* @param {!Array|string} a | ||
* @param {!Array|string} b | ||
* @param {Array<number|string>} a | ||
* @param {Array<number|string>} b | ||
* @returns {number} | ||
@@ -1636,13 +1623,10 @@ */ | ||
arr.sort(sort_by_length_up); | ||
var map = {}; | ||
var a = arr[0]; | ||
// if(!a){ | ||
// | ||
// return []; | ||
// } | ||
for(var i = 0, length = a.length; i < length; ++i) { | ||
map[a[i]] = true; | ||
map[a[i]] = 1; | ||
} | ||
@@ -1655,9 +1639,2 @@ | ||
var b = arr[z]; | ||
// if(!b){ | ||
// | ||
// return []; | ||
// } | ||
var new_map = {}; | ||
var found = false; | ||
@@ -1667,3 +1644,3 @@ | ||
if((map[tmp = b[i]])){ | ||
if((map[tmp = b[i]]) === z){ | ||
@@ -1681,4 +1658,3 @@ if(z === (length_z - 1)){ | ||
found = true; | ||
new_map[tmp] = true; | ||
map[tmp] = false; | ||
map[tmp] = z + 1; | ||
@@ -1693,4 +1669,2 @@ break; | ||
} | ||
map = new_map; | ||
} | ||
@@ -1700,3 +1674,3 @@ | ||
} | ||
else{ | ||
else if(length_z){ | ||
@@ -1837,7 +1811,7 @@ result = arr[0]; | ||
if(flexsearch.debug){ | ||
// if(flexsearch.debug){ | ||
// | ||
// console.log("Worker Job Started: " + data['id']); | ||
// } | ||
console.log("Worker Job Started: " + data['id']); | ||
} | ||
if(data['search']){ | ||
@@ -1848,3 +1822,3 @@ | ||
'result': flexsearch['search'](data['content'], data['limit']), | ||
'result': flexsearch['search'](data['content'], data['threshold'] ? {'limit': data['limit'], 'threshold': data['threshold']} : data['limit']), | ||
'id': id, | ||
@@ -1900,4 +1874,5 @@ 'content': data['content'], | ||
) | ||
)(); | ||
)(data['options']); | ||
flexsearch = new flexsearch(data['options']); | ||
} | ||
@@ -1917,9 +1892,9 @@ } | ||
} | ||
else{ | ||
//else{ | ||
if(options['debug']){ | ||
//if(DEBUG && options['debug']){ | ||
console.log(data); | ||
} | ||
} | ||
//console.log(data); | ||
//} | ||
//} | ||
}, | ||
@@ -1995,4 +1970,7 @@ | ||
//console.log('Register Worker@' + name); | ||
//if(DEBUG){ | ||
//console.log('Register Worker: ' + name + '@' + _core); | ||
//} | ||
return { | ||
@@ -2051,1 +2029,3 @@ | ||
}).call(this); | ||
// --define='DEBUG=false' |
@@ -6,21 +6,21 @@ /* | ||
*/ | ||
'use strict';(function(l,z,e){var d;(d=e.define)&&d.amd?d([],function(){return z}):(d=e.modules)?d[l.toLowerCase()]=z:"undefined"!==typeof module?module.exports=z:e[l]=z})("FlexSearch",function D(l){function e(a){a||(a=n);this.id=a.id||E++;this.init(a);Object.defineProperty(this,"index",{get:function(){return this.a}});Object.defineProperty(this,"length",{get:function(){return Object.keys(this.a).length}})}function d(a){return new RegExp(a,"g")}function u(a,b,c){if("undefined"===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 r(a,b,c,h,f,m){b[c]||(b[c]="1",b=f.indexOf(c),f=3/f.length*(f.length-b)+6/(b-f.lastIndexOf(" ",b))+.5|0,f>m&&(a=a[f],a=a[c]||(a[c]=[]),a[a.length]=h))}function x(a){for(var b="",c="",h="",f=0;f<a.length;f++){var m=a[f];m!==c&&(0<f&&" "!==m&&"h"===m?(h="a"===h||"e"===h||"i"===h||"o"===h||"u"===h||"y"===h,"a"!==c&&"e"!==c&&"i"!==c&&"o"!==c&&"u"!==c&&"y"!==c||!h||(b+=m)):b+=m);h=f===a.length-1?"":a[f+1];c=m}return b}function p(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=[],h=a.length;if(1<h){for(var f={},m=a[0],g=0,q=m.length;g<q;++g)f[m[g]]=!0;for(var d=0,e=1;e<h;++e){var l=a[e],p={},n=!1;g=0;for(q=l.length;g<q;++g)if(f[m=l[g]]){if(e===h-1&&(c[d++]=m,b&&d===b))return c;n=!0;p[m]=!0;f[m]=!1;break}if(!n)return[];f=p}}else c=a[0],b&&c&&c.length>b&&(c=c.slice(0,b));return c}function y(a){a.w||(a.w=A(function(){a.w=null;var b=a.async;b&&(a.async= | ||
!1);if(a.f.length){for(var c=B(),h;(h=a.f.shift())||0===h;){var f=a.h[h];switch(f[0]){case w.add:a.add(f[1],f[2]);break;case w.update:a.update(f[1],f[2]);break;case w.remove:a.remove(f[1])}a.h[h]=null;delete a.h[h];if(100<B()-c)break}a.f.length&&y(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function B(){return"undefined"!==typeof performance?performance.now():(new Date).getTime()}function H(a,b,c,h){a=l("flexsearch","id"+a,function(){var a,b;self.a=function(c){if(c=c.data)b.debug&&console.log("Worker Job Started: "+ | ||
c.id),c.search?self.postMessage({result:b.search(c.content,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.debug&&console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!0,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(c.options))}},function(a){(a=a.data)&&a.result?h(a.id,a.content, | ||
a.result,a.limit):c.debug&&console.log(a)},b);var f=D.toString();c.id=b;a.postMessage(b,{register:f,options:c,id:b});return a}var n={type:"integer",mode:"forward",cache:!1,async:!1,b:!1,threshold:0,encode:!1,debug:!0},t=[],E=0,w={add:0,update:1,remove:2},C=d("[ -/]");e.new=function(a){return new this(a)};e.create=function(a){return e.new(a)};e.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(t[t.length]=d(b),t[t.length]=a[b]);return this};e.register=function(a,b){v[a]=b;return this};e.encode= | ||
function(a,b){return v[a](b)};e.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.v=null;b.j=Array(c);for(var h=0;h<c;h++)b.j[h]=H(b.id,h,a||n,function(a,c,h,d){b.o!==b.b&&(b.i=b.i.concat(h),b.o++,d&&b.i.length>=d&&(b.o=b.b),b.v&&b.o===b.b&&(b.i.length?b.g="":b.g||(b.g=c),b.cache&&b.l.set(c,b.i),b.v(b.i),b.i=[]))})}this.mode=a.mode||this.mode||n.mode;this.cache=a.cache|| | ||
this.cache||n.cache;this.async=a.async||this.async||n.async;this.b=a.worker||this.b||n.b;this.threshold=a.threshold||this.threshold||n.threshold;this.encoder=a.encode&&v[a.encode]||this.encoder||a.encode;this.debug=a.debug||this.debug||n.debug;a.matcher&&this.addMatcher(a.matcher)}this.c=[{},{},{},{},{},{},{},{},{},{}];this.a={};this.h={};this.f=[];this.w=null;this.g="";this.u=!0;this.l=this.cache?new I(3E4,50,!0):!1;return this};e.prototype.encode=function(a){a&&t.length&&(a=u(a,t));a&&this.m.length&& | ||
(a=u(a,this.m));a&&this.encoder&&(a=this.encoder(a));return a};e.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};e.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.f[this.f.length]=a),this.h[a]= | ||
[w.add,a,b],y(this),this;b=this.encode(b);if(!b.length)return this;for(var c={},h=b.constructor===Array?b:b.split(C),f=0;f<h.length;f++){var d=h[f];if(d){var g=d.length;switch(this.mode){case "inverse":case "both":for(var e="",k=g-1;1<=k;k--)e=d[k]+e,r(this.c,c,e,a,b,this.threshold);case "forward":e="";for(k=0;k<g;k++)e+=d[k],r(this.c,c,e,a,b,this.threshold);break;case "full":for(k=0;k<g;k++)for(var l=g;l>k;l--)e=d.substring(k,l),r(this.c,c,e,a,b,this.threshold);break;default:r(this.c,c,d,a,b,this.threshold)}}}this.a[a]= | ||
"1";this.u=!1}return this};e.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.f[this.f.length]=a),this.h[a]=[w.update,a,b],y(this),this;this.remove(a);b&&this.add(a,b)}return this};e.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.f[this.f.length]=a),this.h[a]=[w.remove,a],y(this),this;for(b=0;10>b;b++)for(var c=Object.keys(this.c[b]),d=0;d<c.length;d++){var f=c[d],e=this.c[b];if((e=e&&e[f])&&e.length)for(var g=0;g<e.length;g++)if(e[g]===a){e.splice(g,1);break}e.length||delete this.c[b][f]}delete this.a[a];this.u=!1}return this};e.prototype.search=function(a,b,c){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.v=c;this.o= | ||
0;this.i=[];for(var f=0;f<this.b;f++)this.j[f].postMessage(f,{search:!0,limit:b,threshold:d,content:a});return null}if(c){var e=this;A(function(){c(e.search(a,b));e=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return[];var g=a;if(!this.u)this.cache&&(this.g="",this.l.reset()),this.u=!0;else if(this.cache){var q=this.l.get(a);if(q)return q}else if(this.g&&0===a.indexOf(this.g))return[];g=this.encode(g);if(!g.length)return[];g=g.constructor===Array?g:g.split(C);q=g.length;1<q&& | ||
g.sort(p);for(var k=[],l=!0,n=[],u={},t=0;t<q;t++){var r=g[t];if(r&&!u[r]){for(var w=!1,v=[],x=0,y=9;y>=d;y--)(f=this.c[y][r])&&f.length&&(v[x++]=f,w=!0);if(w)n[n.length]=1<x?n.concat.apply([],v):v[0];else{l=!1;break}u[r]="1"}}l&&(q=n.length,1<q&&n.sort(F),0<q&&(k=G(n,b)));k.length?this.g="":this.g||(this.g=a);this.cache&&this.l.set(a,k);return k};e.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,e=0,g=0;10>g;g++)for(b= | ||
Object.keys(this.c[g]),a=0;a<b.length;a++)c=this.c[g][b[a]].length,d+=c+2*b[a].length+4,f+=c,e+=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:e,status:this.u,cache:this.f.length,matcher:t.length,worker:this.b}}};e.prototype.reset=function(){this.destroy();return this.init()};e.prototype.destroy=function(){this.cache&&this.l.reset();this.c=this.a=this.l=null;return this};var v={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]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d("[-/]")," ",d("[^a-z0-9 ]"),""];return function(b){return u(b.toLowerCase(),a)}}(),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("ou"),"o",d("uo"),"u"];return function(b,c){if(!b)return b;b=v.simple(b);2<b.length&&(b=u(b,a));c||1<b.length&&(b=x(b));return b}}(),extra:function(){var a=[d("p"),"b",d("[sz]"),"c",d("[gq]"),"k",d("[jy]"),"i",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=v.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]+u(d.substring(1), | ||
a))}b=b.join("");b=x(b)}return b}}(),ngram:function(a){var b=[];if(!a)return b;a=v.advanced(a);if(!a)return b;for(var c=0,d=0,e=-1,m="",g=a.length,l=0;l<g;l++){var k=a[l];"a"===k||"e"===k||"i"===k||"o"===k||"u"===k||"y"===k?c++:d++;" "!==k&&(m+=k);if(" "===k||2<=c&&2<=d||l===g-1){if(m){c=m.length;if(2<c||" "===k||l===g-1){if(k=m.charCodeAt(0),1<c||48<=k||57>=k)b[++e]=m}else b[e]&&(b[e]+=m);m=""}d=c=0}}return b}},A=function(){var a={};return function(b,c,d){var e=a[d];e&&clearTimeout(e);return a[d]= | ||
setTimeout(b,c)}}(),I=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 e}(function(){var l={},z=!("undefined"===typeof Blob||"undefined"===typeof URL||!URL.createObjectURL);return function(e,d,u,r,x){var p=e;e=z?URL.createObjectURL(new Blob(["("+u.toString()+")()"],{type:"text/javascript"})):"../"+p+".js";p+="-"+d;l[p]||(l[p]=[]);l[p][x]=new Worker(e); | ||
l[p][x].onmessage=r;return{postMessage:function(d,e){l[p][d].postMessage(e)}}}}()),this); | ||
'use strict';(function(k,z,e){var d;(d=e.define)&&d.amd?d([],function(){return z}):(d=e.modules)?d[k.toLowerCase()]=z:"undefined"!==typeof module?module.exports=z:e[k]=z})("FlexSearch",function D(k){function e(a){a||(a=r);this.id=a.id||E++;this.init(a);Object.defineProperty(this,"index",{get:function(){return this.a}});Object.defineProperty(this,"length",{get:function(){return Object.keys(this.a).length}})}function d(a){return new RegExp(a,"g")}function q(a,b,c){if("undefined"===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,g,f,m){b[c]||(b[c]="1",b=f.indexOf(c),f=3/f.length*(f.length-b)+6/(b-f.lastIndexOf(" ",b))+.5|0,f>m&&(a=a[f],a=a[c]||(a[c]=[]),a[a.length]=g))}function x(a){for(var b="",c="",g="",f=0;f<a.length;f++){var m=a[f];m!==c&&(0<f&&"h"===m?(g="a"===g||"e"===g||"i"===g||"o"===g||"u"===g||"y"===g,"a"!==c&&"e"!==c&&"i"!==c&&"o"!==c&&"u"!==c&&"y"!==c||!g||(b+=m)):b+=m);g=f===a.length-1?"":a[f+1];c=m}return b}function n(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=[],g=a.length;if(1<g){a.sort(F);for(var f={},m=a[0],d=0,l=m.length;d<l;++d)f[m[d]]=1;for(var h=0,e=1;e<g;++e){var k=a[e],n=!1;d=0;for(l=k.length;d<l;++d)if(f[m=k[d]]===e){if(e===g-1&&(c[h++]=m,b&&h===b))return c;n=!0;f[m]=e+1;break}if(!n)return[]}}else g&&(c=a[0],b&&c&&c.length>b&&(c=c.slice(0,b)));return c}function y(a){a.w||(a.w=A(function(){a.w=null;var b=a.async;b&&(a.async= | ||
!1);if(a.f.length){for(var c=B(),g;(g=a.f.shift())||0===g;){var f=a.h[g];switch(f[0]){case w.add:a.add(f[1],f[2]);break;case w.update:a.update(f[1],f[2]);break;case w.remove:a.remove(f[1])}a.h[g]=null;delete a.h[g];if(100<B()-c)break}a.f.length&&y(a)}b&&(a.async=b)},1,"search-async-"+a.id))}function B(){return"undefined"!==typeof performance?performance.now():(new Date).getTime()}function H(a,b,c,g){a=k("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.A&&console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!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&&g(a.id,a.content,a.result, | ||
a.limit)},b);var f=D.toString();c.id=b;a.postMessage(b,{register:f,options:c,id:b});return a}var r={type:"integer",mode:"forward",cache:!1,async:!1,b:!1,threshold:0,encode:!1},p=[],E=0,w={add:0,update:1,remove:2},C=d("[ -/]");e.new=function(a){return new this(a)};e.create=function(a){return e.new(a)};e.addMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&(p[p.length]=d(b),p[p.length]=a[b]);return this};e.register=function(a,b){u[a]=b;return this};e.encode=function(a,b){return u[a](b)};e.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.v=null;b.j=Array(c);for(var g=0;g<c;g++)b.j[g]=H(b.id,g,a||r,function(a,c,g,d){b.o!==b.b&&(b.i=b.i.concat(g),b.o++,d&&b.i.length>=d&&(b.o=b.b),b.v&&b.o===b.b&&(b.i.length?b.g="":b.g||(b.g=c),b.cache&&b.l.set(c,b.i),b.v(b.i),b.i=[]))})}this.mode=a.mode||this.mode||r.mode;this.cache=a.cache||this.cache||r.cache;this.async=a.async|| | ||
this.async||r.async;this.b=a.worker||this.b||r.b;this.threshold=a.threshold||this.threshold||r.threshold;this.encoder=a.encode&&u[a.encode]||this.encoder||a.encode;this.A=a.debug||this.A;a.matcher&&this.addMatcher(a.matcher)}this.c=[{},{},{},{},{},{},{},{},{},{}];this.a={};this.h={};this.f=[];this.w=null;this.g="";this.u=!0;this.l=this.cache?new I(3E4,50,!0):!1;return this};e.prototype.encode=function(a){a&&p.length&&(a=q(a,p));a&&this.m.length&&(a=q(a,this.m));a&&this.encoder&&(a=this.encoder(a)); | ||
return a};e.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};e.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.f[this.f.length]=a),this.h[a]=[w.add,a,b],y(this),this;b=this.encode(b);if(!b.length)return this; | ||
for(var c={},g=b.constructor===Array?b:b.split(C),f=0;f<g.length;f++){var d=g[f];if(d){var e=d.length;switch(this.mode){case "reverse":case "both":for(var l="",h=e-1;1<=h;h--)l=d[h]+l,v(this.c,c,l,a,b,this.threshold);case "forward":l="";for(h=0;h<e;h++)l+=d[h],v(this.c,c,l,a,b,this.threshold);break;case "full":for(h=0;h<e;h++)for(var k=e;k>h;k--)l=d.substring(h,k),v(this.c,c,l,a,b,this.threshold);break;default:v(this.c,c,d,a,b,this.threshold)}}}this.a[a]="1";this.u=!1}return this};e.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.f[this.f.length]=a),this.h[a]=[w.update,a,b],y(this),this;this.remove(a);b&&this.add(a,b)}return this};e.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.f[this.f.length]= | ||
a),this.h[a]=[w.remove,a],y(this),this;for(b=0;10>b;b++)for(var c=Object.keys(this.c[b]),d=0;d<c.length;d++){var f=c[d],e=this.c[b];if((e=e&&e[f])&&e.length)for(var t=0;t<e.length;t++)if(e[t]===a){e.splice(t,1);break}e.length||delete this.c[b][f]}delete this.a[a];this.u=!1}return this};e.prototype.search=function(a,b,c){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.v=c;this.o=0;this.i=[];for(var f= | ||
0;f<this.b;f++)this.j[f].postMessage(f,{search:!0,limit:b,threshold:d,content:a});return null}if(c){var e=this;A(function(){c(e.search(a,b));e=null},1,"search-"+this.id);return null}if(!a||"string"!==typeof a)return[];f=a;if(!this.u)this.cache&&(this.g="",this.l.reset()),this.u=!0;else if(this.cache){var t=this.l.get(a);if(t)return t}else if(this.g&&0===a.indexOf(this.g))return[];f=this.encode(f);if(!f.length)return[];f=f.constructor===Array?f:f.split(C);t=f.length;1<t&&f.sort(n);for(var l=[],h=!0, | ||
k=[],r={},q=0;q<t;q++){var p=f[q];if(p&&!r[p]){for(var v,w=!1,u=[],x=0,y=9;y>=d;y--)if(v=this.c[y][p])u[x++]=v,w=!0;if(w)k[k.length]=1<x?k.concat.apply([],u):u[0];else{h=!1;break}r[p]="1"}}h&&(l=G(k,b));l.length?this.g="":this.g||(this.g=a);this.cache&&this.l.set(a,l);return l};e.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,e=0,k=0;10>k;k++)for(b=Object.keys(this.c[k]),a=0;a<b.length;a++)c=this.c[k][b[a]].length, | ||
d+=c+2*b[a].length+4,f+=c,e+=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:e,status:this.u,cache:this.f.length,matcher:p.length,worker:this.b}}};e.prototype.reset=function(){this.destroy();return this.init()};e.prototype.destroy=function(){this.cache&&this.l.reset();this.c=this.a=this.l=null;return this};var u={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]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d("[-/]")," ",d("[^a-z0-9 ]"),""];return function(b){return q(b.toLowerCase(),a)}}(),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=u.simple(b);2<b.length&&(b=q(b,a));c||1<b.length&&(b=x(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=u.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]+q(d.substring(1),a))}b=b.join("");b=x(b)}return b}}(),ngram:function(a){var b= | ||
[];if(!a)return b;a=u.advanced(a);if(!a)return b;for(var c=0,d=0,f=-1,e="",k=a.length,l=0;l<k;l++){var h=a[l];"a"===h||"e"===h||"i"===h||"o"===h||"u"===h||"y"===h?c++:d++;" "!==h&&(e+=h);if(" "===h||2<=c&&2<=d||l===k-1){if(e){c=e.length;if(2<c||" "===h||l===k-1){if(h=e.charCodeAt(0),1<c||48<=h||57>=h)b[++f]=e}else b[f]&&(b[f]+=e);e=""}d=c=0}}return b}},A=function(){var a={};return function(b,c,d){var f=a[d];f&&clearTimeout(f);return a[d]=setTimeout(b,c)}}(),I=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 e}(function(){var k={},z=!("undefined"===typeof Blob||"undefined"===typeof URL||!URL.createObjectURL);return function(e,d,q,v,x){var n=e;e=z?URL.createObjectURL(new Blob(["("+q.toString()+")()"],{type:"text/javascript"})):"../"+n+".js";n+="-"+d;k[n]||(k[n]=[]);k[n][x]=new Worker(e);k[n][x].onmessage=v;return{postMessage:function(d,e){k[n][d].postMessage(e)}}}}()), | ||
this); |
{ | ||
"name": "flexsearch", | ||
"version": "0.1.28", | ||
"version": "0.1.29", | ||
"description": "Superfast, lightweight and memory efficient full text search library.", | ||
@@ -42,3 +42,3 @@ "keywords": [], | ||
"mocha-phantomjs": "^4.1.0", | ||
"nyc": "^11.5.0", | ||
"nyc": "^11.6.0", | ||
"phantomjs-prebuilt": "^2.1.16", | ||
@@ -45,0 +45,0 @@ "updtr": "^2.0.0" |
151
README.md
@@ -17,3 +17,3 @@ <p align="center"> | ||
When it comes to raw search speed __FlexSearch outperforms every single searching library out there__ 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 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. | ||
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 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. | ||
@@ -53,3 +53,3 @@ Benchmark: | ||
__Note:__ It is slightly faster to use no web worker when the index isn't too big (< 100,000 words). | ||
__Note:__ It is slightly faster to use no web worker when the index or query isn't too big (index < 500,000 words, query < 25 words). | ||
@@ -79,4 +79,4 @@ #### Compare BulkSearch vs. FlexSearch | ||
<td>Usecase</td> | ||
<td><ul><li>Limited content</li><li>Index needs to be updated continously (add, update, remove)</li><li>Boost query time through pagination</li></ul></td> | ||
<td><ul><li>Fastest possible search</li><li>Rare updates on index</li><li>Max out memory capabilities</li></ul></td> | ||
<td><ul><li>Limited content</li><li>Use when existing items of the index needs to be updated continously (update, remove)</li><li>Supports pagination</li></ul></td> | ||
<td><ul><li>Fastest possible search</li><li>Existing items of the index does not need to be updated continously (update, remove)</li><li>Max out memory capabilities</li></ul></td> | ||
</tr> | ||
@@ -299,3 +299,3 @@ <tr></tr> | ||
``` | ||
<a name="flexsearch.encoder"></a> | ||
#### Add custom encoder | ||
@@ -411,14 +411,17 @@ | ||
<tr> | ||
<td align="top">mode</td> | ||
<td align="top">mode<br><br><br><br><br></td> | ||
<td vertical="top" vertical-align="top"> | ||
"strict"<br> | ||
"foward"<br> | ||
"inverse"<br> | ||
"reverse"<br> | ||
"ngram"<br> | ||
"full" | ||
</td> | ||
<td vertical-align="top">The indexing mode.</td> | ||
<td vertical-align="top"> | ||
The <a href="#tokenizer">indexing mode (tokenizer)</a>.<br><br><br><br><br> | ||
</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td align="top">encode</td> | ||
<td align="top">encode<br><br><br><br><br><br></td> | ||
<td> | ||
@@ -430,5 +433,5 @@ false<br> | ||
"extra"<br> | ||
function(string):string | ||
function() | ||
</td> | ||
<td>The encoding type. Choose one of the built-ins or pass a custom encoding function.</td> | ||
<td>The encoding type.<br><br>Choose one of the <a href="#phonetic">built-ins</a> or pass a <a href="#flexsearch.encoder">custom encoding function</a>.<br><br><br><br></td> | ||
</tr> | ||
@@ -438,3 +441,3 @@ <!-- | ||
<tr> | ||
<td align="top">boolean</td> | ||
<td align="top">boolean<br><br></td> | ||
<td> | ||
@@ -448,3 +451,3 @@ "and"<br> | ||
<tr> | ||
<td align="top">multi</td> | ||
<td align="top">multi<br><br></td> | ||
<td> | ||
@@ -454,3 +457,3 @@ true<br> | ||
</td> | ||
<td>Enable multi word processing.</td> | ||
<td>Enable multi word processing.<br><br></td> | ||
</tr> | ||
@@ -460,3 +463,3 @@ --> | ||
<tr> | ||
<td align="top">cache</td> | ||
<td align="top">cache<br><br></td> | ||
<td> | ||
@@ -466,7 +469,7 @@ true<br> | ||
</td> | ||
<td>Enable/Disable caching.</td> | ||
<td>Enable/Disable caching.<br><br></td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td align="top">async</td> | ||
<td align="top">async<br><br></td> | ||
<td> | ||
@@ -476,7 +479,7 @@ true<br> | ||
</td> | ||
<td>Enable/Disable asynchronous processing.</td> | ||
<td>Enable/Disable asynchronous processing.<br><br></td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td align="top">worker</td> | ||
<td align="top">worker<br><br></td> | ||
<td> | ||
@@ -486,7 +489,55 @@ false<br> | ||
</td> | ||
<td>Enable and also count of running worker threads.</td> | ||
<td>Enable/Disable and set count of running worker threads.<br><br></td> | ||
</tr> | ||
</table> | ||
<a name="phonetic" id="phonetic"></a> | ||
<a name="tokenizer"></a> | ||
## Tokenizer | ||
<table> | ||
<tr></tr> | ||
<tr> | ||
<td align="left">Option</td> | ||
<td align="left">Description</td> | ||
<td align="left">Example</td> | ||
<td align="left">Memory Factor (n = length of word)</td> | ||
</tr> | ||
<tr> | ||
<td><b>"strict"</b></td> | ||
<td>index whole words</td> | ||
<td><b>foobar</b></td> | ||
<td>* 1</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td><b>"foward"</b></td> | ||
<td>incrementally index words in forward direction</td> | ||
<td><b>fo</b>obar<br><b>foob</b>ar<br></td> | ||
<td>* n</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td><b>"reverse"</b></td> | ||
<td>incrementally index words in both directions</td> | ||
<td>foob<b>ar</b><br>fo<b>obar</b></td> | ||
<td>* 2n</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td><b>"ngram"</b> (default)</td> | ||
<td>index words partially through phonetic n-grams</td> | ||
<td><b>foo</b>bar<br>foo<b>bar</b></td> | ||
<td>* n/4</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td><b>"full"</b></td> | ||
<td>index every possible combination</td> | ||
<td>fo<b>oba</b>r<br>f<b>oob</b>ar</td> | ||
<td>* n*(n-1)</td> | ||
</tr> | ||
</table> | ||
<a name="phonetic"></a> | ||
## Phonetic Encoding | ||
@@ -510,3 +561,3 @@ | ||
<tr> | ||
<td><b>"icase"</b></td> | ||
<td><b>"icase"</b> (default)</td> | ||
<td>Case in-sensitive encoding</td> | ||
@@ -539,6 +590,6 @@ <td>no</td> | ||
<tr> | ||
<td><b>"ngram"</b></td> | ||
<td>Phonetic normalizations + N-Gram sequencing</td> | ||
<td>yes</td> | ||
<td>~ 40%</td> | ||
<td><b>function()</b></td> | ||
<td>Pass custom encoding: function(string):string</td> | ||
<td></td> | ||
<td></td> | ||
</tr> | ||
@@ -548,3 +599,3 @@ </table> | ||
<a name="compare" id="compare"></a> | ||
### Compare Phonetic Encoder | ||
#### Comparison | ||
@@ -561,3 +612,2 @@ Reference String: __"Björn-Phillipp Mayer"__ | ||
<td align="left">Extra</td> | ||
<td align="left">N-Gram</td> | ||
</tr> | ||
@@ -570,3 +620,2 @@ <tr> | ||
<td><b>yes</b></td> | ||
<td><b>yes</b></td> | ||
</tr> | ||
@@ -580,3 +629,2 @@ <tr></tr> | ||
<td><b>yes</b></td> | ||
<td>no</td> | ||
</tr> | ||
@@ -590,3 +638,2 @@ <tr></tr> | ||
<td><b>yes</b></td> | ||
<td><b>yes</b></td> | ||
</tr> | ||
@@ -600,3 +647,2 @@ <tr></tr> | ||
<td><b>yes</b></td> | ||
<td><b>yes</b></td> | ||
</tr> | ||
@@ -610,3 +656,2 @@ <tr></tr> | ||
<td><b>yes</b></td> | ||
<td><b>yes</b></td> | ||
</tr> | ||
@@ -620,3 +665,2 @@ <tr></tr> | ||
<td><b>yes</b></td> | ||
<td><b>yes</b></td> | ||
</tr> | ||
@@ -630,3 +674,2 @@ <tr></tr> | ||
<td><b>yes</b></td> | ||
<td>no</td> | ||
</tr> | ||
@@ -640,3 +683,2 @@ <tr></tr> | ||
<td><b>yes</b></td> | ||
<td><b>yes</b></td> | ||
</tr> | ||
@@ -650,3 +692,2 @@ <tr></tr> | ||
<td><b>yes</b></td> | ||
<td><b>yes</b></td> | ||
</tr> | ||
@@ -660,3 +701,2 @@ <tr></tr> | ||
<td><b>yes</b></td> | ||
<td><b>yes</b></td> | ||
</tr> | ||
@@ -669,3 +709,2 @@ <tr></tr> | ||
<td>no</td> | ||
<td>no</td> | ||
<td><b>yes</b></td> | ||
@@ -679,3 +718,2 @@ </tr> | ||
<td>yes</td> | ||
<td><b>no</b></td> | ||
</tr> | ||
@@ -685,3 +723,3 @@ </table> | ||
<a name="memory" id="memory"></a> | ||
## Compare Memory Usage | ||
## Memory Usage | ||
@@ -697,3 +735,8 @@ __Note:__ The required memory depends on several options. | ||
<tr> | ||
<td>"icase" (default) / false</td> | ||
<td>false</td> | ||
<td>260 kb</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>"icase" (default)</td> | ||
<td>210 kb</td> | ||
@@ -716,29 +759,29 @@ </tr> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>"ngram"</td> | ||
<td>110 kb</td> | ||
</tr> | ||
<tr> | ||
<td align="left">Mode</td> | ||
<td align="left">Multiplied with:</td> | ||
<td align="left">Multiplied with: (n = <u>average</u> length of all words)</td> | ||
</tr> | ||
<tr> | ||
<td>"strict"</td> | ||
<td>x 1</td> | ||
<td>* 1</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>"forward" (default)</td> | ||
<td>x 1.5</td> | ||
<td>"forward"</td> | ||
<td>* n</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>"inverse"</td> | ||
<td>x 2</td> | ||
<td>"reverse"</td> | ||
<td>* 2n</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>"ngram" (default)</td> | ||
<td>* n/4</td> | ||
</tr> | ||
<tr></tr> | ||
<tr> | ||
<td>"full"</td> | ||
<td>x 2.3</td> | ||
<td>* n*(n-1)</td> | ||
</tr> | ||
@@ -745,0 +788,0 @@ </table> |
@@ -28,3 +28,3 @@ if(typeof module !== 'undefined'){ | ||
var flexsearch_forward; | ||
var flexsearch_inverse; | ||
var flexsearch_reverse; | ||
var flexsearch_full; | ||
@@ -108,6 +108,6 @@ var flexsearch_ngram; | ||
flexsearch_inverse = new FlexSearch({ | ||
flexsearch_reverse = new FlexSearch({ | ||
encode: 'icase', | ||
mode: 'inverse', | ||
mode: 'reverse', | ||
async: false, | ||
@@ -136,3 +136,3 @@ worker: false | ||
encode: 'icase', | ||
mode: 'inverse', | ||
mode: 'reverse', | ||
cache: true | ||
@@ -177,3 +177,3 @@ }); | ||
expect(flexsearch_forward.mode).to.equal("forward"); | ||
expect(flexsearch_inverse.mode).to.equal("inverse"); | ||
expect(flexsearch_reverse.mode).to.equal("reverse"); | ||
expect(flexsearch_full.mode).to.equal("full"); | ||
@@ -216,2 +216,10 @@ expect(flexsearch_ngram.mode).to.equal("strict"); | ||
expect(flexsearch_extra.length).to.equal(0); | ||
flexsearch_extra.add(4, "Thomas"); | ||
flexsearch_extra.add(5, "Arithmetic"); | ||
flexsearch_extra.add(6, "Mahagoni"); | ||
expect(flexsearch_extra.search("tomass")).to.include(4); | ||
expect(flexsearch_extra.search("arytmetik")).to.include(5); | ||
expect(flexsearch_extra.search("mahagony")).to.include(6); | ||
}); | ||
@@ -337,11 +345,11 @@ }); | ||
flexsearch_inverse.add(0, "foobarxxx foobarfoobarfoobarxxx foobarfoobarfoobaryyy foobarfoobarfoobarzzz"); | ||
flexsearch_reverse.add(0, "foobarxxx foobarfoobarfoobarxxx foobarfoobarfoobaryyy foobarfoobarfoobarzzz"); | ||
expect(flexsearch_inverse.search("xxx").length).to.equal(1); | ||
expect(flexsearch_inverse.search("yyy").length).to.equal(1); | ||
expect(flexsearch_inverse.search("zzz").length).to.equal(0); | ||
expect(flexsearch_inverse.search({query: "xxx", threshold: 2}).length).to.equal(1); | ||
expect(flexsearch_inverse.search({query: "xxx", threshold: 5}).length).to.equal(0); | ||
expect(flexsearch_inverse.search({query: "yyy", threshold: 2}).length).to.equal(0); | ||
expect(flexsearch_inverse.search({query: "zzz", threshold: 0}).length).to.equal(0); | ||
expect(flexsearch_reverse.search("xxx").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({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: "yyy", threshold: 2}).length).to.equal(0); | ||
expect(flexsearch_reverse.search({query: "zzz", threshold: 0}).length).to.equal(0); | ||
}); | ||
@@ -566,2 +574,3 @@ }); | ||
encode: false, | ||
mode: 'strict', | ||
async: true, | ||
@@ -845,7 +854,7 @@ worker: 4 | ||
flexsearch_inverse.add(0, "björn phillipp mayer"); | ||
flexsearch_reverse.add(0, "björn phillipp mayer"); | ||
expect(flexsearch_inverse.length).to.equal(1); | ||
expect(flexsearch_inverse.search("jörn phil yer")).to.have.lengthOf(1); | ||
expect(flexsearch_inverse.search("jörn phil yer")).to.include(0); | ||
expect(flexsearch_reverse.length).to.equal(1); | ||
expect(flexsearch_reverse.search("jörn phil yer")).to.have.lengthOf(1); | ||
expect(flexsearch_reverse.search("jörn phil yer")).to.include(0); | ||
}); | ||
@@ -852,0 +861,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123572
762
2122