mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-09-01 18:03:56 +02:00
Update Readme
This commit is contained in:
14
README.md
14
README.md
@@ -754,7 +754,7 @@ index.search("John", {
|
||||
<a name="pagination"></a>
|
||||
#### Pagination
|
||||
|
||||
FlexSearch is providing a cursor-based pagination which has the ability to inject into the most-inner process. This enables a lot of possible performance improvements.
|
||||
FlexSearch is providing a cursor-based pagination which has the ability to inject into the most-inner process. This enables the possibility of many performance improvements.
|
||||
|
||||
> The cursor implementation may be changed often. Just take the cursor as it is and do not expect any specific value or format.
|
||||
|
||||
@@ -1830,7 +1830,7 @@ FlexSearch ist highly customizable. Make use of the the <a href="#presets">right
|
||||
false<br>
|
||||
{number}
|
||||
</td>
|
||||
<td>Enable/Disable <a href="#contextual">contextual indexing</a> and also sets contextual distance of relevance.</td>
|
||||
<td>Enable/Disable <a href="#contextual">contextual indexing</a> and also sets contextual distance of relevance. Depth is the maximum number of words/tokens away a term to be considered as relevant.</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
@@ -1880,6 +1880,16 @@ FlexSearch ist highly customizable. Make use of the the <a href="#presets">right
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## Depth, Threshold, Resolution?
|
||||
|
||||
Whereas __depth is the minimum relevance for the context-based index__, __threshold is the minimum relevance for the lexical index__. Threshold is an enhanced variation of a conventional scoring calculation, it uses document distance and partial distance instead of TF-IDF. The final scoring value is based on <a href="#contextual">3 kinds of distance</a>.
|
||||
|
||||
Resolution on the other hand specify the max scoring value. The final score value is an integer value, so resolution affect how many segments the score may have. When the resolution is 1, then there exist just one scoring level for all matched terms. To get more differentiated results you need to raise the resolution.
|
||||
|
||||
> The difference of both (_resolution_ - _threshold_) affects the performance on higher values.
|
||||
|
||||
The combination of resolution and threshold gives you a good controlling of your matches as well as performance, e.g. when the resolution is 25 and the threshold is 22, then the result only contains matches which are super relevant. The goal should always be just have items in result which are really needed. On top, that also improves performance a lot.
|
||||
|
||||
<a name="tokenizer"></a>
|
||||
## Tokenizer
|
||||
|
||||
|
6
dist/flexsearch.compact.js
vendored
6
dist/flexsearch.compact.js
vendored
@@ -6,7 +6,7 @@
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(l,F,G){let A;(A=G.define)&&A.amd?A([],function(){return F}):(A=G.modules)?A[l.toLowerCase()]=F:"object"===typeof exports?module.exports=F:G[l]=F})("FlexSearch",function(){function l(b,a){const c=a?a.id:b&&b.id;this.id=c||0===c?c:Z++;this.init(b,a);A(this,"index",function(){return this.a?Object.keys(this.a.index[this.a.keys[0]].f):Object.keys(this.f)});A(this,"length",function(){return this.index.length})}function F(b,a){const c=b.length,d=H(a),e=[];for(let h=0,g=0;h<c;h++){const c=
|
||||
b[h];if(d&&a(c)||!d&&!a[c])e[g++]=c}return e}function G(b,a,c,d,e,h,g,m,n,f){c=R(c,g?0:e,m,!1,a,n,f);let k;m&&(m=c.page,k=c.next,c=c.result);if(g)b=this.where(g,null,e,c);else{b=c;a=this.g;c=b.length;e=Array(c);for(h=0;h<c;h++)e[h]=a[b[h]];b=e}c=b;d&&(H(d)||(u=d.split(":"),1<u.length?d=aa:(u=u[0],d=ba)),c.sort(d));return c=I(m,k,c)}function A(b,a,c){Object.defineProperty(b,a,{get:c})}function f(b){return new RegExp(b,"g")}function J(b,a){for(let c=0;c<a.length;c+=2)b=b.replace(a[c],a[c+1]);return b}
|
||||
b[h];if(d&&a(c)||!d&&!a[c])e[g++]=c}return e}function G(b,a,c,d,e,h,g,m,n,f){c=R(c,g?0:e,!1,!1,a,n,f);let k;m&&(m=c.page,k=c.next,c=c.result);if(g)b=this.where(g,null,e,c);else{b=c;a=this.g;c=b.length;e=Array(c);for(h=0;h<c;h++)e[h]=a[b[h]];b=e}c=b;d&&(H(d)||(u=d.split(":"),1<u.length?d=aa:(u=u[0],d=ba)),c.sort(d));return c=I(m,k,c)}function A(b,a,c){Object.defineProperty(b,a,{get:c})}function f(b){return new RegExp(b,"g")}function J(b,a){for(let c=0;c<a.length;c+=2)b=b.replace(a[c],a[c+1]);return b}
|
||||
function M(b,a,c,d,e,h,g,m){if(a[c])return a[c];e=e?(m-(g||m/1.5))*h+(g||m/1.5)*e:h;a[c]=e;e>=g&&(b=b[m-(e+.5>>0)],b=b[c]||(b[c]=[]),b[b.length]=d);return e}function O(b,a){if(b){const c=Object.keys(b);for(let d=0,e=c.length;d<e;d++){const e=c[d],g=b[e];if(g)for(let c=0,d=g.length;c<d;c++)if(g[c]===a){1===d?delete b[e]:g.splice(c,1);break}else K(g[c])&&O(g[c],a)}}}function P(b){let a="",c="";var d="";for(let e=0;e<b.length;e++){const h=b[e];if(h!==c)if(e&&"h"===h){if(d="a"===d||"e"===d||"i"===d||
|
||||
"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)a+=h}else a+=h;d=e===b.length-1?"":b[e+1];c=h}return a}function ca(b,a){b=b.length-a.length;return 0>b?1:b?-1:0}function ba(b,a){b=b[u];a=a[u];return b<a?-1:b>a?1:0}function aa(b,a){const c=u.length;for(let d=0;d<c;d++)b=b[u[d]],a=a[u[d]];return b<a?-1:b>a?1:0}function I(b,a,c){return b?{page:b,next:a?""+a:null,result:c}:c}function R(b,a,c,d,e,h,g){let m;h=[];let n;const f=b.length;!0===c?(c="0",n=""):n=c&&
|
||||
c.split(":");if(1<f){const v=x();let q=[],l,y,t=-1;var k;let B;let T=!0,D,C=0,u,z,p;n&&(2===n.length?(p=n,n=!1):n=parseInt(n[0],10));if(g){for(l=x();++t<f;)if("not"===e[t])for(y=b[t],B=y.length,k=0;k<B;)l["@"+y[k++]]=1;else z=t+1;if(!z)return I(c,m,h);t=-1}else u=E(e)&&e;for(;++t<f;){const da=t===(z||f)-1;let p,x;if(!u||!t)if((k=u||e&&e[t])&&"and"!==k)if("or"===k)x=!0;else continue;else p=!0;y=b[t];B=y.length;if(!B){if(p&&!d)return I(c,m,y);continue}if(T)if(D){var w=D.length;for(k=0;k<w;)v["@"+D[k++]]=
|
||||
@@ -21,8 +21,8 @@ typeof importScripts){let e=this;h=new Promise(function(c){setTimeout(function()
|
||||
f;--k;)v=g[k]+v,M(y,m,v,b,t?1:(f-k)/f,n,l,p-1);v="";case "forward":for(k=0;k<f;k++)v+=g[k],M(y,m,v,b,t?(k+1)/f:1,n,l,p-1);break;case "full":for(k=0;k<f;k++){const a=(t?k+1:f-k)/f;for(let c=f;c>k;c--)v=g.substring(k,c),M(y,m,v,b,a,n,l,p-1)}break;default:if(f=M(y,m,g,b,1,n,l,p-1),q&&1<r&&f>=l)for(f=m._ctx[g]||(m._ctx[g]=x()),g=this.h[g]||(this.h[g]=U(p-(l||0))),n=a-q,v=a+q+1,0>n&&(n=0),v>r&&(v=r);n<v;n++)n!==a&&M(g,f,e[n],b,0,p-(n<a?a-n:n-a),l,p-1)}}}this.f[h]=1}return this};l.prototype.j=function(b,
|
||||
a,c){if(z(a))for(let d=0,e=a.length;d<e;d++){if(d===e-1)return this.j(b,a[d],c);this.j(b,a[d])}else{const n=this.a.index,l=this.a.keys;var d=this.a.tag,e=this.a.id;let k;let m;for(var h=0;h<e.length;h++)k=(k||a)[e[h]];if(d){for(e=0;e<d.length;e++){var g=d[e];var f=g.split(":");for(h=0;h<f.length;h++)m=(m||a)[f[h]];m="@"+m}f=this.s[g];f=f[m]||(f[m]=[])}if("remove"===b){delete this.g[k];for(let a=0,b=l.length;a<b;a++){if(a===b-1)return n[l[a]].remove(k,c);n[l[a]].remove(k)}}e=this.a.field;f&&(f[f.length]=
|
||||
a);for(let f=0,h=e.length;f<h;f++){d=e[f];let m;for(g=0;g<d.length;g++)m=(m||a)[d[g]];this.g[k]=a;d=n[l[f]];g="add"===b?d.add:d.update;if(f===h-1)return g.call(d,k,m,c);g.call(d,k,m)}}};l.prototype.update=function(b,a,c){if(this.a&&K(b))return this.j("update",b,a);this.f["@"+b]&&E(a)&&(this.remove(b),this.add(b,a,c,!0));return this};l.prototype.remove=function(b,a,c){if(this.a&&K(b))return this.j("remove",b,a);var d="@"+b;if(this.f[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=
|
||||
this;d=new Promise(function(a){setTimeout(function(){c.remove(b,null,!0);c=null;a()})});if(a)d.then(a);else return d;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<this.b-(this.threshold||0);a++)O(this.l[a],b);this.depth&&O(this.h,b);delete this.f[d]}return this};let u;l.prototype.search=function(b,a,c,d){if(K(a)){if(z(a))for(var e=0;e<a.length;e++)a[e].query=b;else a.query=b;b=a;a=0}let f=[],g=b;let m,l,p;if(K(b)&&!z(b)){(c=b.callback||H(a)&&a)&&(g.callback=null);l=b.sort;m=b.page;
|
||||
a=b.limit;var k=b.threshold;p=!1;b=b.query}if(this.a){k=this.a.index;var w=g.bool||"or",r=g.field;let h=w;let n,B;if(r)z(r)||(r=[r]);else if(z(g)){var u=g;r=[];h=[];for(var q=0;q<g.length;q++)d=g[q],e=d.bool||w,r[q]=d.field,h[q]=e,"not"===e?n=!0:"and"===e&&(B=!0)}else r=this.a.keys;w=r.length;for(q=0;q<w;q++)u&&(g=u[q]),E(g)||(g.page=null,g.limit=0),f[q]=k[r[q]].search(g,0);if(c)return c(G.call(this,b,h,f,l,a,p,!1,m,B,n));if(this.async){const c=this;return new Promise(function(d){Promise.all(f).then(function(e){d(G.call(c,
|
||||
this;d=new Promise(function(a){setTimeout(function(){c.remove(b,null,!0);c=null;a()})});if(a)d.then(a);else return d;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=0;a<this.b-(this.threshold||0);a++)O(this.l[a],b);this.depth&&O(this.h,b);delete this.f[d]}return this};let u;l.prototype.search=function(b,a,c,d){if(K(a)){if(z(a))for(var e=0;e<a.length;e++)a[e].query=b;else a.query=b;b=a;a=0}let f=[],g=b;let m,l,p;if(K(b)&&!z(b)){(c=b.callback||H(a)&&a)&&(g.callback=null);l=b.sort;m=!1;
|
||||
a=b.limit;var k=b.threshold;p=!1;b=b.query}if(this.a){k=this.a.index;var w=g.bool||"or",r=g.field;let h=w;let n,B;if(r)z(r)||(r=[r]);else if(z(g)){var u=g;r=[];h=[];for(var q=0;q<g.length;q++)d=g[q],e=d.bool||w,r[q]=d.field,h[q]=e,"not"===e?n=!0:"and"===e&&(B=!0)}else r=this.a.keys;w=r.length;for(q=0;q<w;q++)u&&(g=u[q]),m&&!E(g)&&(g.page=null,g.limit=0),f[q]=k[r[q]].search(g,0);if(c)return c(G.call(this,b,h,f,l,a,p,!1,m,B,n));if(this.async){const c=this;return new Promise(function(d){Promise.all(f).then(function(e){d(G.call(c,
|
||||
b,h,e,l,a,p,!1,m,B,n))})})}return G.call(this,b,h,f,l,a,p,!1,m,B,n)}k||(k=this.threshold||0);H(a)?(c=a,a=1E3):a||0===a||(a=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let b=this;k=new Promise(function(c){setTimeout(function(){c(b.search(g,a,null,!0));b=null})});if(c)k.then(c);else return k;return this}if(c)return c(this.search(g,a,null,!0)),this}if(!b||!E(b))return f;g=b;g=this.encode(g);if(!g.length)return f;c=this.c;c=H(c)?c(g):g.split(W);this.filter&&(c=F(c,this.filter));u=c.length;
|
||||
d=!0;e=[];const A=x();1<u&&(this.depth?(r=!0,q=c[0],A[q]=1):c.sort(ca));if(!r||(w=this.h)[q]){const a=this.b;for(let b=r?1:0;b<u;b++){const f=c[b];if(f){if(!A[f]){const b=[];let c=!1,g=0;if(q=r?w[q]:this.l){let d;for(let e=0;e<a-k;e++)if(d=q[e][f])b[g++]=d,c=!0}if(c)e[e.length]=1<g?b.concat.apply([],b):b[0];else{d=!1;break}A[f]=1}q=f}}}else d=!1;d&&(f=R(e,a,m,!1));return f};l.prototype.clear=function(){return this.destroy().init()};l.prototype.destroy=function(){this.l=this.h=this.f=null;if(this.a){const b=
|
||||
this.a.keys;for(let a=0;a<b.length;a++)this.a.index[b[a]].destroy();this.a=this.g=null}return this};const L={icase:function(b){return b.toLowerCase()},simple:function(){const b=[f("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",f("[\u00e8\u00e9\u00ea\u00eb]"),"e",f("[\u00ec\u00ed\u00ee\u00ef]"),"i",f("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",f("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",f("[\u00fd\u0177\u00ff]"),"y",f("\u00f1"),"n",f("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]")," ",f("[^a-z0-9 ]"),
|
||||
|
12
dist/flexsearch.es5.js
vendored
12
dist/flexsearch.es5.js
vendored
@@ -35,12 +35,12 @@ f._ctx[v]||(f._ctx[v]=G()),v=this.s[v]||(this.s[v]=ea(q-(B||0))),w=C-l,r=C+l+1,0
|
||||
b)[A[q]];p="@"+p}A=this.B[l];A=A[p]||(A[p]=[])}if("remove"===a)for(delete this.m[h],f=0,e=d.length;f<e;f++){if(f===e-1)return g[d[f]].remove(h,c);g[d[f]].remove(h)}f=this.a.field;A&&(A[A.length]=b);e=0;for(l=f.length;e<l;e++){A=f[e];p=void 0;for(q=0;q<A.length;q++)p=(p||b)[A[q]];this.m[h]=b;A=g[d[e]];q="add"===a?A.add:A.update;if(e===l-1)return q.call(A,h,p,c);q.call(A,h,p)}}};f.prototype.update=function(a,b,c){if(this.a&&J(a))return this.l("update",a,b);this.f["@"+a]&&N(b)&&(this.remove(a),this.add(a,
|
||||
b,c,!0));return this};f.prototype.remove=function(a,b,c){if(this.a&&J(a))return this.l("remove",a,b);var g="@"+a;if(this.f[g]){if(this.i)return this.b[this.f[g]].postMessage({remove:!0,id:a}),delete this.f[g],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){var d=this;g=new Promise(function(b){setTimeout(function(){d.remove(a,null,!0);d=null;b()})});if(b)g.then(b);else return g;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.c-(this.threshold||0);b++)S(this.u[b],
|
||||
a);this.depth&&S(this.s,a);delete this.f[g];this.o=!1}return this};var F;f.prototype.search=function(a,b,c,d){if(J(b)){if(E(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}var g=[],f=a;if(J(a)&&!E(a)){(c=a.callback||R(b)&&b)&&(f.callback=null);var h=a.sort;var l=a.page;b=a.limit;var B=a.threshold;var x=a.suggest;a=a.query}if(this.a){B=this.a.index;var q=f.where,t=f.bool||"or",n=f.field,C=t,v,y;if(n)E(n)||(n=[n]);else if(E(f)){var w=f;n=[];C=[];for(var r=0;r<f.length;r++)d=f[r],e=
|
||||
d.bool||t,n[r]=d.field,C[r]=e,"not"===e?v=!0:"and"===e&&(y=!0)}else n=this.a.keys;t=n.length;for(r=0;r<t;r++)w&&(f=w[r]),N(f)||(f.page=null,f.limit=0),g[r]=B[n[r]].search(f,0);if(c)return c(Q.call(this,a,C,g,h,b,x,q,l,y,v));if(this.async){var z=this;return new Promise(function(c){Promise.all(g).then(function(d){c(Q.call(z,a,C,d,h,b,x,q,l,y,v))})})}return Q.call(this,a,C,g,h,b,x,q,l,y,v)}B||(B=this.threshold||0);R(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.i)for(this.H=c,this.D=0,this.A=[],n=0;n<this.i;n++)this.b[n].postMessage({search:!0,
|
||||
limit:b,cursor:l,threshold:B,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){var D=this;B=new Promise(function(a){setTimeout(function(){a(D.search(f,b,null,!0));D=null})});if(c)B.then(c);else return B;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!N(a))return g;f=a;if(this.cache)if(this.o){if(c=this.v.get(a))return c}else this.v.clear(),this.o=!0;f=this.encode(f);if(!f.length)return g;c=this.h;c=R(c)?c(f):f.split(ha);this.filter&&(c=p(c,this.filter));w=
|
||||
c.length;d=!0;e=[];var F=G();1<w&&(this.depth?(n=!0,r=c[0],F[r]=1):c.sort(na));if(!n||(t=this.s)[r])for(var I=this.c,H=n?1:0;H<w;H++){var K=c[H];if(K){if(!F[K]){var L=[],M=!1,O=0;if(r=n?t[r]:this.u)for(var T=void 0,S=0;S<I-B;S++)if(T=r[S][K])L[O++]=T,M=!0;if(M)e[e.length]=1<O?L.concat.apply([],L):L[0];else if(!x){d=!1;break}F[K]=1}r=K}}else d=!1;d&&(g=da(e,b,l,x));this.cache&&this.v.set(a,g);return g}};f.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};f.prototype.where=function(a,
|
||||
b,c,d){var e=this.m,g=[],f=0,h;if(J(a)){c||(c=b);var l=Object.keys(a);var p=l.length;var x=!1;if(1===p&&"id"===l[0])return[e[a.id]];if((h=this.I)&&!d)for(var q=0;q<h.length;q++){var t=h[q],n=a[t];if(!H(n)){d=this.B[t]["@"+n];if(0===--p)return d;l.splice(l.indexOf(t),1);delete a[t];break}}h=Array(p);for(q=0;q<p;q++)h[q]=l[q].split(":")}else{if(R(a)){b=d||Object.keys(e);c=b.length;for(l=0;l<c;l++)p=e[b[l]],a(p)&&(g[f++]=p);return g}if(H(b))return[e[a]];if("id"===a)return[e[b]];l=[a];p=1;h=[a.split(":")];
|
||||
x=!0}d=d||Object.keys(e);q=d.length;for(t=0;t<q;t++){n=e[d[t]];for(var C=!0,v=0;v<p;v++){x||(b=a[l[v]]);var y=h[v],w=y.length,r=n;if(1<w)for(var z=0;z<w;z++)r=r[y[z]];else r=r[y[0]];if(r!==b){C=!1;break}}if(C&&(g[f++]=n,c&&f===c))break}return g};f.prototype.info=function(){if(this.i)for(var a=0;a<this.i;a++)this.b[a].postMessage({info:!0,id:this.id});else return{id:this.id,items:this.length,cache:this.cache&&this.cache.C?this.cache.C.length:!1,matcher:T.length+(this.g?this.g.length:0),worker:this.i,
|
||||
threshold:this.threshold,depth:this.depth,resolution:this.c,contextual:this.depth&&"strict"===this.h}};f.prototype.clear=function(){return this.destroy().init()};f.prototype.destroy=function(){this.cache&&(this.v.clear(),this.v=null);this.u=this.s=this.f=null;if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.m=null}return this};f.prototype.export=function(){if(this.a){for(var a=this.a.keys,b=Array(a.length+1),c=0;c<a.length;c++){var d=this.a.index[a[c]];
|
||||
d.bool||t,n[r]=d.field,C[r]=e,"not"===e?v=!0:"and"===e&&(y=!0)}else n=this.a.keys;t=n.length;for(r=0;r<t;r++)w&&(f=w[r]),l&&!N(f)&&(f.page=null,f.limit=0),g[r]=B[n[r]].search(f,0);if(c)return c(Q.call(this,a,C,g,h,b,x,q,l,y,v));if(this.async){var z=this;return new Promise(function(c){Promise.all(g).then(function(d){c(Q.call(z,a,C,d,h,b,x,q,l,y,v))})})}return Q.call(this,a,C,g,h,b,x,q,l,y,v)}B||(B=this.threshold||0);R(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.i)for(this.H=c,this.D=0,this.A=[],n=0;n<
|
||||
this.i;n++)this.b[n].postMessage({search:!0,limit:b,cursor:l,threshold:B,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){var D=this;B=new Promise(function(a){setTimeout(function(){a(D.search(f,b,null,!0));D=null})});if(c)B.then(c);else return B;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!N(a))return g;f=a;if(this.cache)if(this.o){if(c=this.v.get(a))return c}else this.v.clear(),this.o=!0;f=this.encode(f);if(!f.length)return g;c=this.h;c=R(c)?c(f):f.split(ha);
|
||||
this.filter&&(c=p(c,this.filter));w=c.length;d=!0;e=[];var F=G();1<w&&(this.depth?(n=!0,r=c[0],F[r]=1):c.sort(na));if(!n||(t=this.s)[r])for(var I=this.c,H=n?1:0;H<w;H++){var K=c[H];if(K){if(!F[K]){var L=[],M=!1,O=0;if(r=n?t[r]:this.u)for(var T=void 0,S=0;S<I-B;S++)if(T=r[S][K])L[O++]=T,M=!0;if(M)e[e.length]=1<O?L.concat.apply([],L):L[0];else if(!x){d=!1;break}F[K]=1}r=K}}else d=!1;d&&(g=da(e,b,l,x));this.cache&&this.v.set(a,g);return g}};f.prototype.find=function(a,b){return this.where(a,b,1)[0]||
|
||||
null};f.prototype.where=function(a,b,c,d){var e=this.m,g=[],f=0,h;if(J(a)){c||(c=b);var l=Object.keys(a);var p=l.length;var x=!1;if(1===p&&"id"===l[0])return[e[a.id]];if((h=this.I)&&!d)for(var q=0;q<h.length;q++){var t=h[q],n=a[t];if(!H(n)){d=this.B[t]["@"+n];if(0===--p)return d;l.splice(l.indexOf(t),1);delete a[t];break}}h=Array(p);for(q=0;q<p;q++)h[q]=l[q].split(":")}else{if(R(a)){b=d||Object.keys(e);c=b.length;for(l=0;l<c;l++)p=e[b[l]],a(p)&&(g[f++]=p);return g}if(H(b))return[e[a]];if("id"===a)return[e[b]];
|
||||
l=[a];p=1;h=[a.split(":")];x=!0}d=d||Object.keys(e);q=d.length;for(t=0;t<q;t++){n=e[d[t]];for(var C=!0,v=0;v<p;v++){x||(b=a[l[v]]);var y=h[v],w=y.length,r=n;if(1<w)for(var z=0;z<w;z++)r=r[y[z]];else r=r[y[0]];if(r!==b){C=!1;break}}if(C&&(g[f++]=n,c&&f===c))break}return g};f.prototype.info=function(){if(this.i)for(var a=0;a<this.i;a++)this.b[a].postMessage({info:!0,id:this.id});else return{id:this.id,items:this.length,cache:this.cache&&this.cache.C?this.cache.C.length:!1,matcher:T.length+(this.g?this.g.length:
|
||||
0),worker:this.i,threshold:this.threshold,depth:this.depth,resolution:this.c,contextual:this.depth&&"strict"===this.h}};f.prototype.clear=function(){return this.destroy().init()};f.prototype.destroy=function(){this.cache&&(this.v.clear(),this.v=null);this.u=this.s=this.f=null;if(this.a){for(var a=this.a.keys,b=0;b<a.length;b++)this.a.index[a[b]].destroy();this.a=this.m=null}return this};f.prototype.export=function(){if(this.a){for(var a=this.a.keys,b=Array(a.length+1),c=0;c<a.length;c++){var d=this.a.index[a[c]];
|
||||
b[c]=[d.u,d.s,Object.keys(d.f)]}b[c]=this.m;return JSON.stringify(b)}return JSON.stringify([this.u,this.s,Object.keys(this.f)])};f.prototype.import=function(a){a=JSON.parse(a);var b=G();if(this.a){for(var c=this.a.keys,d=c.length,e=a[0][2],f=0;f<e.length;f++)b[e[f]]=1;for(e=0;e<d;e++)f=this.a.index[c[e]],f.u=a[e][0],f.s=a[e][1],f.f=b,f.m=a[d];this.m=a[d]}else{c=a[2];for(d=0;d<c.length;d++)b[c[d]]=1;this.u=a[0];this.s=a[1];this.f=b}};var O={icase:function(a){return a.toLowerCase()},simple:function(){var a=
|
||||
[e("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",e("[\u00e8\u00e9\u00ea\u00eb]"),"e",e("[\u00ec\u00ed\u00ee\u00ef]"),"i",e("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",e("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",e("[\u00fd\u0177\u00ff]"),"y",e("\u00f1"),"n",e("\u00e7"),"c",e("\u00df"),"s",e(" & ")," and ",e("[-/]")," ",e("[^a-z0-9 ]"),"",e("\\s+")," "];return function(b){b=x(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){var a=[e("ae"),"a",e("ai"),"ei",e("ay"),"ei",e("ey"),"ei",e("oe"),
|
||||
"o",e("ue"),"u",e("ie"),"i",e("sz"),"s",e("zs"),"s",e("sh"),"s",e("ck"),"k",e("cc"),"k",e("dt"),"t",e("ph"),"f",e("pf"),"f",e("ou"),"o",e("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=x(b,a));c||1<b.length&&(b=X(b));return b}}(),extra:function(){var a=[e("p"),"b",e("z"),"s",e("[cgq]"),"k",e("n"),"m",e("d"),"t",e("[vw]"),"f",e("[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];
|
||||
|
2
dist/flexsearch.light.js
vendored
2
dist/flexsearch.light.js
vendored
@@ -13,7 +13,7 @@ v.threshold:b;this.a=D(b=a.resolution)?b=c.a||this.a||v.a:b;b<=this.threshold&&(
|
||||
for(d in a)a.hasOwnProperty(d)&&(f=b?b(d):d,c.push(new RegExp(f+"($|\\W)","g"),b?b(a[d]):a[d]));this.stemmer=d=c}this.h=H(this.a-(this.threshold||0));this.f=y();this.b=y();return this};e.prototype.encode=function(a){a&&G.length&&(a=k(a,G));a&&this.j.length&&(a=k(a,this.j));a&&this.g&&(a=this.g(a));a&&this.stemmer&&(a=k(a,this.stemmer));return a};e.prototype.addMatcher=function(a){const c=this.j;for(const b in a)a.hasOwnProperty(b)&&c.push(new RegExp(b,"g"),a[b]);return this};e.prototype.add=function(a,
|
||||
c,b,f,d){if(c&&C(c)&&(a||0===a)){const e="@"+a;if(this.b[e]&&!f)return this.update(a,c);if(!d&&b)return this.add(a,c,null,f,!0),b(),this;c=this.encode(c);if(!c.length)return this;b=this.c;c=A(b)?b(c):c.split(I);this.filter&&(c=z(c,this.filter));f=y();f._ctx=y();d=c.length;const q=this.threshold,k=this.depth,p=this.a,r=this.h,u=this.i;for(let e=0;e<d;e++){var l=c[e];if(l){var g=l.length,h=(u?e+1:d-e)/d,n="";switch(b){case "reverse":case "both":for(var m=g;--m;)n=l[m]+n,B(r,f,n,a,u?1:(g-m)/g,h,q,p-
|
||||
1);n="";case "forward":for(m=0;m<g;m++)n+=l[m],B(r,f,n,a,u?(m+1)/g:1,h,q,p-1);break;case "full":for(m=0;m<g;m++){const b=(u?m+1:g-m)/g;for(let c=g;c>m;c--)n=l.substring(m,c),B(r,f,n,a,b,h,q,p-1)}break;default:if(g=B(r,f,l,a,1,h,q,p-1),k&&1<d&&g>=q)for(g=f._ctx[l]||(f._ctx[l]=y()),l=this.f[l]||(this.f[l]=H(p-(q||0))),h=e-k,n=e+k+1,0>h&&(h=0),n>d&&(n=d);h<n;h++)h!==e&&B(l,g,c[h],a,0,p-(h<e?e-h:h-e),q,p-1)}}}this.b[e]=1}return this};e.prototype.update=function(a,c,b){this.b["@"+a]&&C(c)&&(this.remove(a),
|
||||
this.add(a,c,b,!0));return this};e.prototype.remove=function(a,c,b){const f="@"+a;if(this.b[f]){if(!b&&c)return this.remove(a,null,!0),c(),this;for(c=0;c<this.a-(this.threshold||0);c++)E(this.h[c],a);this.depth&&E(this.f,a);delete this.b[f]}return this};e.prototype.search=function(a,c,b,f){var d=[],e=a;if("object"===typeof a){var g=a.page;c=a.limit;var h=a.threshold;a=a.query}h||(h=this.threshold||0);A(c)?(b=c,c=1E3):c||0===c||(c=1E3);if(!f&&b)return b(this.search(e,c,null,!0)),this;if(!a||!C(a))return d;
|
||||
this.add(a,c,b,!0));return this};e.prototype.remove=function(a,c,b){const f="@"+a;if(this.b[f]){if(!b&&c)return this.remove(a,null,!0),c(),this;for(c=0;c<this.a-(this.threshold||0);c++)E(this.h[c],a);this.depth&&E(this.f,a);delete this.b[f]}return this};e.prototype.search=function(a,c,b,f){var d=[],e=a;if("object"===typeof a){var g=!1;c=a.limit;var h=a.threshold;a=a.query}h||(h=this.threshold||0);A(c)?(b=c,c=1E3):c||0===c||(c=1E3);if(!f&&b)return b(this.search(e,c,null,!0)),this;if(!a||!C(a))return d;
|
||||
e=this.encode(a);if(!e.length)return d;a=this.c;a=A(a)?a(e):e.split(I);this.filter&&(a=z(a,this.filter));b=a.length;f=!0;e=[];var n=y();if(1<b)if(this.depth){var m=!0;var k=a[0];n[k]=1}else a.sort(M);var q;if(!m||(q=this.f)[k]){var v=this.a;for(var p=m?1:0;p<b;p++){var r=a[p];if(r){if(!n[r]){var u=[],t=!1,w=0;if(k=m?q[k]:this.h){let a;for(let b=0;b<v-h;b++)if(a=k[b][r])u[w++]=a,t=!0}if(t)e[e.length]=1<w?u.concat.apply([],u):u[0];else{f=!1;break}n[r]=1}k=r}}}else f=!1;if(f)a:{let l;d=[];m=e.length;
|
||||
!0===g?(g="0",h=""):h=g&&g.split(":");if(1<m){q=y();a=-1;r=!0;n=0;for(h&&(2===h.length?h=!1:h=parseInt(h[0],10));++a<m;){v=a===m-1;k=e[a];f=k.length;if(!f){d=F(g,l,k);break a}if(r)if(x){p=x.length;for(b=0;b<p;)q["@"+x[b++]]=1;var x=null;r=!1}else{x=k;continue}u=!1;for(b=0;b<f;)if(p=k[b++],t="@"+p,(w=q[t])&&w===a){if(v){if(!h||--h<n)if(d[n++]=p,c&&n===c){d=F(g,n,d);break a}}else q[t]=a+1;u=!0}if(!u)break}x&&(d=x)}else m&&(d=e[0]);c&&(x=g?parseInt(g,10):0,l=x+c,l<d.length?d=d.slice(x,l):x&&(d=d.slice(x)));
|
||||
d=F(g,l,d)}return d};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.h=this.f=this.b=null;return this};const w={icase:function(a){return a.toLowerCase()}};return e}(!1),this);
|
||||
|
4
dist/flexsearch.min.js
vendored
4
dist/flexsearch.min.js
vendored
@@ -26,8 +26,8 @@ q();const p=e.length,r=this.threshold,u=this.depth,y=this.b,z=this.j,v=this.D;fo
|
||||
(m||b)[h[f]];m="@"+m}h=this.G[g];h=h[m]||(h[m]=[])}if("remove"===a){delete this.h[k];for(let a=0,b=l.length;a<b;a++){if(a===b-1)return n[l[a]].remove(k,c);n[l[a]].remove(k)}}e=this.a.field;h&&(h[h.length]=b);for(let f=0,h=e.length;f<h;f++){d=e[f];let m;for(g=0;g<d.length;g++)m=(m||b)[d[g]];this.h[k]=b;d=n[l[f]];g="add"===a?d.add:d.update;if(f===h-1)return g.call(d,k,m,c);g.call(d,k,m)}}};l.prototype.update=function(a,b,c){if(this.a&&G(a))return this.A("update",a,b);this.c["@"+a]&&I(b)&&(this.remove(a),
|
||||
this.add(a,b,c,!0));return this};l.prototype.remove=function(a,b,c){if(this.a&&G(a))return this.A("remove",a,b);var d="@"+a;if(this.c[d]){if(this.g)return this.m[this.c[d]].postMessage({remove:!0,id:a}),delete this.c[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<this.b-(this.threshold||
|
||||
0);b++)T(this.j[b],a);this.depth&&T(this.i,a);delete this.c[d];this.B=!1}return this};let F;l.prototype.search=function(a,b,c,d){if(G(b)){if(w(b))for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let f=[],g=a;let h,l,r;if(G(a)&&!w(a)){(c=a.callback||J(b)&&b)&&(g.callback=null);l=a.sort;h=a.page;b=a.limit;var k=a.threshold;r=a.suggest;a=a.query}if(this.a){k=this.a.index;const m=g.where;var B=g.bool||"or",p=g.field;let n=B;let A,q;if(p)w(p)||(p=[p]);else if(w(g)){var t=g;p=[];n=[];for(var u=
|
||||
0;u<g.length;u++)d=g[u],e=d.bool||B,p[u]=d.field,n[u]=e,"not"===e?A=!0:"and"===e&&(q=!0)}else p=this.a.keys;B=p.length;for(u=0;u<B;u++)t&&(g=t[u]),I(g)||(g.page=null,g.limit=0),f[u]=k[p[u]].search(g,0);if(c)return c(Q.call(this,a,n,f,l,b,r,m,h,q,A));if(this.async){const c=this;return new Promise(function(d){Promise.all(f).then(function(e){d(Q.call(c,a,n,e,l,b,r,m,h,q,A))})})}return Q.call(this,a,n,f,l,b,r,m,h,q,A)}k||(k=this.threshold||0);J(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.g)for(this.F=c,
|
||||
this.u=0,this.o=[],p=0;p<this.g;p++)this.m[p].postMessage({search:!0,limit:b,cursor:h,threshold:k,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;k=new Promise(function(c){setTimeout(function(){c(a.search(g,b,null,!0));a=null})});if(c)k.then(c);else return k;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!I(a))return f;g=a;if(this.cache)if(this.B){if(c=this.l.get(a))return c}else this.l.clear(),this.B=!0;g=this.encode(g);if(!g.length)return f;
|
||||
0;u<g.length;u++)d=g[u],e=d.bool||B,p[u]=d.field,n[u]=e,"not"===e?A=!0:"and"===e&&(q=!0)}else p=this.a.keys;B=p.length;for(u=0;u<B;u++)t&&(g=t[u]),h&&!I(g)&&(g.page=null,g.limit=0),f[u]=k[p[u]].search(g,0);if(c)return c(Q.call(this,a,n,f,l,b,r,m,h,q,A));if(this.async){const c=this;return new Promise(function(d){Promise.all(f).then(function(e){d(Q.call(c,a,n,e,l,b,r,m,h,q,A))})})}return Q.call(this,a,n,f,l,b,r,m,h,q,A)}k||(k=this.threshold||0);J(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.g)for(this.F=
|
||||
c,this.u=0,this.o=[],p=0;p<this.g;p++)this.m[p].postMessage({search:!0,limit:b,cursor:h,threshold:k,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;k=new Promise(function(c){setTimeout(function(){c(a.search(g,b,null,!0));a=null})});if(c)k.then(c);else return k;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!I(a))return f;g=a;if(this.cache)if(this.B){if(c=this.l.get(a))return c}else this.l.clear(),this.B=!0;g=this.encode(g);if(!g.length)return f;
|
||||
c=this.f;c=J(c)?c(g):g.split(Z);this.filter&&(c=O(c,this.filter));t=c.length;d=!0;e=[];var y=q();1<t&&(this.depth?(p=!0,u=c[0],y[u]=1):c.sort(ha));if(!p||(B=this.i)[u]){const a=this.b;for(let b=p?1:0;b<t;b++){const f=c[b];if(f){if(!y[f]){const b=[];let c=!1,g=0;if(u=p?B[u]:this.j){let d;for(let e=0;e<a-k;e++)if(d=u[e][f])b[g++]=d,c=!0}if(c)e[e.length]=1<g?b.concat.apply([],b):b[0];else if(!r){d=!1;break}y[f]=1}u=f}}}else d=!1;d&&(f=V(e,b,h,r));this.cache&&this.l.set(a,f);return f}};l.prototype.find=
|
||||
function(a,b){return this.where(a,b,1)[0]||null};l.prototype.where=function(a,b,c,d){const e=this.h,f=[];let g=0;let h;var l;if(G(a)){c||(c=b);var r=Object.keys(a);var k=r.length;h=!1;if(1===k&&"id"===r[0])return[e[a.id]];if((l=this.I)&&!d)for(var q=0;q<l.length;q++){var p=l[q],t=a[p];if(!D(t)){d=this.G[p]["@"+t];if(0===--k)return d;r.splice(r.indexOf(p),1);delete a[p];break}}l=Array(k);for(q=0;q<k;q++)l[q]=r[q].split(":")}else{if(J(a)){b=d||Object.keys(e);c=b.length;for(r=0;r<c;r++)k=e[b[r]],a(k)&&
|
||||
(f[g++]=k);return f}if(D(b))return[e[a]];if("id"===a)return[e[b]];r=[a];k=1;l=[a.split(":")];h=!0}d=d||Object.keys(e);q=d.length;for(p=0;p<q;p++){t=e[d[p]];let m=!0;for(let c=0;c<k;c++){h||(b=a[r[c]]);const d=l[c],e=d.length;let f=t;if(1<e)for(let b=0;b<e;b++)f=f[d[b]];else f=f[d[0]];if(f!==b){m=!1;break}}if(m&&(f[g++]=t,c&&g===c))break}return f};l.prototype.info=function(){if(this.g)for(let a=0;a<this.g;a++)this.m[a].postMessage({info:!0,id:this.id});else return{id:this.id,items:this.length,cache:this.cache&&
|
||||
|
22
dist/flexsearch.node.js
vendored
22
dist/flexsearch.node.js
vendored
@@ -23,14 +23,14 @@ k;c--)h=g.substring(k,c),N(z,t,h,b,a,n,q,l-1)}break;default:if(m=N(z,t,g,b,1,n,q
|
||||
0;f<e.length;f++)k=(k||a)[e[f]];if(d){for(e=0;e<d.length;e++){var g=d[e];var h=g.split(":");for(f=0;f<h.length;f++)l=(l||a)[h[f]];l="@"+l}h=this.w[g];h=h[l]||(h[l]=[])}if("remove"===b){delete this.g[k];for(let a=0,b=m.length;a<b;a++){if(a===b-1)return n[m[a]].remove(k,c);n[m[a]].remove(k)}}e=this.a.field;h&&(h[h.length]=a);for(let f=0,h=e.length;f<h;f++){d=e[f];let l;for(g=0;g<d.length;g++)l=(l||a)[d[g]];this.g[k]=a;d=n[m[f]];g="add"===b?d.add:d.update;if(f===h-1)return g.call(d,k,l,c);g.call(d,k,
|
||||
l)}}};l.prototype.update=function(b,a,c){if(this.a&&C(b))return this.s("update",b,a);this.f["@"+b]&&E(a)&&(this.remove(b),this.add(b,a,c,!0));return this};l.prototype.remove=function(b,a,c){if(this.a&&C(b))return this.s("remove",b,a);var d="@"+b;if(this.f[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(a){setTimeout(function(){c.remove(b,null,!0);c=null;a()})});if(a)d.then(a);else return d;return this}if(a)return this.remove(b,null,!0),a(),this}for(a=
|
||||
0;a<this.b-(this.threshold||0);a++)P(this.i[a],b);this.depth&&P(this.h,b);delete this.f[d];this.u=!1}return this};let v;l.prototype.search=function(b,a,c,d){if(C(a)){if(y(a))for(var e=0;e<a.length;e++)a[e].query=b;else a.query=b;b=a;a=0}let f=[],g=b;let h,l,q;if(C(b)&&!y(b)){(c=b.callback||H(a)&&a)&&(g.callback=null);l=b.sort;h=b.page;a=b.limit;var k=b.threshold;q=b.suggest;b=b.query}if(this.a){k=this.a.index;const m=g.where;var t=g.bool||"or",p=g.field;let n=t;let A,r;if(p)y(p)||(p=[p]);else if(y(g)){var v=
|
||||
g;p=[];n=[];for(var u=0;u<g.length;u++)d=g[u],e=d.bool||t,p[u]=d.field,n[u]=e,"not"===e?A=!0:"and"===e&&(r=!0)}else p=this.a.keys;t=p.length;for(u=0;u<t;u++)v&&(g=v[u]),E(g)||(g.page=null,g.limit=0),f[u]=k[p[u]].search(g,0);if(c)return c(J.call(this,b,n,f,l,a,q,m,h,r,A));if(this.async){const c=this;return new Promise(function(d){Promise.all(f).then(function(e){d(J.call(c,b,n,e,l,a,q,m,h,r,A))})})}return J.call(this,b,n,f,l,a,q,m,h,r,A)}k||(k=this.threshold||0);H(a)?(c=a,a=1E3):a||0===a||(a=1E3);if(!d){if(this.async&&
|
||||
"function"!==typeof importScripts){let b=this;k=new Promise(function(c){setTimeout(function(){c(b.search(g,a,null,!0));b=null})});if(c)k.then(c);else return k;return this}if(c)return c(this.search(g,a,null,!0)),this}if(!b||!E(b))return f;g=b;if(this.cache)if(this.u){if(c=this.j.get(b))return c}else this.j.clear(),this.u=!0;g=this.encode(g);if(!g.length)return f;c=this.c;c=H(c)?c(g):g.split(W);this.filter&&(c=I(c,this.filter));v=c.length;d=!0;e=[];const x=r();1<v&&(this.depth?(p=!0,u=c[0],x[u]=1):
|
||||
c.sort(ca));if(!p||(t=this.h)[u]){const a=this.b;for(let b=p?1:0;b<v;b++){const f=c[b];if(f){if(!x[f]){const b=[];let c=!1,g=0;if(u=p?t[u]:this.i){let d;for(let e=0;e<a-k;e++)if(d=u[e][f])b[g++]=d,c=!0}if(c)e[e.length]=1<g?b.concat.apply([],b):b[0];else if(!q){d=!1;break}x[f]=1}u=f}}}else d=!1;d&&(f=R(e,a,h,q));this.cache&&this.j.set(b,f);return f};l.prototype.find=function(b,a){return this.where(b,a,1)[0]||null};l.prototype.where=function(b,a,c,d){const e=this.g,f=[];let g=0;let h;var l;if(C(b)){c||
|
||||
(c=a);var q=Object.keys(b);var k=q.length;h=!1;if(1===k&&"id"===q[0])return[e[b.id]];if((l=this.B)&&!d)for(var t=0;t<l.length;t++){var p=l[t],r=b[p];if(!F(r)){d=this.w[p]["@"+r];if(0===--k)return d;q.splice(q.indexOf(p),1);delete b[p];break}}l=Array(k);for(t=0;t<k;t++)l[t]=q[t].split(":")}else{if(H(b)){a=d||Object.keys(e);c=a.length;for(q=0;q<c;q++)k=e[a[q]],b(k)&&(f[g++]=k);return f}if(F(a))return[e[b]];if("id"===b)return[e[a]];q=[b];k=1;l=[b.split(":")];h=!0}d=d||Object.keys(e);t=d.length;for(p=
|
||||
0;p<t;p++){r=e[d[p]];let m=!0;for(let c=0;c<k;c++){h||(a=b[q[c]]);const d=l[c],e=d.length;let f=r;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==a){m=!1;break}}if(m&&(f[g++]=r,c&&g===c))break}return f};l.prototype.info=function(){return{id:this.id,items:this.length,cache:this.cache&&this.cache.l?this.cache.l.length:!1,matcher:O.length+(this.m?this.m.length:0),worker:this.C,threshold:this.threshold,depth:this.depth,resolution:this.b,contextual:this.depth&&"strict"===this.c}};l.prototype.clear=
|
||||
function(){return this.destroy().init()};l.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.i=this.h=this.f=null;if(this.a){const b=this.a.keys;for(let a=0;a<b.length;a++)this.a.index[b[a]].destroy();this.a=this.g=null}return this};l.prototype.export=function(){if(this.a){const b=this.a.keys,a=Array(b.length+1);let c=0;for(;c<b.length;c++){const d=this.a.index[b[c]];a[c]=[d.i,d.h,Object.keys(d.f)]}a[c]=this.g;return JSON.stringify(a)}return JSON.stringify([this.i,this.h,
|
||||
Object.keys(this.f)])};l.prototype.import=function(b){b=JSON.parse(b);const a=r();if(this.a){var c=this.a.keys,d=c.length,e=b[0][2];for(var f=0;f<e.length;f++)a[e[f]]=1;for(e=0;e<d;e++)f=this.a.index[c[e]],f.i=b[e][0],f.h=b[e][1],f.f=a,f.g=b[d];this.g=b[d]}else{c=b[2];for(d=0;d<c.length;d++)a[c[d]]=1;this.i=b[0];this.h=b[1];this.f=a}};const M={icase:function(b){return b.toLowerCase()},simple:function(){const b=[h("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",h("[\u00e8\u00e9\u00ea\u00eb]"),"e",h("[\u00ec\u00ed\u00ee\u00ef]"),
|
||||
"i",h("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",h("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",h("[\u00fd\u0177\u00ff]"),"y",h("\u00f1"),"n",h("\u00e7"),"c",h("\u00df"),"s",h(" & ")," and ",h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(a){a=L(a.toLowerCase(),b);return" "===a?"":a}}(),advanced:function(){const b=[h("ae"),"a",h("ai"),"ei",h("ay"),"ei",h("ey"),"ei",h("oe"),"o",h("ue"),"u",h("ie"),"i",h("sz"),"s",h("zs"),"s",h("sh"),"s",h("ck"),"k",h("cc"),"k",h("dt"),"t",h("ph"),"f",
|
||||
h("pf"),"f",h("ou"),"o",h("uo"),"u"];return function(a,c){if(!a)return a;a=this.simple(a);2<a.length&&(a=L(a,b));c||1<a.length&&(a=Q(a));return a}}(),extra:function(){const b=[h("p"),"b",h("z"),"s",h("[cgq]"),"k",h("n"),"m",h("d"),"t",h("[vw]"),"f",h("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(let c=0;c<a.length;c++){const d=a[c];1<d.length&&(a[c]=d[0]+L(d.substring(1),b))}a=a.join(" ");a=Q(a)}return a}}(),balance:function(){const b=[h("[-/]"),
|
||||
" ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(a){return Q(L(a.toLowerCase(),b))}}()},ea=function(){function b(a){this.clear();this.A=!0!==a&&a}b.prototype.clear=function(){this.cache=r();this.count=r();this.index=r();this.l=[]};b.prototype.set=function(a,b){if(this.A&&F(this.cache[a])){let c=this.l.length;if(c===this.A){c--;const a=this.l[c];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=c;this.l[c]=a;this.count[a]=-1;this.cache[a]=b;this.get(a)}else this.cache[a]=
|
||||
b};b.prototype.get=function(a){const b=this.cache[a];if(this.A&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.l;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return b}();return l}(!1),this);
|
||||
g;p=[];n=[];for(var u=0;u<g.length;u++)d=g[u],e=d.bool||t,p[u]=d.field,n[u]=e,"not"===e?A=!0:"and"===e&&(r=!0)}else p=this.a.keys;t=p.length;for(u=0;u<t;u++)v&&(g=v[u]),h&&!E(g)&&(g.page=null,g.limit=0),f[u]=k[p[u]].search(g,0);if(c)return c(J.call(this,b,n,f,l,a,q,m,h,r,A));if(this.async){const c=this;return new Promise(function(d){Promise.all(f).then(function(e){d(J.call(c,b,n,e,l,a,q,m,h,r,A))})})}return J.call(this,b,n,f,l,a,q,m,h,r,A)}k||(k=this.threshold||0);H(a)?(c=a,a=1E3):a||0===a||(a=1E3);
|
||||
if(!d){if(this.async&&"function"!==typeof importScripts){let b=this;k=new Promise(function(c){setTimeout(function(){c(b.search(g,a,null,!0));b=null})});if(c)k.then(c);else return k;return this}if(c)return c(this.search(g,a,null,!0)),this}if(!b||!E(b))return f;g=b;if(this.cache)if(this.u){if(c=this.j.get(b))return c}else this.j.clear(),this.u=!0;g=this.encode(g);if(!g.length)return f;c=this.c;c=H(c)?c(g):g.split(W);this.filter&&(c=I(c,this.filter));v=c.length;d=!0;e=[];const x=r();1<v&&(this.depth?
|
||||
(p=!0,u=c[0],x[u]=1):c.sort(ca));if(!p||(t=this.h)[u]){const a=this.b;for(let b=p?1:0;b<v;b++){const f=c[b];if(f){if(!x[f]){const b=[];let c=!1,g=0;if(u=p?t[u]:this.i){let d;for(let e=0;e<a-k;e++)if(d=u[e][f])b[g++]=d,c=!0}if(c)e[e.length]=1<g?b.concat.apply([],b):b[0];else if(!q){d=!1;break}x[f]=1}u=f}}}else d=!1;d&&(f=R(e,a,h,q));this.cache&&this.j.set(b,f);return f};l.prototype.find=function(b,a){return this.where(b,a,1)[0]||null};l.prototype.where=function(b,a,c,d){const e=this.g,f=[];let g=0;
|
||||
let h;var l;if(C(b)){c||(c=a);var q=Object.keys(b);var k=q.length;h=!1;if(1===k&&"id"===q[0])return[e[b.id]];if((l=this.B)&&!d)for(var t=0;t<l.length;t++){var p=l[t],r=b[p];if(!F(r)){d=this.w[p]["@"+r];if(0===--k)return d;q.splice(q.indexOf(p),1);delete b[p];break}}l=Array(k);for(t=0;t<k;t++)l[t]=q[t].split(":")}else{if(H(b)){a=d||Object.keys(e);c=a.length;for(q=0;q<c;q++)k=e[a[q]],b(k)&&(f[g++]=k);return f}if(F(a))return[e[b]];if("id"===b)return[e[a]];q=[b];k=1;l=[b.split(":")];h=!0}d=d||Object.keys(e);
|
||||
t=d.length;for(p=0;p<t;p++){r=e[d[p]];let m=!0;for(let c=0;c<k;c++){h||(a=b[q[c]]);const d=l[c],e=d.length;let f=r;if(1<e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==a){m=!1;break}}if(m&&(f[g++]=r,c&&g===c))break}return f};l.prototype.info=function(){return{id:this.id,items:this.length,cache:this.cache&&this.cache.l?this.cache.l.length:!1,matcher:O.length+(this.m?this.m.length:0),worker:this.C,threshold:this.threshold,depth:this.depth,resolution:this.b,contextual:this.depth&&"strict"===this.c}};
|
||||
l.prototype.clear=function(){return this.destroy().init()};l.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.i=this.h=this.f=null;if(this.a){const b=this.a.keys;for(let a=0;a<b.length;a++)this.a.index[b[a]].destroy();this.a=this.g=null}return this};l.prototype.export=function(){if(this.a){const b=this.a.keys,a=Array(b.length+1);let c=0;for(;c<b.length;c++){const d=this.a.index[b[c]];a[c]=[d.i,d.h,Object.keys(d.f)]}a[c]=this.g;return JSON.stringify(a)}return JSON.stringify([this.i,
|
||||
this.h,Object.keys(this.f)])};l.prototype.import=function(b){b=JSON.parse(b);const a=r();if(this.a){var c=this.a.keys,d=c.length,e=b[0][2];for(var f=0;f<e.length;f++)a[e[f]]=1;for(e=0;e<d;e++)f=this.a.index[c[e]],f.i=b[e][0],f.h=b[e][1],f.f=a,f.g=b[d];this.g=b[d]}else{c=b[2];for(d=0;d<c.length;d++)a[c[d]]=1;this.i=b[0];this.h=b[1];this.f=a}};const M={icase:function(b){return b.toLowerCase()},simple:function(){const b=[h("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",h("[\u00e8\u00e9\u00ea\u00eb]"),
|
||||
"e",h("[\u00ec\u00ed\u00ee\u00ef]"),"i",h("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",h("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",h("[\u00fd\u0177\u00ff]"),"y",h("\u00f1"),"n",h("\u00e7"),"c",h("\u00df"),"s",h(" & ")," and ",h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(a){a=L(a.toLowerCase(),b);return" "===a?"":a}}(),advanced:function(){const b=[h("ae"),"a",h("ai"),"ei",h("ay"),"ei",h("ey"),"ei",h("oe"),"o",h("ue"),"u",h("ie"),"i",h("sz"),"s",h("zs"),"s",h("sh"),"s",h("ck"),"k",
|
||||
h("cc"),"k",h("dt"),"t",h("ph"),"f",h("pf"),"f",h("ou"),"o",h("uo"),"u"];return function(a,c){if(!a)return a;a=this.simple(a);2<a.length&&(a=L(a,b));c||1<a.length&&(a=Q(a));return a}}(),extra:function(){const b=[h("p"),"b",h("z"),"s",h("[cgq]"),"k",h("n"),"m",h("d"),"t",h("[vw]"),"f",h("[aeiouy]"),""];return function(a){if(!a)return a;a=this.advanced(a,!0);if(1<a.length){a=a.split(" ");for(let c=0;c<a.length;c++){const d=a[c];1<d.length&&(a[c]=d[0]+L(d.substring(1),b))}a=a.join(" ");a=Q(a)}return a}}(),
|
||||
balance:function(){const b=[h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(a){return Q(L(a.toLowerCase(),b))}}()},ea=function(){function b(a){this.clear();this.A=!0!==a&&a}b.prototype.clear=function(){this.cache=r();this.count=r();this.index=r();this.l=[]};b.prototype.set=function(a,b){if(this.A&&F(this.cache[a])){let c=this.l.length;if(c===this.A){c--;const a=this.l[c];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=c;this.l[c]=a;this.count[a]=-1;this.cache[a]=
|
||||
b;this.get(a)}else this.cache[a]=b};b.prototype.get=function(a){const b=this.cache[a];if(this.A&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.l;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return b}();return l}(!1),this);
|
||||
|
@@ -1383,7 +1383,16 @@
|
||||
|
||||
function merge_and_sort(query, bool, result, sort, limit, suggest, where, cursor, has_and, has_not){
|
||||
|
||||
result = intersect(result, where ? 0 : limit, cursor, SUPPORT_SUGGESTION && suggest, bool, has_and, has_not);
|
||||
result = intersect(
|
||||
|
||||
result,
|
||||
where ? 0 : limit,
|
||||
SUPPORT_PAGINATION && cursor,
|
||||
SUPPORT_SUGGESTION && suggest,
|
||||
bool,
|
||||
has_and,
|
||||
has_not
|
||||
);
|
||||
|
||||
let next;
|
||||
|
||||
@@ -1490,7 +1499,7 @@
|
||||
}
|
||||
|
||||
sort = SUPPORT_DOCUMENT && query["sort"];
|
||||
cursor = query["page"];
|
||||
cursor = SUPPORT_PAGINATION && query["page"];
|
||||
limit = query["limit"];
|
||||
threshold = query["threshold"];
|
||||
enrich = query["enrich"];
|
||||
@@ -1557,7 +1566,7 @@
|
||||
_query = queries[i];
|
||||
}
|
||||
|
||||
if(!is_string(_query)){
|
||||
if(cursor && !is_string(_query)){
|
||||
|
||||
_query["page"] = null;
|
||||
_query["limit"] = 0;
|
||||
|
12
package.json
12
package.json
@@ -26,12 +26,12 @@
|
||||
"url": "https://github.com/nextapps-de/flexsearch.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node compile RELEASE=min DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENT=true SUPPORT_WHERE=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-light": "node compile RELEASE=light DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESET=false SUPPORT_SUGGESTION=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENT=false SUPPORT_WHERE=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-compact": "node compile RELEASE=compact DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=false SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENT=true SUPPORT_WHERE=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-custom": "node compile RELEASE=custom DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESET=false SUPPORT_SUGGESTION=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENT=false SUPPORT_WHERE=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-es5": "node compile RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENT=true SUPPORT_WHERE=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT",
|
||||
"build-node": "node compile RELEASE=node DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENT=true SUPPORT_WHERE=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build": "node compile RELEASE=min DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENT=true SUPPORT_OPERATOR=true SUPPORT_WHERE=true SUPPORT_PAGINATION=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-light": "node compile RELEASE=light DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESET=false SUPPORT_SUGGESTION=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENT=false SUPPORT_OPERATOR=false SUPPORT_WHERE=false SUPPORT_PAGINATION=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-compact": "node compile RELEASE=compact DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=false SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENT=true SUPPORT_OPERATOR=true SUPPORT_WHERE=false SUPPORT_PAGINATION=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-custom": "node compile RELEASE=custom DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESET=false SUPPORT_SUGGESTION=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENT=false SUPPORT_OPERATOR=false SUPPORT_WHERE=false SUPPORT_PAGINATION=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-es5": "node compile RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENT=true SUPPORT_OPERATOR=true SUPPORT_WHERE=true SUPPORT_PAGINATION=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT",
|
||||
"build-node": "node compile RELEASE=node DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESET=true SUPPORT_SUGGESTION=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENT=true SUPPORT_OPERATOR=true SUPPORT_WHERE=true SUPPORT_PAGINATION=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-lang": "node compile RELEASE=lang",
|
||||
"build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-node",
|
||||
"test-production": "nyc --reporter=html --reporter=text mocha --timeout=3000 test --exit",
|
||||
|
23
test/test.js
23
test/test.js
@@ -870,7 +870,6 @@ describe("Encoding", function(){
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// CJK Word Break
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -897,6 +896,28 @@ describe("CJK Word Break", function(){
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Cyrillic Word Break
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
describe("Cyrillic Word Break", function(){
|
||||
|
||||
it("Should have been tokenized properly", function(){
|
||||
|
||||
var index = FlexSearch.create({
|
||||
encode: false,
|
||||
tokenize: function(str){
|
||||
return str.replace(/[\x00-\x7F]/g, "").split("");
|
||||
}
|
||||
});
|
||||
|
||||
index.add(0, "Фообар");
|
||||
|
||||
expect(index.search("Фообар")).to.include(0);
|
||||
expect(index.search("бар")).to.include(0);
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Right-To-Left
|
||||
// ------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user