mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-01 09:53:56 +02:00
v0.3.2
This commit is contained in:
@@ -360,7 +360,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
|
||||
|
||||
html += "<tr>" +
|
||||
"<td>" + test + "</td>" +
|
||||
"<td id=\"test-" + test + "\">wait ...</td>" +
|
||||
"<td id=\"test-" + test + "\">indexing ...</td>" +
|
||||
"</tr>"
|
||||
}
|
||||
}
|
||||
@@ -443,7 +443,7 @@ Test rules: 1. no cache allowed, 2. no async allowed, 3. should return at least
|
||||
|
||||
console.log(key + ":", duration);
|
||||
|
||||
document.getElementById("test-" + key).textContent = /*format_number*/((1000 / duration * loops + 0.5) >> 0) + " op/s";
|
||||
document.getElementById("test-" + key).textContent = /*format_number*/(((1000 / duration * loops * 10 + 0.5) >> 0) / 10) + " op/s";
|
||||
|
||||
if(++index < keys.length){
|
||||
|
||||
|
36
test/flexsearch.es5.js
Normal file
36
test/flexsearch.es5.js
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
FlexSearch v0.3.2
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';function J(g){var h=0;return function(){return h<g.length?{done:!1,value:g[h++]}:{done:!0}}}function K(g){var h="undefined"!=typeof Symbol&&Symbol.iterator&&g[Symbol.iterator];return h?h.call(g):{next:J(g)}}var S="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,T="function"==typeof Object.defineProperties?Object.defineProperty:function(g,h,e){g!=Array.prototype&&g!=Object.prototype&&(g[h]=e.value)};
|
||||
function U(g,h){if(h){var e=S;g=g.split(".");for(var k=0;k<g.length-1;k++){var a=g[k];a in e||(e[a]={});e=e[a]}g=g[g.length-1];k=e[g];h=h(k);h!=k&&null!=h&&T(e,g,{configurable:!0,writable:!0,value:h})}}
|
||||
U("Promise",function(g){function h(d){this.b=0;this.g=void 0;this.a=[];var a=this.c();try{d(a.resolve,a.reject)}catch(D){a.reject(D)}}function e(){this.a=null}function k(d){return d instanceof h?d:new h(function(a){a(d)})}if(g)return g;e.prototype.b=function(d){if(null==this.a){this.a=[];var a=this;this.c(function(){a.g()})}this.a.push(d)};var a=S.setTimeout;e.prototype.c=function(d){a(d,0)};e.prototype.g=function(){for(;this.a&&this.a.length;){var d=this.a;this.a=[];for(var a=0;a<d.length;++a){var h=
|
||||
d[a];d[a]=null;try{h()}catch(v){this.f(v)}}}this.a=null};e.prototype.f=function(d){this.c(function(){throw d;})};h.prototype.c=function(){function d(d){return function(e){h||(h=!0,d.call(a,e))}}var a=this,h=!1;return{resolve:d(this.s),reject:d(this.f)}};h.prototype.s=function(d){if(d===this)this.f(new TypeError("A Promise cannot resolve to itself"));else if(d instanceof h)this.u(d);else{a:switch(typeof d){case "object":var a=null!=d;break a;case "function":a=!0;break a;default:a=!1}a?this.o(d):this.j(d)}};
|
||||
h.prototype.o=function(a){var d=void 0;try{d=a.then}catch(D){this.f(D);return}"function"==typeof d?this.v(d,a):this.j(a)};h.prototype.f=function(a){this.l(2,a)};h.prototype.j=function(a){this.l(1,a)};h.prototype.l=function(a,h){if(0!=this.b)throw Error("Cannot settle("+a+", "+h+"): Promise already settled in state"+this.b);this.b=a;this.g=h;this.m()};h.prototype.m=function(){if(null!=this.a){for(var a=0;a<this.a.length;++a)l.b(this.a[a]);this.a=null}};var l=new e;h.prototype.u=function(a){var d=this.c();
|
||||
a.A(d.resolve,d.reject)};h.prototype.v=function(a,h){var d=this.c();try{a.call(h,d.resolve,d.reject)}catch(v){d.reject(v)}};h.prototype.then=function(a,e){function d(a,d){return"function"==typeof a?function(d){try{g(a(d))}catch(E){k(E)}}:d}var g,k,m=new h(function(a,d){g=a;k=d});this.A(d(a,g),d(e,k));return m};h.prototype.catch=function(a){return this.then(void 0,a)};h.prototype.A=function(a,h){function d(){switch(e.b){case 1:a(e.g);break;case 2:h(e.g);break;default:throw Error("Unexpected state: "+
|
||||
e.b);}}var e=this;null==this.a?l.b(d):this.a.push(d)};h.resolve=k;h.reject=function(a){return new h(function(d,h){h(a)})};h.race=function(a){return new h(function(d,h){for(var e=K(a),g=e.next();!g.done;g=e.next())k(g.value).A(d,h)})};h.all=function(a){var d=K(a),e=d.next();return e.done?k([]):new h(function(a,h){function g(d){return function(h){m[d]=h;l--;0==l&&a(m)}}var m=[],l=0;do m.push(void 0),l++,k(e.value).A(g(m.length-1),h),e=d.next();while(!e.done)})};return h});
|
||||
(function(g,h,e){var k;(k=e.define)&&k.amd?k([],function(){return h}):(k=e.modules)?k[g.toLowerCase()]=h:"object"===typeof exports?module.exports=h:e[g]=h})("FlexSearch",function aa(g){function e(b){E(b)&&(b=L[b]);b||(b=w);this.id=b.id||ba++;this.init(b);k(this,"index",function(){return this.a});k(this,"length",function(){return Object.keys(this.a).length})}function k(b,c,a){Object.defineProperty(b,c,{get:a})}function a(b){return new RegExp(b,"g")}function l(b,c){for(var a=0;a<c.length;a+=2)b=b.replace(c[a],
|
||||
c[a+1]);return b}function d(b,c,a,f,A,d,e){if(c[a])return c[a];A=A?(9-(e||6))*d+(e||6)*A:d;c[a]=A;A>=e&&(b=b[A+.5>>0],b=b[a]||(b[a]=[]),b[b.length]=f);return A}function m(b,c){if(b)for(var a=Object.keys(b),f=0,A=a.length;f<A;f++){var d=a[f],e=b[d];if(e)for(var r=0,g=e.length;r<g;r++)if(e[r]===c){1===g?delete b[d]:e.splice(r,1);break}else"object"===typeof e[r]&&m(e[r],c)}}function D(b){var c=[];if(!b)return c;for(var a=0,f=0,d=0,e="",g=b.length,r=0;r<g;r++){var z=b[r];"a"===z||"e"===z||"i"===z||"o"===
|
||||
z||"u"===z||"y"===z?a++:f++;" "!==z&&(e+=z);if(" "===z||a>=(8<g?2:1)&&2<=f||2<=a&&f>=(8<g?2:1)||r===g-1)e&&(c[d]&&2<e.length&&d++,c[d]=c[d]?c[d]+e:e," "===z&&d++,e=""),f=a=0}return c}function v(b){for(var c="",a="",f="",d=0;d<b.length;d++){var e=b[d];if(e!==a)if(d&&"h"===e){if(f="a"===f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f,("a"===a||"e"===a||"i"===a||"o"===a||"u"===a||"y"===a)&&f||" "===a)c+=e}else c+=e;f=d===b.length-1?"":b[d+1];a=e}return c}function V(b,c){var a={};if(b)for(var f=0;f<b.length;f++){var d=
|
||||
c?c(b[f]):b[f];a[d]=String.fromCharCode(65E3-b.length+f)}return a}function Z(b,c){var d=[];if(b)for(var f in b)if(b.hasOwnProperty(f)){var e=c?c(f):f;d.push(a("(?=.{"+(e.length+3)+",})"+e+"$"),c?c(b[f]):b[f])}return d}function W(b,c){b=b.length-c.length;return 0>b?1:b?-1:0}function X(b,c){b=b.length-c.length;return 0>b?-1:b?1:0}function Y(b,c,a){var f=[],d=[],e=b.length;if(1<e){b.sort(X);for(var g={},r=b[0],t=r.length,k=0;k<t;)g[r[k++]]=1;for(var n,p=0,q=0;++q<e;){var u=!1,m=q===e-1;d=[];r=b[q];t=
|
||||
r.length;for(k=0;k<t;)if(n=r[k++],g[n]){var l=g[n];if(l===q){if(m){if(f[p++]=n,c&&p===c)return f}else g[n]=q+1;u=!0}else a&&(l=d[l]||(d[l]=[]),l[l.length]=n)}if(!u&&!a)break}if(a&&(p=f.length,(q=d.length)&&(!c||p<c)))for(;q--;)if(n=d[q])for(b=0,a=n.length;b<a;b++)if(f[p++]=n[b],c&&p===c)return f}else e&&(f=b[0],c&&f.length>c&&(f=f.slice(0,c)));return f}function E(b){return"string"===typeof b}function H(b){return"function"===typeof b}function x(b){return"undefined"===typeof b}function B(b){b.F||(b.F=
|
||||
M(function(){b.F=0;var c=b.async;c&&(b.async=!1);if(b.b.length){for(var a=Date.now(),f;(f=b.b.shift())||0===f;){var d=b.c[f];switch(d[0]){case C.add:b.add(d[1],d[2]);break;case C.remove:b.remove(d[1])}delete b.c[f];if(100<Date.now()-a)break}b.b.length&&B(b)}c&&(b.async=c)},1,"search-async-"+b.id))}function N(b){for(var c=Array(b),a=0;a<b;a++)c[a]={};return c}function ca(b,c,a,f){b=g("flexsearch","id"+b,function(){var b,c;self.onmessage=function(a){if(a=a.data)if(a.search){var f=c.search(a.content,
|
||||
a.threshold?{limit:a.limit,threshold:a.threshold}:a.limit);self.postMessage({id:b,content:a.content,limit:a.limit,result:f})}else a.add?c.add(a.id,a.content):a.update?c.update(a.id,a.content):a.remove?c.remove(a.id):a.clear?c.clear():a.register&&(b=a.id,a.options.cache=!1,a.options.async=!0,a.options.worker=!1,c=(new Function(a.register.substring(a.register.indexOf("{")+1,a.register.lastIndexOf("}"))))(),c=new c(a.options))}},function(b){(b=b.data)&&b.result&&f(b.id,b.content,b.result,b.limit)},c);
|
||||
var d=aa.toString();a.id=c;b.postMessage(c,{register:d,options:a,id:c});return b}var w={encode:"icase",h:"forward",w:!1,cache:!1,async:!1,i:!1,threshold:0,depth:0},L={memory:{encode:"extra",h:"strict",threshold:7},speed:{encode:"icase",h:"strict",threshold:7,depth:2},match:{encode:"extra",h:"full"},score:{encode:"extra",h:"strict",threshold:5,depth:4},balance:{encode:"balance",h:"strict",threshold:6,depth:3},fastest:{encode:"icase",h:"strict",threshold:9,depth:1}},F=[],ba=0,C={add:0,update:1,remove:2},
|
||||
O=a("[ -/]"),P={},Q={},R=function(){for(var b=Object.getOwnPropertyNames({}.__proto__),c={},a=0;a<b.length;a++)c[b[a]]=1;return c}();e.create=function(b){return new e(b)};e.registerMatcher=function(b){for(var c in b)b.hasOwnProperty(c)&&F.push(a(c),b[c]);return this};e.registerEncoder=function(b,c){y[b]=c.bind(y);return this};e.registerLanguage=function(b,c){P[b]=c.filter;Q[b]=c.stemmer;return this};e.encode=function(b,c){return R[b]?c:y[b](c)};e.prototype.init=function(b){this.D=[];b||(b=w);var c=
|
||||
b.profile,a=c?L[c]:{};if(c=b.worker)if(Worker){var f=this,d=parseInt(c,10)||4;f.m=-1;f.o=0;f.f=[];f.C=null;f.j=Array(d);for(var e=0;e<d;e++)f.j[e]=ca(f.id,e,b,function(b,c,a,d){if(f.o!==f.i)return f.f=f.f.concat(a),f.o++,d&&f.f.length>=d&&(f.o=f.i),f.C&&f.o===f.i&&(f.cache&&f.g.set(c,f.f),f.C(f.f),f.f=[]),f})}else b.worker=!1,this.j=null;this.h=b.tokenize||a.h||this.h||w.h;this.async=x(c=b.async)?this.async||w.async:c;this.i=x(c=b.worker)?this.i||w.i:c;this.threshold=x(c=b.threshold)?a.threshold||
|
||||
this.threshold||w.threshold:c;this.depth=x(c=b.depth)?a.depth||this.depth||w.depth:c;this.w=x(c=b.suggest)?this.w||w.w:c;this.s=(c=x(c=b.encode)?a.encode:c)&&y[c]&&y[c].bind(y)||(H(c)?c:this.s||!1);(c=b.matcher)&&this.addMatcher(c);if(c=b.filter)this.filter=V(P[c]||c,this.s);if(c=b.stemmer)this.stemmer=Z(Q[c]||c,this.s);this.v=N(10);this.l={};this.a={};this.c={};this.b=[];this.F=0;this.u=!0;this.g=(this.cache=c=x(c=b.cache)?this.cache||w.cache:c)?new da(c):!1;return this};e.prototype.encode=function(b){b&&
|
||||
F.length&&(b=l(b,F));b&&this.D.length&&(b=l(b,this.D));b&&this.s&&(b=this.s(b));b&&this.stemmer&&(b=l(b,this.stemmer));return b};e.prototype.addMatcher=function(b){var c=this.D,d;for(d in b)b.hasOwnProperty(d)&&c.push(a(d),b[d]);return this};e.prototype.add=function(b,c,a){if(c&&E(c)&&(b&&!R[b]||0===b))if(this.a[b]&&!a)this.update(b,c);else{if(this.i)return++this.m>=this.j.length&&(this.m=0),this.j[this.m].postMessage(this.m,{add:!0,id:b,content:c}),this.a[b]=""+this.m,this;if(this.async)return this.c[b]||
|
||||
(this.b[this.b.length]=b),this.c[b]=[C.add,b,c],B(this),this;c=this.encode(c);if(!c.length)return this;a=this.h;c=H(a)?a(c):"ngram"===a?D(c):c.split(O);for(var f={_ctx:{}},e=this.threshold,g=this.depth,k=this.v,r=c.length,t=0;t<r;t++){var l=c[t];if(l){var n=l.length,p=(r-t)/r,q="";switch(a){case "reverse":case "both":for(var u=n-1;1<=u;u--)q=l[u]+q,d(k,f,q,b,(n-u)/n,p,e);q="";case "forward":for(u=0;u<n;u++)q+=l[u],d(k,f,q,b,1,p,e);break;case "full":for(u=0;u<n;u++)for(var m=(n-u)/n,v=n;v>u;v--)q=
|
||||
l.substring(u,v),d(k,f,q,b,m,p,e);break;default:if(n=d(k,f,l,b,1,p,e),g&&1<r&&n>=e)for(n=f._ctx[l]||(f._ctx[l]={}),l=this.l[l]||(this.l[l]=N(10)),p=t-g,q=t+g+1,0>p&&(p=0),q>r&&(q=r);p<q;p++)p!==t&&d(l,n,c[p],b,0,10-(p<t?t-p:p-t),e)}}}this.a[b]=1;this.u=!1}return this};e.prototype.update=function(b,c){this.a[b]&&E(c)&&(this.remove(b),this.add(b,c,!0));return this};e.prototype.remove=function(b){if(this.a[b]){if(this.i){var c=this.a[b];this.j[c].postMessage(c,{remove:!0,id:b});delete this.a[b];return this}if(this.async)return this.c[b]||
|
||||
(this.b[this.b.length]=b),this.c[b]=[C.remove,b],B(this),this;for(c=0;10>c;c++)m(this.v[c],b);this.depth&&m(this.l,b);delete this.a[b];this.u=!1}return this};e.prototype.search=function(b,c,a,f){var d=b,e=[];if("object"===typeof b){(a=b.callback||c)&&(d.callback=null);c=b.limit;var g=b.threshold;b=b.query}g||(g=this.threshold||0);H(c)?(a=c,c=1E3):c||0===c||(c=1E3);if(this.i)for(this.C=a,this.o=0,this.f=[],e=0;e<this.i;e++)this.j[e].postMessage(e,{search:!0,limit:c,threshold:g,content:b});else if(a){var k=
|
||||
this;M(function(){a(k.search(d,c,null,!0));k=null},1,"search-"+this.id)}else{if(!f&&this.async&&"function"!==typeof importScripts){var l=this;return new Promise(function(b){b(l.search(d,c,null,!0));l=null})}if(!b||!E(b))return e;d=b;if(this.cache)if(this.u){if(f=this.g.get(b))return f}else this.g.clear(),this.u=!0;d=this.encode(d);if(!d.length)return e;f=this.h;f=H(f)?f(d):"ngram"===f?D(d):d.split(O);var t=f.length,n=!0,p=[],q={};if(1<t)if(this.depth){var m=!0;var v=f[0];q[v]=1}else f.sort(W);var w;
|
||||
if(!m||(w=this.l)[v])for(var x=m?1:0;x<t;x++){var y=f[x];if(y&&!q[y]){var G=void 0;G=void 0;for(var C=!1,B=[],F=0,I=9;I>=g;I--)if(G=(m?w[v]:this.v)[I],G=G[y])B[F++]=G,C=!0;if(C)p[p.length]=1<F?p.concat.apply([],B):B[0];else if(!this.w){n=!1;break}q[y]=1}v=y}else n=!1;n&&(e=Y(p,c,this.w));this.cache&&this.g.set(b,e);return e}};e.prototype.clear=function(){this.destroy();return this.init()};e.prototype.destroy=function(){this.cache&&(this.g.clear(),this.g=null);this.filter=this.stemmer=this.v=this.l=
|
||||
this.a=this.c=this.b=null;return this};var y={icase:function(b){return b.toLowerCase()},simple:function(){var b=[a("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",a("[\u00e8\u00e9\u00ea\u00eb]"),"e",a("[\u00ec\u00ed\u00ee\u00ef]"),"i",a("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",a("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",a("[\u00fd\u0177\u00ff]"),"y",a("\u00f1"),"n",a("\u00e7"),"c",a("\u00df"),"s",a(" & ")," and ",a("[-/]")," ",a("[^a-z0-9 ]"),"",a("\\s\\s+")," "];return function(c){c=l(c.toLowerCase(),
|
||||
b);return" "!==c?c:""}}(),advanced:function(){var b=[a("ae"),"a",a("ai"),"ei",a("ay"),"ei",a("ey"),"ei",a("oe"),"o",a("ue"),"u",a("ie"),"i",a("sz"),"s",a("zs"),"s",a("sh"),"s",a("ck"),"k",a("cc"),"k",a("dt"),"t",a("ph"),"f",a("pf"),"f",a("ou"),"o",a("uo"),"u"];return function(c,a){if(!c)return c;c=this.simple(c);2<c.length&&(c=l(c,b));a||1<c.length&&(c=v(c));return c}}(),extra:function(){var b=[a("p"),"b",a("z"),"s",a("[cgq]"),"k",a("n"),"m",a("d"),"t",a("[vw]"),"f",a("[aeiouy]"),""];return function(a){if(!a)return a;
|
||||
a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(var c=0;c<a.length;c++){var d=a[c];1<d.length&&(a[c]=d[0]+l(d.substring(1),b))}a=a.join(" ");a=v(a)}return a}}(),balance:function(){var b=[a("[-/]")," ",a("[^a-z0-9 ]"),"",a("\\s\\s+")," "];return function(a){return v(l(a.toLowerCase(),b))}}()},M=function(){var b={};return function(a,d,f){var c=b[f];c&&clearTimeout(c);return b[f]=setTimeout(a,d)}}(),da=function(){function a(a){this.clear();this.B=!0!==a&&a}a.prototype.clear=function(){this.cache=
|
||||
{};this.count={};this.index={};this.a=[]};a.prototype.set=function(a,b){if(this.B&&x(this.cache[a])){var c=this.a.length;if(c===this.B){c--;var d=this.a[c];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=c;this.a[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=b};a.prototype.get=function(a){var b=this.cache[a];if(this.B&&b){var c=++this.count[a],d=this.index,e=d[a];if(0<e){for(var g=this.a,k=e;this.count[g[--e]]<=c&&-1!==e;);e++;if(e!==k){for(c=k;c>
|
||||
e;c--)k=g[c-1],g[c]=k,d[k]=c;g[e]=a;d[a]=e}}}return b};return a}();return e}(function(){var g=Object.create(null),h="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,k,a,l,d){var m=e;e=h?URL.createObjectURL(new Blob(["("+a.toString()+")()"],{type:"text/javascript"})):m+".es5.js";m+="-"+k;g[m]||(g[m]=[]);g[m][d]=new Worker(e);g[m][d].onmessage=l;return{postMessage:function(a,d){g[m][a].postMessage(d)}}}}()),this);
|
@@ -12,7 +12,7 @@
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
<!--<script src="../node_modules/mocha-phantomjs-core/browser-shim.js"></script>-->
|
||||
<script src="../flexsearch.min.js"></script>
|
||||
<script src="flexsearch.es5.js"></script>
|
||||
<script>
|
||||
window.initMochaPhantomJS && initMochaPhantomJS();
|
||||
mocha.ui('bdd');
|
||||
|
@@ -283,10 +283,10 @@ var text_data = "LIBRARY OF THE FUTURE (R) First Edition Ver. 4.02 Gulliver's Tr
|
||||
|
||||
flexsearch = new FlexSearch({
|
||||
encode: 'extra',
|
||||
mode: 'strict',
|
||||
tokenize: 'strict',
|
||||
threshold: 5,
|
||||
depth: 3,
|
||||
suggest:true,
|
||||
suggest: true,
|
||||
filter: true,
|
||||
stemmer: true,
|
||||
async: false,
|
||||
|
51
test/test.js
51
test/test.js
@@ -41,7 +41,7 @@ describe("Initialize", function(){
|
||||
|
||||
flexsearch_sync = new FlexSearch({
|
||||
|
||||
mode: "forward",
|
||||
tokenize: "forward",
|
||||
encode: false,
|
||||
async: false,
|
||||
worker: false
|
||||
@@ -49,7 +49,7 @@ describe("Initialize", function(){
|
||||
|
||||
flexsearch_async = FlexSearch.create({
|
||||
|
||||
mode: "forward",
|
||||
tokenize: "forward",
|
||||
encode: false,
|
||||
async: true,
|
||||
worker: false
|
||||
@@ -93,7 +93,7 @@ describe("Initialize", function(){
|
||||
flexsearch_strict = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
mode: "strict",
|
||||
tokenize: "strict",
|
||||
async: false,
|
||||
worker: false
|
||||
});
|
||||
@@ -101,7 +101,7 @@ describe("Initialize", function(){
|
||||
flexsearch_forward = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
mode: "forward",
|
||||
tokenize: "forward",
|
||||
async: false,
|
||||
worker: false
|
||||
});
|
||||
@@ -109,7 +109,7 @@ describe("Initialize", function(){
|
||||
flexsearch_reverse = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
mode: "reverse",
|
||||
tokenize: "reverse",
|
||||
async: false,
|
||||
worker: false
|
||||
});
|
||||
@@ -117,7 +117,7 @@ describe("Initialize", function(){
|
||||
flexsearch_full = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
mode: "full",
|
||||
tokenize: "full",
|
||||
async: false,
|
||||
worker: false
|
||||
});
|
||||
@@ -125,7 +125,7 @@ describe("Initialize", function(){
|
||||
flexsearch_ngram = new FlexSearch({
|
||||
|
||||
encode: "advanced",
|
||||
mode: "ngram",
|
||||
tokenize: "ngram",
|
||||
async: false,
|
||||
worker: false
|
||||
});
|
||||
@@ -133,7 +133,7 @@ describe("Initialize", function(){
|
||||
flexsearch_cache = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
mode: "reverse",
|
||||
tokenize: "reverse",
|
||||
cache: true
|
||||
});
|
||||
|
||||
@@ -177,12 +177,15 @@ describe("Initialize", function(){
|
||||
expect(flexsearch_async.async).to.equal(true);
|
||||
}
|
||||
|
||||
expect(flexsearch_default.mode).to.equal("forward");
|
||||
expect(flexsearch_strict.mode).to.equal("strict");
|
||||
expect(flexsearch_forward.mode).to.equal("forward");
|
||||
expect(flexsearch_reverse.mode).to.equal("reverse");
|
||||
expect(flexsearch_full.mode).to.equal("full");
|
||||
expect(flexsearch_ngram.mode).to.equal("ngram");
|
||||
if((env !== "light") && (env !== "min")){
|
||||
|
||||
expect(flexsearch_default.tokenize).to.equal("forward");
|
||||
expect(flexsearch_strict.tokenize).to.equal("strict");
|
||||
expect(flexsearch_forward.tokenize).to.equal("forward");
|
||||
expect(flexsearch_reverse.tokenize).to.equal("reverse");
|
||||
expect(flexsearch_full.tokenize).to.equal("full");
|
||||
expect(flexsearch_ngram.tokenize).to.equal("ngram");
|
||||
}
|
||||
|
||||
// not available in compiled version:
|
||||
if(typeof flexsearch_custom.encoder !== "undefined"){
|
||||
@@ -648,7 +651,7 @@ if(env !== "light"){
|
||||
flexsearch_worker = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
mode: "strict",
|
||||
tokenize: "strict",
|
||||
async: false,
|
||||
worker: 4
|
||||
});
|
||||
@@ -933,7 +936,7 @@ describe("Context", function(){
|
||||
var flexsearch_depth = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
mode: "strict",
|
||||
tokenize: "strict",
|
||||
depth: 2,
|
||||
async: false,
|
||||
worker: false
|
||||
@@ -1033,7 +1036,7 @@ describe("Relevance", function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
encode: "advanced",
|
||||
mode: "strict"
|
||||
tokenize: "strict"
|
||||
});
|
||||
|
||||
index.add(0, "1 2 3 2 4 1 5 3");
|
||||
@@ -1047,7 +1050,7 @@ describe("Relevance", function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
encode: "advanced",
|
||||
mode: "strict",
|
||||
tokenize: "strict",
|
||||
threshold: 5,
|
||||
depth: 3
|
||||
});
|
||||
@@ -1063,7 +1066,7 @@ describe("Relevance", function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
encode: "extra",
|
||||
mode: "ngram",
|
||||
tokenize: "ngram",
|
||||
threshold: 5,
|
||||
depth: 3
|
||||
});
|
||||
@@ -1094,7 +1097,7 @@ if(env !== "light"){
|
||||
|
||||
var index = new FlexSearch({
|
||||
encode: "advanced",
|
||||
mode: "strict",
|
||||
tokenize: "strict",
|
||||
suggest: true
|
||||
});
|
||||
|
||||
@@ -1207,13 +1210,15 @@ if(env !== "light" && env !== "min"){
|
||||
|
||||
"id",
|
||||
"chars",
|
||||
//"status",
|
||||
"cache",
|
||||
"items",
|
||||
"matcher",
|
||||
"memory",
|
||||
"sequences",
|
||||
"worker"
|
||||
"worker",
|
||||
"contextual",
|
||||
"depth",
|
||||
"threshold"
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -1227,7 +1232,7 @@ describe("Chaining", function(){
|
||||
|
||||
it("Should have been chained properly", function(){
|
||||
|
||||
var index = FlexSearch.create({mode: "forward", encode: "icase"})
|
||||
var index = FlexSearch.create({tokenize: "forward", encode: "icase"})
|
||||
.addMatcher({"â": "a"})
|
||||
.add(0, "foo")
|
||||
.add(1, "bar");
|
||||
|
Reference in New Issue
Block a user