diff --git a/dist/flexsearch.bundle.debug.js b/dist/flexsearch.bundle.debug.js index db88c9e..45b7226 100644 --- a/dist/flexsearch.bundle.debug.js +++ b/dist/flexsearch.bundle.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.135 (Bundle/Debug) + * FlexSearch.js v0.8.138 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -2548,7 +2548,7 @@ function Z(a) { a = null; }); } -;const ub = {Index:N, Charset:eb, Encoder:ka, Document:U, Worker:P, Resolver:W, IndexedDB:rb, Language:{}}, vb = "undefined" !== typeof global ? global : self; +;const ub = {Index:N, Charset:eb, Encoder:ka, Document:U, Worker:P, Resolver:W, IndexedDB:rb, Language:{}}, vb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; let wb; (wb = vb.define) && wb.amd ? wb([], function() { return ub; diff --git a/dist/flexsearch.bundle.min.js b/dist/flexsearch.bundle.min.js index 02c9dbd..ead5583 100644 --- a/dist/flexsearch.bundle.min.js +++ b/dist/flexsearch.bundle.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.135 (Bundle) + * FlexSearch.js v0.8.138 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -101,4 +101,4 @@ for(let n=0,m,q;nn&&!f&&"string"===typeof m&&!isNaN(m)&&(n=h.indexOf(parseInt(m,10)))&&(f=1),0<=n)if(d=1,1{a.onsuccess=function(){c(this.result)};a.oncomplete=function(){c()};a.onerror=b;a=null})};const ub={Index:N,Charset:eb,Encoder:J,Document:U,Worker:P,Resolver:W,IndexedDB:sb,Language:{}},vb="undefined"!==typeof global?global:self;let wb;(wb=vb.define)&&wb.amd?wb([],function(){return ub}):"object"===typeof vb.exports?vb.exports=ub:vb.FlexSearch=ub;}(this||self)); +tb(b,a,!0)}}),this.transaction("reg","readwrite",function(c){for(let b=0;b{a.onsuccess=function(){c(this.result)};a.oncomplete=function(){c()};a.onerror=b;a=null})};const ub={Index:N,Charset:eb,Encoder:J,Document:U,Worker:P,Resolver:W,IndexedDB:sb,Language:{}},vb="undefined"!==typeof self?self:"undefined"!==typeof global?global:self;let wb;(wb=vb.define)&&wb.amd?wb([],function(){return ub}):"object"===typeof vb.exports?vb.exports=ub:vb.FlexSearch=ub;}(this||self)); diff --git a/dist/flexsearch.bundle.module.debug.js b/dist/flexsearch.bundle.module.debug.js index 1a68b88..aef68ff 100644 --- a/dist/flexsearch.bundle.module.debug.js +++ b/dist/flexsearch.bundle.module.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.135 (Bundle/Module/Debug) + * FlexSearch.js v0.8.138 (Bundle/Module/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH diff --git a/dist/flexsearch.bundle.module.min.js b/dist/flexsearch.bundle.module.min.js index 5acf655..89dd8a5 100644 --- a/dist/flexsearch.bundle.module.min.js +++ b/dist/flexsearch.bundle.module.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.135 (Bundle/Module) + * FlexSearch.js v0.8.138 (Bundle/Module) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH diff --git a/dist/flexsearch.compact.debug.js b/dist/flexsearch.compact.debug.js index 50c9026..a5c5508 100644 --- a/dist/flexsearch.compact.debug.js +++ b/dist/flexsearch.compact.debug.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.135 (Bundle/Debug) + * FlexSearch.js v0.8.138 (Bundle/Debug) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -651,37 +651,38 @@ function za(a, c) { } return e; } -;function W(a, c, b) { +;function Aa(a, c, b, e) { if (!a.length) { return a; } if (1 === a.length) { - return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a; + return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, e ? W.call(this, a) : a; } - let e = []; - for (let d = 0, f, g; d < a.length; d++) { - if ((f = a[d]) && (g = f.length)) { + let d = []; + for (let f = 0, g, k; f < a.length; f++) { + if ((g = a[f]) && (k = g.length)) { if (b) { - if (b >= g) { - b -= g; + if (b >= k) { + b -= k; continue; } - b < g && (f = c ? f.slice(b, b + c) : f.slice(b), g = f.length, b = 0); + b < k && (g = c ? g.slice(b, b + c) : g.slice(b), k = g.length, b = 0); } - g > c && (f = f.slice(0, c), g = c); - if (!e.length && g >= c) { - return f; + k > c && (g = g.slice(0, c), k = c); + if (!d.length && k >= c) { + return e ? W.call(this, g) : g; } - e.push(f); - c -= g; + d.push(g); + c -= k; if (!c) { break; } } } - return e = 1 < e.length ? [].concat.apply([], e) : e[0]; + d = 1 < d.length ? [].concat.apply([], d) : d[0]; + return e ? W.call(this, d) : d; } -;function Aa(a, c, b) { +;function Ba(a, c, b) { var e = b[0]; if (e.then) { return Promise.all(b).then(function(m) { @@ -728,10 +729,10 @@ function za(a, c) { return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; } ;X.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Aa(this, "or", arguments); - return Ba.call(this, a, c, b, e, d, f); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Ba(this, "or", arguments); + return Ca.call(this, a, c, b, e, d, f); }; -function Ba(a, c, b, e, d, f) { +function Ca(a, c, b, e, d, f) { if (c.length) { const g = this; return Promise.all(c).then(function(k) { @@ -739,7 +740,7 @@ function Ba(a, c, b, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return Ba.call(g, a, [], b, e, d, f); + return Ca.call(g, a, [], b, e, d, f); }); } a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = ya(a, b, e), e = 0)); @@ -752,20 +753,20 @@ function Ba(a, c, b, e, d, f) { f && (a = !!f.suggest, d = f.resolve, c = f.limit, b = f.offset, e = f.enrich && d); } if (a) { - const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:n} = Aa(this, "and", arguments); - return Ca.call(this, f, g, k, h, l, m, n); + const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:n} = Ba(this, "and", arguments); + return Da.call(this, f, g, k, h, l, m, n); } return d ? this.resolve(c, b, e) : this; }; -function Ca(a, c, b, e, d, f, g) { +function Da(a, c, b, e, d, f, g) { if (c.length) { - const h = this; - return Promise.all(c).then(function(l) { + const k = this; + return Promise.all(c).then(function(h) { a = []; - for (let m = 0, n; m < l.length; m++) { - (n = l[m]).length && (a[m] = n); + for (let l = 0, m; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); } - return Ca.call(h, a, [], b, e, d, f, g); + return Da.call(k, a, [], b, e, d, f, g); }); } if (a.length) { @@ -773,10 +774,7 @@ function Ca(a, c, b, e, d, f, g) { this.result = a[0]; } else { if (c = aa(a)) { - this.result = xa(a, c, b, e, g); - var k; - f ? d ? k = this.result : k = this.result : k = this; - return k; + return this.result = xa(a, c, b, e, g), f ? d ? W.call(this.index, this.result) : this.result : this; } this.result = []; } @@ -786,40 +784,32 @@ function Ca(a, c, b, e, d, f, g) { return f ? this.resolve(b, e, d) : this; } ;X.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Aa(this, "xor", arguments); - return Da.call(this, a, c, b, e, d, f, g); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ba(this, "xor", arguments); + return Ea.call(this, a, c, b, e, d, f, g); }; -function Da(a, c, b, e, d, f, g) { +function Ea(a, c, b, e, d, f, g) { if (c.length) { - const h = this; - return Promise.all(c).then(function(l) { + const k = this; + return Promise.all(c).then(function(h) { a = []; - for (let m = 0, n; m < l.length; m++) { - (n = l[m]).length && (a[m] = n); + for (let l = 0, m; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); } - return Da.call(h, a, [], b, e, d, f, g); + return Ea.call(k, a, [], b, e, d, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - this.result = Ea.call(this, a, b, e, f, this.h); - if (f) { - var k; - d ? k = this.result : k = this.result; - c = k; - } else { - c = this; - } - return c; + return this.result = Fa.call(this, a, b, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(b, e, d) : this; } -function Ea(a, c, b, e, d) { +function Fa(a, c, b, e, d) { const f = [], g = C(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -865,35 +855,28 @@ function Ea(a, c, b, e, d) { return f; } ;X.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Aa(this, "not", arguments); - return Fa.call(this, a, c, b, e, d, f, g); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ba(this, "not", arguments); + return Ga.call(this, a, c, b, e, d, f, g); }; -function Fa(a, c, b, e, d, f, g) { +function Ga(a, c, b, e, d, f, g) { if (c.length) { - const h = this; - return Promise.all(c).then(function(l) { + const k = this; + return Promise.all(c).then(function(h) { a = []; - for (let m = 0, n; m < l.length; m++) { - (n = l[m]).length && (a[m] = n); + for (let l = 0, m; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); } - return Fa.call(h, a, [], b, e, d, f, g); + return Ga.call(k, a, [], b, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Ga.call(this, a, b, e, f); + this.result = Ha.call(this, a, b, e, f); } else if (f) { return this.resolve(b, e, d); } - if (f) { - var k; - d ? k = this.result : k = this.result; - c = k; - } else { - c = this; - } - return c; + return f ? d ? W.call(this.index, this.result) : this.result : this; } -function Ga(a, c, b, e) { +function Ha(a, c, b, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, k = 0; f < this.result.length; f++) { @@ -965,10 +948,10 @@ X.prototype.boost = function(a) { this.h += a; return this; }; -X.prototype.resolve = function(a, c) { - const b = this.result, e = this.index; +X.prototype.resolve = function(a, c, b) { + const e = this.result, d = this.index; this.result = this.index = null; - return b.length ? ("object" === typeof a && (c = a.offset, a = a.limit), W.call(e, b, a || 100, c)) : b; + return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), Aa.call(d, e, a || 100, c, b)) : e; }; C(); V.prototype.search = function(a, c, b, e) { @@ -1030,7 +1013,7 @@ V.prototype.search = function(a, c, b, e) { f = []; if (u.length) { for (p = 0; p < u.length; p += 2) { - q = Ha.call(this, u[p], u[p + 1], c, t), d.push({field:u[p], tag:u[p + 1], result:q}); + q = Ia.call(this, u[p], u[p + 1], c, t, g), d.push({field:u[p], tag:u[p + 1], result:q}); } } return f.length ? Promise.all(f).then(function(y) { @@ -1064,7 +1047,7 @@ V.prototype.search = function(a, c, b, e) { if (l && F) { w = []; z = 0; - for (let G = 0, H, Ya; G < l.length; G += 2) { + for (let G = 0, H, Za; G < l.length; G += 2) { H = this.tag.get(l[G]); if (!H) { if (console.warn("Tag '" + l[G] + ":" + l[G + 1] + "' will be skipped because there is no field '" + l[G] + "'."), k) { @@ -1073,7 +1056,7 @@ V.prototype.search = function(a, c, b, e) { return n ? d : new X(d); } } - if (Ya = (H = H && H.get(l[G + 1])) && H.length) { + if (Za = (H = H && H.get(l[G + 1])) && H.length) { z++, w.push(H); } else if (!k) { return n ? d : new X(d); @@ -1109,14 +1092,15 @@ V.prototype.search = function(a, c, b, e) { u = []; for (t = 0; t < f.length; t++) { e = d[t]; + g && e.length && "undefined" === typeof e[0].doc && (e = W.call(this, e)); if (p) { return n ? e : new X(e); } d[t] = {field:f[t], result:e}; } - return q ? Ia(d, c) : r ? Ja(d, a, this.index, this.field, this.C, r) : d; + return q ? Ja(d, c) : r ? Ka(d, a, this.index, this.field, this.C, r) : d; }; -function Ja(a, c, b, e, d, f) { +function Ka(a, c, b, e, d, f) { let g, k, h; for (let m = 0, n, r, p, q; m < a.length; m++) { let t = a[m].result; @@ -1158,7 +1142,7 @@ function Ja(a, c, b, e, d, f) { } return a; } -function Ia(a, c) { +function Ja(a, c) { const b = [], e = C(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1177,18 +1161,29 @@ function Ia(a, c) { } return b; } -function Ha(a, c, b, e) { - let d = this.tag.get(a); - if (!d) { +function Ia(a, c, b, e, d) { + let f = this.tag.get(a); + if (!f) { return console.warn("Tag '" + a + "' was not found"), []; } - if ((a = (d = d && d.get(c)) && d.length - e) && 0 < a) { + if ((a = (f = f && f.get(c)) && f.length - e) && 0 < a) { if (a > b || e) { - d = d.slice(e, e + b); + f = f.slice(e, e + b); } - return d; + d && (f = W.call(this, f)); + return f; } } +function W(a) { + if (!this || !this.store) { + return a; + } + const c = Array(a.length); + for (let b = 0, e; b < a.length; b++) { + e = a[b], c[b] = {id:e, doc:this.store.get(e)}; + } + return c; +} ;function V(a) { if (!this || this.constructor !== V) { return new V(a); @@ -1198,7 +1193,7 @@ function Ha(a, c, b, e) { this.C = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && Ka(b, this.J) || "id"; + this.key = (b = c.key || c.id) && La(b, this.J) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); this.A = (b = c.store || null) && b && !0 !== b && []; this.store = b && new Map(); @@ -1209,13 +1204,13 @@ function Ha(a, c, b, e) { let e = c.index || c.field || c; D(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], D(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new O(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Ka(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; + f = e[d], D(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new O(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = La(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; } if (this.A) { a = c.store; D(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = Ka(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = La(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); } } this.index = b; @@ -1231,14 +1226,14 @@ function Ha(a, c, b, e) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.B[d] = f.custom : (this.B[d] = Ka(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); + f.custom ? this.B[d] = f.custom : (this.B[d] = La(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); this.T[d] = g; this.tag.set(g, new Map()); } } } } -function Ka(a, c) { +function La(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { @@ -1306,7 +1301,7 @@ x.set = function(a, c) { this.store.set(a, c); return this; }; -x.searchCache = La; +x.searchCache = Ma; x.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1367,7 +1362,7 @@ x.import = function(a, c) { } }; ja(V.prototype); -function La(a, c, b) { +function Ma(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Y()); let e = this.cache.get(a); @@ -1408,31 +1403,31 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Ma = {normalize:function(a) { +const Na = {normalize:function(a) { return a.toLowerCase(); }}; -const Na = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); -const Oa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Pa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const Qa = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -const Ra = /[\x00-\x7F]+/g; +const Oa = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); +const Pa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Qa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const Ra = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; const Sa = /[\x00-\x7F]+/g; const Ta = /[\x00-\x7F]+/g; -var Ua = {LatinExact:{split:/\s+/, normalize:!1}, LatinDefault:Ma, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Na}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Na, matcher:Oa, replacer:Pa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Na, replacer:Pa.concat([/(?!^)[aeo]/g, ""]), matcher:Oa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +const Ua = /[\x00-\x7F]+/g; +var Va = {LatinExact:{split:/\s+/, normalize:!1}, LatinDefault:Na, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Oa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Oa, matcher:Pa, replacer:Qa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Oa, replacer:Qa.concat([/(?!^)[aeo]/g, ""]), matcher:Pa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; - let e = c.charAt(0), d = Qa[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Qa[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = Ra[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Ra[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } }}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ra, " "); + return ("" + a).replace(Sa, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Sa, ""); + return ("" + a).replace(Ta, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ta, " "); + return ("" + a).replace(Ua, " "); }}}; -const Va = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +const Wa = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; O.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { @@ -1445,7 +1440,7 @@ O.prototype.add = function(a, c, b, e) { let q = c[this.rtl ? e - 1 - p : p]; var d = q.length; if (d && (n || !m[q])) { - var f = this.score ? this.score(c, q, p, null, 0) : Wa(r, e, p), g = ""; + var f = this.score ? this.score(c, q, p, null, 0) : Xa(r, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { @@ -1453,7 +1448,7 @@ O.prototype.add = function(a, c, b, e) { for (f = d; f > t; f--) { g = q.substring(t, f); u = this.rtl ? d - 1 - t : t; - var k = this.score ? this.score(c, q, p, g, u) : Wa(r, e, p, d, u); + var k = this.score ? this.score(c, q, p, g, u) : Xa(r, e, p, d, u); Z(this, m, g, k, a, b); } } @@ -1463,7 +1458,7 @@ O.prototype.add = function(a, c, b, e) { if (1 < d) { for (k = d - 1; 0 < k; k--) { g = q[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, q, p, g, k) : Wa(r, e, p, d, k); + var h = this.score ? this.score(c, q, p, g, k) : Xa(r, e, p, d, k); Z(this, m, g, h, a, b); } g = ""; @@ -1480,7 +1475,7 @@ O.prototype.add = function(a, c, b, e) { for (d = C(), g = this.S, f = q, k = Math.min(n + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { if ((q = c[this.rtl ? e - 1 - p - h : p + h]) && !d[q]) { d[q] = 1; - const t = this.score ? this.score(c, f, p, q, h - 1) : Wa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; + const t = this.score ? this.score(c, f, p, q, h - 1) : Xa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; Z(this, l, u ? f : q, t, a, b, u ? q : f); } } @@ -1499,7 +1494,7 @@ function Z(a, c, b, e, d, f, g) { g ? (c = h || (c[b] = C()), c[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : c[b] = 1, (h = k.get(b)) ? k = h : k.set(b, k = []), k = k[e] || (k[e] = []), f && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k]))); } } -function Wa(a, c, b, e, d) { +function Xa(a, c, b, e, d) { return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; } ;O.prototype.search = function(a, c, b) { @@ -1520,11 +1515,11 @@ function Wa(a, c, b, e, d) { b = a.length; c = c || (k ? 100 : 0); if (1 === b) { - return g = c, (c = Xa(this, a[0], "")) && c.length ? W.call(this, c, g, d) : []; + return g = c, (c = Ya(this, a[0], "")) && c.length ? Aa.call(this, c, g, d) : []; } f = this.depth && !1 !== f; if (2 === b && f && !g) { - return g = c, (c = Xa(this, a[0], a[1])) && c.length ? W.call(this, c, g, d) : []; + return g = c, (c = Ya(this, a[0], a[1])) && c.length ? Aa.call(this, c, g, d) : []; } k = C(); let l = 0; @@ -1536,7 +1531,7 @@ function Wa(a, c, b, e, d) { for (let q, t; l < b; l++) { if ((t = a[l]) && !k[t]) { k[t] = 1; - q = Xa(this, t, m); + q = Ya(this, t, m); a: { f = q; var n = e, r = g, p = h; @@ -1575,14 +1570,14 @@ function Wa(a, c, b, e, d) { if (1 < e) { m = xa(a, h, c, d, g); } else if (1 === e) { - g = W.call(null, a[0], c, d); + g = Aa.call(null, a[0], c, d); break a; } g = m; } return g; }; -function Xa(a, c, b) { +function Ya(a, c, b) { let e; b && (e = a.bidirectional && c > b) && (e = b, b = c, c = e); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); @@ -1603,14 +1598,14 @@ function Xa(a, c, b) { } } } else { - Za(this.map, a), this.depth && Za(this.ctx, a); + $a(this.map, a), this.depth && $a(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function Za(a, c) { +function $a(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1625,7 +1620,7 @@ function Za(a, c) { } } else { for (let e of a.entries()) { - const d = e[0], f = Za(e[1], c); + const d = e[0], f = $a(e[1], c); f ? b += f : a.delete(d); } } @@ -1637,12 +1632,12 @@ function Za(a, c) { } if (a) { var b = D(a) ? a : a.preset; - b && (Va[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Va[b], a)); + b && (Wa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Wa[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? Ua[a.encoder] : a.encode || a.encoder || Ma; + const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? Va[a.encoder] : a.encode || a.encoder || Na; this.encoder = d.encode ? d : "object" === typeof d ? new K(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = b = (b = a.tokenize) && "default" !== b && b || "strict"; @@ -1678,7 +1673,7 @@ x.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; -function $a(a) { +function ab(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1686,7 +1681,7 @@ function $a(a) { } } else { for (const b of a.entries()) { - const e = b[0], d = $a(b[1]); + const e = b[0], d = ab(b[1]); d ? c += d : a.delete(e); } } @@ -1696,11 +1691,11 @@ x.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - $a(this.map); - this.depth && $a(this.ctx); + ab(this.map); + this.depth && ab(this.ctx); return this; }; -x.searchCache = La; +x.searchCache = Ma; x.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { @@ -1763,9 +1758,9 @@ x.serialize = function(a = !0) { }; ja(O.prototype); C(); -const ab = {Index:O, Charset:Ua, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, bb = "undefined" !== typeof global ? global : self; -let cb; -(cb = bb.define) && cb.amd ? cb([], function() { - return ab; -}) : "object" === typeof bb.exports ? bb.exports = ab : bb.FlexSearch = ab; +const bb = {Index:O, Charset:Va, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}, cb = "undefined" !== typeof self ? self : "undefined" !== typeof global ? global : self; +let db; +(db = cb.define) && db.amd ? db([], function() { + return bb; +}) : "object" === typeof cb.exports ? cb.exports = bb : cb.FlexSearch = bb; }(this||self)); diff --git a/dist/flexsearch.compact.min.js b/dist/flexsearch.compact.min.js index b8aa8c2..b351195 100644 --- a/dist/flexsearch.compact.min.js +++ b/dist/flexsearch.compact.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.135 (Bundle) + * FlexSearch.js v0.8.138 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -35,37 +35,36 @@ function ua(a,c){let b="";for(const e of a.entries()){a=e[0];const d=e[1];let f= f.I;if(g&&!g(c))continue;f.constructor===String&&(f=""+f);f=I(c,f)}if(d&&f){D(f)&&(f=[f]);for(let h=0,l,m;hb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} -function ya(a,c,b){const e=[],d=C();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}bc&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};X.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Aa(this,"and",arguments);return Ca.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; -function Ca(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(l){a=[];for(let m=0,n;ma.length)this.result=a[0];else{if(c=aa(a)){this.result=xa(a,c,b,e,g);var k;f?d?k=this.result:k=this.result:k=this;return k}this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};X.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Aa(this,"xor",arguments);return Da.call(this,a,c,b,e,d,f,g)}; -function Da(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(l){a=[];for(let m=0,n;ma.length)this.result=a[0];else{this.result=Ea.call(this,a,b,e,f,this.h);if(f){var k;d?k=this.result:k=this.result;c=k}else c=this;return c}else g||(this.result=a);return f?this.resolve(b,e,d):this} -function Ea(a,c,b,e,d){const f=[],g=C();let k=0;for(let h=0,l;hb||e)a=a.slice(e,e+b);return a}};function V(a){if(!this||this.constructor!==V)return new V(a);const c=a.document||a.doc||a;var b;this.C=[];this.field=[];this.J=[];this.key=(b=c.key||c.id)&&Ka(b,this.J)||"id";this.reg=(this.fastupdate=!!a.fastupdate)?new Map:new Set;this.A=(b=c.store||null)&&b&&!0!==b&&[];this.store=b&&new Map;this.cache=(b=a.cache||null)&&new Y(b);a.cache=!1;this.priority=a.priority||4;b=new Map;let e=c.index||c.field||c;D(e)&&(e=[e]);for(let d=0,f,g;dc?c?a.slice(b,b+c):a.slice(b):a,e?W.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?W.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};X.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; +function Da(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(c=aa(a))return this.result=xa(a,c,b,e,g),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};X.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Ba(this,"xor",arguments);return Ea.call(this,a,c,b,e,d,f,g)}; +function Ea(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Fa.call(this,a,b,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} +function Fa(a,c,b,e,d){const f=[],g=C();let k=0;for(let h=0,l;hb||e)a=a.slice(e,e+b);d&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -Y.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Ma={normalize:function(a){return a.toLowerCase()}};const Na=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Oa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Pa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Qa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const Ra=/[\x00-\x7F]+/g;const Sa=/[\x00-\x7F]+/g;const Ta=/[\x00-\x7F]+/g;var Ua={LatinExact:{split:/\s+/,normalize:!1},LatinDefault:Ma,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Na},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Na,matcher:Oa,replacer:Pa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Na,replacer:Pa.concat([/(?!^)[aeo]/g,""]),matcher:Oa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Wa(r,e,p,d,u); -Z(this,m,g,k,a,b)}break}case "reverse":if(1g?0:1),e,p,k-1,h-1),u=this.bidirectional&& -q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Wa(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};O.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Za(this.map,a),this.depth&&Za(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Za(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;ethis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:function(a){return a.toLowerCase()}};const Oa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Pa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Qa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Ra={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const Sa=/[\x00-\x7F]+/g;const Ta=/[\x00-\x7F]+/g;const Ua=/[\x00-\x7F]+/g;var Va={LatinExact:{split:/\s+/,normalize:!1},LatinDefault:Na,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Oa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Oa,matcher:Pa,replacer:Qa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Oa,replacer:Qa.concat([/(?!^)[aeo]/g,""]),matcher:Pa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Xa(r,e,p,d,u); +Z(this,m,g,k,a,b)}break}case "reverse":if(1g?0:1),e,p,k-1,h-1),u=this.bidirectional&& +q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Xa(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};O.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else $a(this.map,a),this.depth&&$a(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function $a(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};function $a(a){let c=0;if(a.constructor===Array)for(let b=0,e;bb.add(a,c)):this.add(a,c)};function ab(a){let c=0;if(a.constructor===Array)for(let b=0,e;b c ? c ? a.slice(b, b + c) : a.slice(b) : a; + return a = a[0], a = b || a.length > c ? c ? a.slice(b, b + c) : a.slice(b) : a, e ? W.call(this, a) : a; } - let e = []; - for (let d = 0, f, g; d < a.length; d++) { - if ((f = a[d]) && (g = f.length)) { + let d = []; + for (let f = 0, g, k; f < a.length; f++) { + if ((g = a[f]) && (k = g.length)) { if (b) { - if (b >= g) { - b -= g; + if (b >= k) { + b -= k; continue; } - b < g && (f = c ? f.slice(b, b + c) : f.slice(b), g = f.length, b = 0); + b < k && (g = c ? g.slice(b, b + c) : g.slice(b), k = g.length, b = 0); } - g > c && (f = f.slice(0, c), g = c); - if (!e.length && g >= c) { - return f; + k > c && (g = g.slice(0, c), k = c); + if (!d.length && k >= c) { + return e ? W.call(this, g) : g; } - e.push(f); - c -= g; + d.push(g); + c -= k; if (!c) { break; } } } - return e = 1 < e.length ? [].concat.apply([], e) : e[0]; + d = 1 < d.length ? [].concat.apply([], d) : d[0]; + return e ? W.call(this, d) : d; } -;function Aa(a, c, b) { +;function Ba(a, c, b) { var e = b[0]; if (e.then) { return Promise.all(b).then(function(m) { @@ -727,10 +728,10 @@ function za(a, c) { return {O:e, P:d, limit:f, offset:g, enrich:k, resolve:h, suggest:l}; } ;X.prototype.or = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Aa(this, "or", arguments); - return Ba.call(this, a, c, b, e, d, f); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f} = Ba(this, "or", arguments); + return Ca.call(this, a, c, b, e, d, f); }; -function Ba(a, c, b, e, d, f) { +function Ca(a, c, b, e, d, f) { if (c.length) { const g = this; return Promise.all(c).then(function(k) { @@ -738,7 +739,7 @@ function Ba(a, c, b, e, d, f) { for (let h = 0, l; h < k.length; h++) { (l = k[h]).length && (a[h] = l); } - return Ba.call(g, a, [], b, e, d, f); + return Ca.call(g, a, [], b, e, d, f); }); } a.length && (this.result.length && a.push(this.result), 2 > a.length ? this.result = a[0] : (this.result = ya(a, b, e), e = 0)); @@ -751,20 +752,20 @@ function Ba(a, c, b, e, d, f) { f && (a = !!f.suggest, d = f.resolve, c = f.limit, b = f.offset, e = f.enrich && d); } if (a) { - const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:n} = Aa(this, "and", arguments); - return Ca.call(this, f, g, k, h, l, m, n); + const {O:f, P:g, limit:k, offset:h, enrich:l, resolve:m, suggest:n} = Ba(this, "and", arguments); + return Da.call(this, f, g, k, h, l, m, n); } return d ? this.resolve(c, b, e) : this; }; -function Ca(a, c, b, e, d, f, g) { +function Da(a, c, b, e, d, f, g) { if (c.length) { - const h = this; - return Promise.all(c).then(function(l) { + const k = this; + return Promise.all(c).then(function(h) { a = []; - for (let m = 0, n; m < l.length; m++) { - (n = l[m]).length && (a[m] = n); + for (let l = 0, m; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); } - return Ca.call(h, a, [], b, e, d, f, g); + return Da.call(k, a, [], b, e, d, f, g); }); } if (a.length) { @@ -772,10 +773,7 @@ function Ca(a, c, b, e, d, f, g) { this.result = a[0]; } else { if (c = aa(a)) { - this.result = xa(a, c, b, e, g); - var k; - f ? d ? k = this.result : k = this.result : k = this; - return k; + return this.result = xa(a, c, b, e, g), f ? d ? W.call(this.index, this.result) : this.result : this; } this.result = []; } @@ -785,40 +783,32 @@ function Ca(a, c, b, e, d, f, g) { return f ? this.resolve(b, e, d) : this; } ;X.prototype.xor = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Aa(this, "xor", arguments); - return Da.call(this, a, c, b, e, d, f, g); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ba(this, "xor", arguments); + return Ea.call(this, a, c, b, e, d, f, g); }; -function Da(a, c, b, e, d, f, g) { +function Ea(a, c, b, e, d, f, g) { if (c.length) { - const h = this; - return Promise.all(c).then(function(l) { + const k = this; + return Promise.all(c).then(function(h) { a = []; - for (let m = 0, n; m < l.length; m++) { - (n = l[m]).length && (a[m] = n); + for (let l = 0, m; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); } - return Da.call(h, a, [], b, e, d, f, g); + return Ea.call(k, a, [], b, e, d, f, g); }); } if (a.length) { if (this.result.length && a.unshift(this.result), 2 > a.length) { this.result = a[0]; } else { - this.result = Ea.call(this, a, b, e, f, this.h); - if (f) { - var k; - d ? k = this.result : k = this.result; - c = k; - } else { - c = this; - } - return c; + return this.result = Fa.call(this, a, b, e, f, this.h), f ? d ? W.call(this.index, this.result) : this.result : this; } } else { g || (this.result = a); } return f ? this.resolve(b, e, d) : this; } -function Ea(a, c, b, e, d) { +function Fa(a, c, b, e, d) { const f = [], g = C(); let k = 0; for (let h = 0, l; h < a.length; h++) { @@ -864,35 +854,28 @@ function Ea(a, c, b, e, d) { return f; } ;X.prototype.not = function() { - const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Aa(this, "not", arguments); - return Fa.call(this, a, c, b, e, d, f, g); + const {O:a, P:c, limit:b, offset:e, enrich:d, resolve:f, suggest:g} = Ba(this, "not", arguments); + return Ga.call(this, a, c, b, e, d, f, g); }; -function Fa(a, c, b, e, d, f, g) { +function Ga(a, c, b, e, d, f, g) { if (c.length) { - const h = this; - return Promise.all(c).then(function(l) { + const k = this; + return Promise.all(c).then(function(h) { a = []; - for (let m = 0, n; m < l.length; m++) { - (n = l[m]).length && (a[m] = n); + for (let l = 0, m; l < h.length; l++) { + (m = h[l]).length && (a[l] = m); } - return Fa.call(h, a, [], b, e, d, f, g); + return Ga.call(k, a, [], b, e, d, f, g); }); } if (a.length && this.result.length) { - this.result = Ga.call(this, a, b, e, f); + this.result = Ha.call(this, a, b, e, f); } else if (f) { return this.resolve(b, e, d); } - if (f) { - var k; - d ? k = this.result : k = this.result; - c = k; - } else { - c = this; - } - return c; + return f ? d ? W.call(this.index, this.result) : this.result : this; } -function Ga(a, c, b, e) { +function Ha(a, c, b, e) { const d = []; a = new Set(a.flat().flat()); for (let f = 0, g, k = 0; f < this.result.length; f++) { @@ -964,10 +947,10 @@ X.prototype.boost = function(a) { this.h += a; return this; }; -X.prototype.resolve = function(a, c) { - const b = this.result, e = this.index; +X.prototype.resolve = function(a, c, b) { + const e = this.result, d = this.index; this.result = this.index = null; - return b.length ? ("object" === typeof a && (c = a.offset, a = a.limit), W.call(e, b, a || 100, c)) : b; + return e.length ? ("object" === typeof a && (b = a.enrich, c = a.offset, a = a.limit), Aa.call(d, e, a || 100, c, b)) : e; }; C(); V.prototype.search = function(a, c, b, e) { @@ -1029,7 +1012,7 @@ V.prototype.search = function(a, c, b, e) { f = []; if (u.length) { for (p = 0; p < u.length; p += 2) { - q = Ha.call(this, u[p], u[p + 1], c, t), d.push({field:u[p], tag:u[p + 1], result:q}); + q = Ia.call(this, u[p], u[p + 1], c, t, g), d.push({field:u[p], tag:u[p + 1], result:q}); } } return f.length ? Promise.all(f).then(function(y) { @@ -1063,7 +1046,7 @@ V.prototype.search = function(a, c, b, e) { if (l && F) { w = []; z = 0; - for (let G = 0, H, Va; G < l.length; G += 2) { + for (let G = 0, H, Wa; G < l.length; G += 2) { H = this.tag.get(l[G]); if (!H) { if (console.warn("Tag '" + l[G] + ":" + l[G + 1] + "' will be skipped because there is no field '" + l[G] + "'."), k) { @@ -1072,7 +1055,7 @@ V.prototype.search = function(a, c, b, e) { return n ? d : new X(d); } } - if (Va = (H = H && H.get(l[G + 1])) && H.length) { + if (Wa = (H = H && H.get(l[G + 1])) && H.length) { z++, w.push(H); } else if (!k) { return n ? d : new X(d); @@ -1108,14 +1091,15 @@ V.prototype.search = function(a, c, b, e) { u = []; for (t = 0; t < f.length; t++) { e = d[t]; + g && e.length && "undefined" === typeof e[0].doc && (e = W.call(this, e)); if (p) { return n ? e : new X(e); } d[t] = {field:f[t], result:e}; } - return q ? Ia(d, c) : r ? Ja(d, a, this.index, this.field, this.C, r) : d; + return q ? Ja(d, c) : r ? Ka(d, a, this.index, this.field, this.C, r) : d; }; -function Ja(a, c, b, e, d, f) { +function Ka(a, c, b, e, d, f) { let g, k, h; for (let m = 0, n, r, p, q; m < a.length; m++) { let t = a[m].result; @@ -1157,7 +1141,7 @@ function Ja(a, c, b, e, d, f) { } return a; } -function Ia(a, c) { +function Ja(a, c) { const b = [], e = C(); for (let d = 0, f, g; d < a.length; d++) { f = a[d]; @@ -1176,18 +1160,29 @@ function Ia(a, c) { } return b; } -function Ha(a, c, b, e) { - let d = this.tag.get(a); - if (!d) { +function Ia(a, c, b, e, d) { + let f = this.tag.get(a); + if (!f) { return console.warn("Tag '" + a + "' was not found"), []; } - if ((a = (d = d && d.get(c)) && d.length - e) && 0 < a) { + if ((a = (f = f && f.get(c)) && f.length - e) && 0 < a) { if (a > b || e) { - d = d.slice(e, e + b); + f = f.slice(e, e + b); } - return d; + d && (f = W.call(this, f)); + return f; } } +function W(a) { + if (!this || !this.store) { + return a; + } + const c = Array(a.length); + for (let b = 0, e; b < a.length; b++) { + e = a[b], c[b] = {id:e, doc:this.store.get(e)}; + } + return c; +} ;function V(a) { if (!this || this.constructor !== V) { return new V(a); @@ -1197,7 +1192,7 @@ function Ha(a, c, b, e) { this.C = []; this.field = []; this.J = []; - this.key = (b = c.key || c.id) && Ka(b, this.J) || "id"; + this.key = (b = c.key || c.id) && La(b, this.J) || "id"; this.reg = (this.fastupdate = !!a.fastupdate) ? new Map() : new Set(); this.A = (b = c.store || null) && b && !0 !== b && []; this.store = b && new Map(); @@ -1208,13 +1203,13 @@ function Ha(a, c, b, e) { let e = c.index || c.field || c; D(e) && (e = [e]); for (let d = 0, f, g; d < e.length; d++) { - f = e[d], D(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new O(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Ka(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; + f = e[d], D(f) || (g = f, f = f.field), g = I(g) ? Object.assign({}, a, g) : a, b.set(f, new O(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = La(f, this.J), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].I = g.filter)), this.field[d] = f; } if (this.A) { a = c.store; D(a) && (a = [a]); for (let d = 0, f, g; d < a.length; d++) { - f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = Ka(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); + f = a[d], g = f.field || f, f.custom ? (this.A[d] = f.custom, f.custom.U = g) : (this.A[d] = La(g, this.J), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].I = f.filter)); } } this.index = b; @@ -1230,14 +1225,14 @@ function Ha(a, c, b, e) { if (!g) { throw Error("The tag field from the document descriptor is undefined."); } - f.custom ? this.B[d] = f.custom : (this.B[d] = Ka(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); + f.custom ? this.B[d] = f.custom : (this.B[d] = La(g, this.J), f.filter && ("string" === typeof this.B[d] && (this.B[d] = new String(this.B[d])), this.B[d].I = f.filter)); this.T[d] = g; this.tag.set(g, new Map()); } } } } -function Ka(a, c) { +function La(a, c) { const b = a.split(":"); let e = 0; for (let d = 0; d < b.length; d++) { @@ -1305,7 +1300,7 @@ x.set = function(a, c) { this.store.set(a, c); return this; }; -x.searchCache = La; +x.searchCache = Ma; x.export = function(a, c, b = 0, e = 0) { if (b < this.field.length) { const g = this.field[b]; @@ -1366,7 +1361,7 @@ x.import = function(a, c) { } }; ja(V.prototype); -function La(a, c, b) { +function Ma(a, c, b) { a = ("object" === typeof a ? "" + a.query : a).toLowerCase(); this.cache || (this.cache = new Y()); let e = this.cache.get(a); @@ -1407,31 +1402,31 @@ Y.prototype.clear = function() { this.cache.clear(); this.h = ""; }; -const Ma = {normalize:function(a) { +const Na = {normalize:function(a) { return a.toLowerCase(); }}; -const Na = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); -const Oa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Pa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; -const Qa = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; -const Ra = /[\x00-\x7F]+/g; +const Oa = new Map([["b", "p"], ["v", "f"], ["w", "f"], ["z", "s"], ["x", "s"], ["d", "t"], ["n", "m"], ["c", "k"], ["g", "k"], ["j", "k"], ["q", "k"], ["i", "e"], ["y", "e"], ["u", "o"]]); +const Pa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["ph", "f"], ["pf", "f"]]), Qa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /(.)\1+/g, "$1"]; +const Ra = {a:"", e:"", i:"", o:"", u:"", y:"", b:1, f:1, p:1, v:1, c:2, g:2, j:2, k:2, q:2, s:2, x:2, z:2, "\u00df":2, d:3, t:3, l:4, m:5, n:5, r:6}; const Sa = /[\x00-\x7F]+/g; const Ta = /[\x00-\x7F]+/g; -var Ua = {LatinExact:{split:/\s+/, normalize:!1}, LatinDefault:Ma, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Na}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Na, matcher:Oa, replacer:Pa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Na, replacer:Pa.concat([/(?!^)[aeo]/g, ""]), matcher:Oa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { +const Ua = /[\x00-\x7F]+/g; +var Va = {LatinExact:{split:/\s+/, normalize:!1}, LatinDefault:Na, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:Oa}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:Oa, matcher:Pa, replacer:Qa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:Oa, replacer:Qa.concat([/(?!^)[aeo]/g, ""]), matcher:Pa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) { for (let b = 0; b < a.length; b++) { var c = a[b]; - let e = c.charAt(0), d = Qa[e]; - for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Qa[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { + let e = c.charAt(0), d = Ra[e]; + for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = Ra[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) { } a[b] = e; } }}, ArabicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ra, " "); + return ("" + a).replace(Sa, " "); }}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) { - return ("" + a).replace(Sa, ""); + return ("" + a).replace(Ta, ""); }}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) { - return ("" + a).replace(Ta, " "); + return ("" + a).replace(Ua, " "); }}}; -const Wa = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; +const Xa = {memory:{resolution:1}, performance:{resolution:3, fastupdate:!0, context:{depth:1, resolution:1}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:3}}}; O.prototype.add = function(a, c, b, e) { if (c && (a || 0 === a)) { if (!e && !b && this.reg.has(a)) { @@ -1444,7 +1439,7 @@ O.prototype.add = function(a, c, b, e) { let q = c[this.rtl ? e - 1 - p : p]; var d = q.length; if (d && (n || !m[q])) { - var f = this.score ? this.score(c, q, p, null, 0) : Xa(r, e, p), g = ""; + var f = this.score ? this.score(c, q, p, null, 0) : Ya(r, e, p), g = ""; switch(this.tokenize) { case "full": if (2 < d) { @@ -1452,7 +1447,7 @@ O.prototype.add = function(a, c, b, e) { for (f = d; f > t; f--) { g = q.substring(t, f); u = this.rtl ? d - 1 - t : t; - var k = this.score ? this.score(c, q, p, g, u) : Xa(r, e, p, d, u); + var k = this.score ? this.score(c, q, p, g, u) : Ya(r, e, p, d, u); Z(this, m, g, k, a, b); } } @@ -1462,7 +1457,7 @@ O.prototype.add = function(a, c, b, e) { if (1 < d) { for (k = d - 1; 0 < k; k--) { g = q[this.rtl ? d - 1 - k : k] + g; - var h = this.score ? this.score(c, q, p, g, k) : Xa(r, e, p, d, k); + var h = this.score ? this.score(c, q, p, g, k) : Ya(r, e, p, d, k); Z(this, m, g, h, a, b); } g = ""; @@ -1479,7 +1474,7 @@ O.prototype.add = function(a, c, b, e) { for (d = C(), g = this.S, f = q, k = Math.min(n + 1, this.rtl ? p + 1 : e - p), d[f] = 1, h = 1; h < k; h++) { if ((q = c[this.rtl ? e - 1 - p - h : p + h]) && !d[q]) { d[q] = 1; - const t = this.score ? this.score(c, f, p, q, h - 1) : Xa(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; + const t = this.score ? this.score(c, f, p, q, h - 1) : Ya(g + (e / 2 > g ? 0 : 1), e, p, k - 1, h - 1), u = this.bidirectional && q > f; Z(this, l, u ? f : q, t, a, b, u ? q : f); } } @@ -1498,7 +1493,7 @@ function Z(a, c, b, e, d, f, g) { g ? (c = h || (c[b] = C()), c[g] = 1, (h = k.get(g)) ? k = h : k.set(g, k = new Map())) : c[b] = 1, (h = k.get(b)) ? k = h : k.set(b, k = []), k = k[e] || (k[e] = []), f && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k]))); } } -function Xa(a, c, b, e, d) { +function Ya(a, c, b, e, d) { return b && 1 < a ? c + (e || 0) <= a ? b + (d || 0) : (a - 1) / (c + (e || 0)) * (b + (d || 0)) + 1 | 0 : 0; } ;O.prototype.search = function(a, c, b) { @@ -1519,11 +1514,11 @@ function Xa(a, c, b, e, d) { b = a.length; c = c || (k ? 100 : 0); if (1 === b) { - return g = c, (c = Ya(this, a[0], "")) && c.length ? W.call(this, c, g, d) : []; + return g = c, (c = Za(this, a[0], "")) && c.length ? Aa.call(this, c, g, d) : []; } f = this.depth && !1 !== f; if (2 === b && f && !g) { - return g = c, (c = Ya(this, a[0], a[1])) && c.length ? W.call(this, c, g, d) : []; + return g = c, (c = Za(this, a[0], a[1])) && c.length ? Aa.call(this, c, g, d) : []; } k = C(); let l = 0; @@ -1535,7 +1530,7 @@ function Xa(a, c, b, e, d) { for (let q, t; l < b; l++) { if ((t = a[l]) && !k[t]) { k[t] = 1; - q = Ya(this, t, m); + q = Za(this, t, m); a: { f = q; var n = e, r = g, p = h; @@ -1574,14 +1569,14 @@ function Xa(a, c, b, e, d) { if (1 < e) { m = xa(a, h, c, d, g); } else if (1 === e) { - g = W.call(null, a[0], c, d); + g = Aa.call(null, a[0], c, d); break a; } g = m; } return g; }; -function Ya(a, c, b) { +function Za(a, c, b) { let e; b && (e = a.bidirectional && c > b) && (e = b, b = c, c = e); a = b ? (a = a.ctx.get(b)) && a.get(c) : a.map.get(c); @@ -1602,14 +1597,14 @@ function Ya(a, c, b) { } } } else { - Za(this.map, a), this.depth && Za(this.ctx, a); + $a(this.map, a), this.depth && $a(this.ctx, a); } c || this.reg.delete(a); } this.cache && this.cache.remove(a); return this; }; -function Za(a, c) { +function $a(a, c) { let b = 0; if (a.constructor === Array) { for (let e = 0, d, f; e < a.length; e++) { @@ -1624,7 +1619,7 @@ function Za(a, c) { } } else { for (let e of a.entries()) { - const d = e[0], f = Za(e[1], c); + const d = e[0], f = $a(e[1], c); f ? b += f : a.delete(d); } } @@ -1636,12 +1631,12 @@ function Za(a, c) { } if (a) { var b = D(a) ? a : a.preset; - b && (Wa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Wa[b], a)); + b && (Xa[b] || console.warn("Preset not found: " + b), a = Object.assign({}, Xa[b], a)); } else { a = {}; } b = a.context; - const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? Ua[a.encoder] : a.encode || a.encoder || Ma; + const e = !0 === b ? {depth:1} : b || {}, d = D(a.encoder) ? Va[a.encoder] : a.encode || a.encoder || Na; this.encoder = d.encode ? d : "object" === typeof d ? new K(d) : {encode:d}; this.resolution = a.resolution || 9; this.tokenize = b = (b = a.tokenize) && "default" !== b && b || "strict"; @@ -1677,7 +1672,7 @@ x.update = function(a, c) { const b = this, e = this.remove(a); return e && e.then ? e.then(() => b.add(a, c)) : this.add(a, c); }; -function $a(a) { +function ab(a) { let c = 0; if (a.constructor === Array) { for (let b = 0, e; b < a.length; b++) { @@ -1685,7 +1680,7 @@ function $a(a) { } } else { for (const b of a.entries()) { - const e = b[0], d = $a(b[1]); + const e = b[0], d = ab(b[1]); d ? c += d : a.delete(e); } } @@ -1695,11 +1690,11 @@ x.cleanup = function() { if (!this.fastupdate) { return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this; } - $a(this.map); - this.depth && $a(this.ctx); + ab(this.map); + this.depth && ab(this.ctx); return this; }; -x.searchCache = La; +x.searchCache = Ma; x.export = function(a, c, b = 0, e = 0) { let d, f; switch(e) { @@ -1762,6 +1757,6 @@ x.serialize = function(a = !0) { }; ja(O.prototype); C(); -export default {Index:O, Charset:Ua, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; +export default {Index:O, Charset:Va, Encoder:K, Document:V, Worker:null, Resolver:null, IndexedDB:null, Language:{}}; -export const Index=O;export const Charset=Ua;export const Encoder=K;export const Document=V;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file +export const Index=O;export const Charset=Va;export const Encoder=K;export const Document=V;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={}; \ No newline at end of file diff --git a/dist/flexsearch.compact.module.min.js b/dist/flexsearch.compact.module.min.js index 13cc9b5..0470ca3 100644 --- a/dist/flexsearch.compact.module.min.js +++ b/dist/flexsearch.compact.module.min.js @@ -1,5 +1,5 @@ /**! - * FlexSearch.js v0.8.135 (Bundle) + * FlexSearch.js v0.8.138 (Bundle) * Author and Copyright: Thomas Wilkerling * Licence: Apache-2.0 * Hosted by Nextapps GmbH @@ -35,38 +35,37 @@ function ua(a,c){let b="";for(const e of a.entries()){a=e[0];const d=e[1];let f= f.I;if(g&&!g(c))continue;f.constructor===String&&(f=""+f);f=I(c,f)}if(d&&f){D(f)&&(f=[f]);for(let h=0,l,m;hb||e?g.slice(e,b+e):g;else{if(ab||e)g=g.slice(e,b+e)}return g} -function ya(a,c,b){const e=[],d=C();let f;var g=a.length;let k;for(let h=g-1;0<=h;h--)if(k=(g=a[h])&&g.length)for(let l=0;lc?c?a.slice(b,b+c):a.slice(b):a;let e=[];for(let d=0,f,g;d=g){b-=g;continue}bc&&(f=f.slice(0,c),g=c);if(!e.length&&g>=c)return f;e.push(f);c-=g;if(!c)break}return e=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};X.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Aa(this,"and",arguments);return Ca.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; -function Ca(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(l){a=[];for(let m=0,n;ma.length)this.result=a[0];else{if(c=aa(a)){this.result=xa(a,c,b,e,g);var k;f?d?k=this.result:k=this.result:k=this;return k}this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};X.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Aa(this,"xor",arguments);return Da.call(this,a,c,b,e,d,f,g)}; -function Da(a,c,b,e,d,f,g){if(c.length){const h=this;return Promise.all(c).then(function(l){a=[];for(let m=0,n;ma.length)this.result=a[0];else{this.result=Ea.call(this,a,b,e,f,this.h);if(f){var k;d?k=this.result:k=this.result;c=k}else c=this;return c}else g||(this.result=a);return f?this.resolve(b,e,d):this} -function Ea(a,c,b,e,d){const f=[],g=C();let k=0;for(let h=0,l;hb||e)a=a.slice(e,e+b);return a}};function V(a){if(!this||this.constructor!==V)return new V(a);const c=a.document||a.doc||a;var b;this.C=[];this.field=[];this.J=[];this.key=(b=c.key||c.id)&&Ka(b,this.J)||"id";this.reg=(this.fastupdate=!!a.fastupdate)?new Map:new Set;this.A=(b=c.store||null)&&b&&!0!==b&&[];this.store=b&&new Map;this.cache=(b=a.cache||null)&&new Y(b);a.cache=!1;this.priority=a.priority||4;b=new Map;let e=c.index||c.field||c;D(e)&&(e=[e]);for(let d=0,f,g;dc?c?a.slice(b,b+c):a.slice(b):a,e?W.call(this,a):a;let d=[];for(let f=0,g,k;f=k){b-=k;continue}bc&&(g=g.slice(0,c),k=c);if(!d.length&&k>=c)return e?W.call(this,g):g;d.push(g);c-=k;if(!c)break}d=1a.length?this.result=a[0]:(this.result=ya(a,b,e),e=0));return f?this.resolve(b,e,d):this};X.prototype.and=function(){let a=this.result.length,c,b,e,d;if(!a){const f=arguments[0];f&&(a=!!f.suggest,d=f.resolve,c=f.limit,b=f.offset,e=f.enrich&&d)}if(a){const {O:f,P:g,limit:k,offset:h,enrich:l,resolve:m,suggest:n}=Ba(this,"and",arguments);return Da.call(this,f,g,k,h,l,m,n)}return d?this.resolve(c,b,e):this}; +function Da(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else{if(c=aa(a))return this.result=xa(a,c,b,e,g),f?d?W.call(this.index,this.result):this.result:this;this.result=[]}else g||(this.result=a);return f?this.resolve(b,e,d):this};X.prototype.xor=function(){const {O:a,P:c,limit:b,offset:e,enrich:d,resolve:f,suggest:g}=Ba(this,"xor",arguments);return Ea.call(this,a,c,b,e,d,f,g)}; +function Ea(a,c,b,e,d,f,g){if(c.length){const k=this;return Promise.all(c).then(function(h){a=[];for(let l=0,m;la.length)this.result=a[0];else return this.result=Fa.call(this,a,b,e,f,this.h),f?d?W.call(this.index,this.result):this.result:this;else g||(this.result=a);return f?this.resolve(b,e,d):this} +function Fa(a,c,b,e,d){const f=[],g=C();let k=0;for(let h=0,l;hb||e)a=a.slice(e,e+b);d&&(a=W.call(this,a));return a}}function W(a){if(!this||!this.store)return a;const c=Array(a.length);for(let b=0,e;bthis.limit&&this.cache.delete(this.cache.keys().next().value)}; -Y.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Ma={normalize:function(a){return a.toLowerCase()}};const Na=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Oa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Pa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Qa={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const Ra=/[\x00-\x7F]+/g;const Sa=/[\x00-\x7F]+/g;const Ta=/[\x00-\x7F]+/g;var Va={LatinExact:{split:/\s+/,normalize:!1},LatinDefault:Ma,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Na},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Na,matcher:Oa,replacer:Pa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Na,replacer:Pa.concat([/(?!^)[aeo]/g,""]),matcher:Oa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Xa(r,e,p,d,u); -Z(this,m,g,k,a,b)}break}case "reverse":if(1g?0:1),e,p,k-1,h-1),u=this.bidirectional&& -q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Xa(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};O.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else Za(this.map,a),this.depth&&Za(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; -function Za(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;ethis.limit&&this.cache.delete(this.cache.keys().next().value)}; +Y.prototype.get=function(a){const c=this.cache.get(a);c&&this.h!==a&&(this.cache.delete(a),this.cache.set(this.h=a,c));return c};Y.prototype.remove=function(a){for(const c of this.cache){const b=c[0];c[1].includes(a)&&this.cache.delete(b)}};Y.prototype.clear=function(){this.cache.clear();this.h=""};const Na={normalize:function(a){return a.toLowerCase()}};const Oa=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]);const Pa=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Qa=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"];const Ra={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,"\u00df":2,d:3,t:3,l:4,m:5,n:5,r:6};const Sa=/[\x00-\x7F]+/g;const Ta=/[\x00-\x7F]+/g;const Ua=/[\x00-\x7F]+/g;var Wa={LatinExact:{split:/\s+/,normalize:!1},LatinDefault:Na,LatinSimple:{normalize:!0,dedupe:!0},LatinBalance:{normalize:!0,dedupe:!0,mapper:Oa},LatinAdvanced:{normalize:!0,dedupe:!0,mapper:Oa,matcher:Pa,replacer:Qa},LatinExtra:{normalize:!0,dedupe:!0,mapper:Oa,replacer:Qa.concat([/(?!^)[aeo]/g,""]),matcher:Pa},LatinSoundex:{normalize:!0,dedupe:!1,include:{letter:!0},finalize:function(a){for(let b=0;bt;f--){g=q.substring(t,f);u=this.rtl?d-1-t:t;var k=this.score?this.score(c,q,p,g,u):Ya(r,e,p,d,u); +Z(this,m,g,k,a,b)}break}case "reverse":if(1g?0:1),e,p,k-1,h-1),u=this.bidirectional&& +q>f;Z(this,l,u?f:q,t,a,b,u?q:f)}}}}this.fastupdate||this.reg.add(a)}}return this};function Z(a,c,b,e,d,f,g){let k=g?a.ctx:a.map,h;if(!c[b]||g&&!(h=c[b])[g])g?(c=h||(c[b]=C()),c[g]=1,(h=k.get(g))?k=h:k.set(g,k=new Map)):c[b]=1,(h=k.get(b))?k=h:k.set(b,k=[]),k=k[e]||(k[e]=[]),f&&k.includes(d)||(k.push(d),a.fastupdate&&((c=a.reg.get(d))?c.push(k):a.reg.set(d,[k])))}function Ya(a,c,b,e,d){return b&&1b)&&(e=b,b=c,c=e);a=b?(a=a.ctx.get(b))&&a.get(c):a.map.get(c);return a};O.prototype.remove=function(a,c){const b=this.reg.size&&(this.fastupdate?this.reg.get(a):this.reg.has(a));if(b){if(this.fastupdate)for(let e=0,d;ed.length)d.pop();else{const f=d.indexOf(a);f===b.length-1?d.pop():d.splice(f,1)}}else $a(this.map,a),this.depth&&$a(this.ctx,a);c||this.reg.delete(a)}this.cache&&this.cache.remove(a);return this}; +function $a(a,c){let b=0;if(a.constructor===Array)for(let e=0,d,f;eb.add(a,c)):this.add(a,c)};function $a(a){let c=0;if(a.constructor===Array)for(let b=0,e;bb.add(a,c)):this.add(a,c)};function ab(a){let c=0;if(a.constructor===Array)for(let b=0,e;bm&&!g&&"string"===typeof n&&!isNaN(n)&&(m=k.indexOf(parseInt(n,10)))&&(g=1),0<=m)if(e=1,1b)&& function P(a,c){let b=0;if(a.constructor===Array)for(let f=0,d,g;fb.add(a,c)):this.add(a,c)}; function Q(a){let c=0;if(a.constructor===Array)for(let b=0,f;b} */ -export const stemmer = new Map([["ational", ""], ["iveness", ""], ["fulness", ""], ["ousness", ""], ["ization", ""], ["tional", ""], ["biliti", ""], ["icate", ""], ["ative", ""], ["alize", ""], ["iciti", ""], ["entli", ""], ["ousli", ""], ["alism", ""], ["ation", ""], ["aliti", ""], ["iviti", ""], ["ement", ""], ["izer", ""], ["able", ""], ["alli", ""], ["ator", ""], ["logi", ""], ["ical", ""], ["ance", ""], ["ence", ""], ["ness", ""], ["ble", ""], ["ment", ""], ["eli", ""], ["bli", ""], ["ful", ""], ["ant", ""], ["ent", ""], ["ism", ""], ["ate", ""], ["iti", ""], ["ous", ""], ["ive", ""], ["ize", ""], ["ing", ""], ["ion", ""], ["al", ""], ["ou", ""], ["er", ""], ["ic", ""], ["ly", ""]]); +export const stemmer = new Map([["ational", ""], ["iveness", ""], ["fulness", ""], ["ousness", ""], ["ization", ""], ["tional", "tion"], ["biliti", ""], ["icate", ""], ["ative", ""], ["alize", ""], ["iciti", ""], ["entli", ""], ["ousli", ""], ["alism", ""], ["ation", ""], ["aliti", ""], ["iviti", ""], ["ement", ""], ["izer", ""], ["able", ""], ["ible", ""], ["alli", ""], ["ator", ""], ["less", ""], ["logi", ""], ["ical", ""], ["ance", ""], ["ence", ""], ["ness", ""], ["ble", ""], ["ment", ""], ["eli", ""], ["bli", ""], ["ful", ""], ["ant", ""], ["ent", ""], ["ism", ""], ["ate", ""], ["iti", ""], ["ous", ""], ["ive", ""], ["ize", ""], ["ing", ""], ["ion", ""], ["ies", "y"], ["al", ""], ["ou", ""], ["er", ""], ["ed", ""], ["es", "e"], ["ic", ""], ["ly", ""], ["li", ""], ["s", ""]]); /* he’s (= he is / he has) diff --git a/dist/module-min/bundle.js b/dist/module-min/bundle.js index cad799e..26f07c1 100644 --- a/dist/module-min/bundle.js +++ b/dist/module-min/bundle.js @@ -1 +1 @@ -import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,FieldOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions,PersistentOptions,ResolverOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/index.js";import Charset from"./charset.js";import{KeystoreMap,KeystoreArray,KeystoreSet}from"./keystore.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.serialize,Index.prototype.mount,Index.prototype.commit,Index.prototype.destroy,Index.prototype.encoder,Index.prototype.reg,Index.prototype.map,Index.prototype.ctx,Index.prototype.db,Index.prototype.tag,Index.prototype.store,Index.prototype.depth,Index.prototype.bidirectional,Index.prototype.commit_task,Index.prototype.commit_timer,Index.prototype.cache,Index.prototype.bypass,Index.prototype.document,Encoder.prototype.assign,Encoder.prototype.encode,Encoder.prototype.addMatcher,Encoder.prototype.addStemmer,Encoder.prototype.addFilter,Encoder.prototype.addMapper,Encoder.prototype.addReplacer,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.prototype.destroy,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Document.prototype.field,Document.prototype.index,Document.prototype.reg,Document.prototype.tag,Document.prototype.store,Document.prototype.fastupdate,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Resolver.prototype.result,StorageInterface.db,StorageInterface.id,StorageInterface.support_tag_search,StorageInterface.fastupdate,StorageInterface.prototype.mount,StorageInterface.prototype.open,StorageInterface.prototype.close,StorageInterface.prototype.destroy,StorageInterface.prototype.clear,StorageInterface.prototype.get,StorageInterface.prototype.tag,StorageInterface.prototype.enrich,StorageInterface.prototype.has,StorageInterface.prototype.search,StorageInterface.prototype.info,StorageInterface.prototype.commit,StorageInterface.prototype.remove,KeystoreArray.length,KeystoreMap.size,KeystoreSet.size,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.worker,IndexOptions.config,IndexOptions.priority,IndexOptions.export,IndexOptions.import,FieldOptions.preset,FieldOptions.context,FieldOptions.encoder,FieldOptions.encode,FieldOptions.resolution,FieldOptions.tokenize,FieldOptions.fastupdate,FieldOptions.score,FieldOptions.keystore,FieldOptions.rtl,FieldOptions.cache,FieldOptions.db,FieldOptions.config,FieldOptions.resolve,FieldOptions.field,FieldOptions.filter,FieldOptions.custom,FieldOptions.worker,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,DocumentOptions.priority,DocumentOptions.export,DocumentOptions.import,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,DocumentDescriptor.id,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,SearchOptions.resolution,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,DocumentSearchOptions.highlight,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char,PersistentOptions.name,PersistentOptions.field,PersistentOptions.type,PersistentOptions.db,ResolverOptions.index,ResolverOptions.query,ResolverOptions.limit,ResolverOptions.offset,ResolverOptions.enrich,ResolverOptions.resolve,ResolverOptions.suggest,ResolverOptions.and,ResolverOptions.or,ResolverOptions.xor,ResolverOptions.not;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{const a="undefined"==typeof global?self:global;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}export default FlexSearch;export{Index,Document,Encoder,Charset,WorkerIndex as Worker,Resolver,IdxDB as IndexedDB}; \ No newline at end of file +import{SearchOptions,ContextOptions,DocumentDescriptor,DocumentSearchOptions,FieldOptions,IndexOptions,DocumentOptions,TagOptions,StoreOptions,EncoderOptions,EncoderSplitOptions,PersistentOptions,ResolverOptions}from"./type.js";import StorageInterface from"./db/interface.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker.js";import Resolver from"./resolver.js";import Encoder from"./encoder.js";import IdxDB from"./db/indexeddb/index.js";import Charset from"./charset.js";import{KeystoreMap,KeystoreArray,KeystoreSet}from"./keystore.js";Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,Index.prototype.clear,Index.prototype.cleanup,Index.prototype.searchCache,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync,Index.prototype.export,Index.prototype.import,Index.prototype.serialize,Index.prototype.mount,Index.prototype.commit,Index.prototype.destroy,Index.prototype.encoder,Index.prototype.reg,Index.prototype.map,Index.prototype.ctx,Index.prototype.db,Index.prototype.tag,Index.prototype.store,Index.prototype.depth,Index.prototype.bidirectional,Index.prototype.commit_task,Index.prototype.commit_timer,Index.prototype.cache,Index.prototype.bypass,Index.prototype.document,Encoder.prototype.assign,Encoder.prototype.encode,Encoder.prototype.addMatcher,Encoder.prototype.addStemmer,Encoder.prototype.addFilter,Encoder.prototype.addMapper,Encoder.prototype.addReplacer,Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.clear,Document.prototype.cleanup,Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Document.prototype.mount,Document.prototype.commit,Document.prototype.destroy,Document.prototype.export,Document.prototype.import,Document.prototype.searchCache,Document.prototype.get,Document.prototype.set,Document.prototype.field,Document.prototype.index,Document.prototype.reg,Document.prototype.tag,Document.prototype.store,Document.prototype.fastupdate,Resolver.prototype.limit,Resolver.prototype.offset,Resolver.prototype.boost,Resolver.prototype.resolve,Resolver.prototype.or,Resolver.prototype.and,Resolver.prototype.xor,Resolver.prototype.not,Resolver.prototype.result,StorageInterface.db,StorageInterface.id,StorageInterface.support_tag_search,StorageInterface.fastupdate,StorageInterface.prototype.mount,StorageInterface.prototype.open,StorageInterface.prototype.close,StorageInterface.prototype.destroy,StorageInterface.prototype.clear,StorageInterface.prototype.get,StorageInterface.prototype.tag,StorageInterface.prototype.enrich,StorageInterface.prototype.has,StorageInterface.prototype.search,StorageInterface.prototype.info,StorageInterface.prototype.commit,StorageInterface.prototype.remove,KeystoreArray.length,KeystoreMap.size,KeystoreSet.size,Charset.LatinExact,Charset.LatinDefault,Charset.LatinSimple,Charset.LatinBalance,Charset.LatinAdvanced,Charset.LatinExtra,Charset.LatinSoundex,Charset.ArabicDefault,Charset.CjkDefault,Charset.CyrillicDefault,IndexOptions.preset,IndexOptions.context,IndexOptions.encoder,IndexOptions.encode,IndexOptions.resolution,IndexOptions.tokenize,IndexOptions.fastupdate,IndexOptions.score,IndexOptions.keystore,IndexOptions.rtl,IndexOptions.cache,IndexOptions.resolve,IndexOptions.db,IndexOptions.worker,IndexOptions.config,IndexOptions.priority,IndexOptions.export,IndexOptions.import,FieldOptions.preset,FieldOptions.context,FieldOptions.encoder,FieldOptions.encode,FieldOptions.resolution,FieldOptions.tokenize,FieldOptions.fastupdate,FieldOptions.score,FieldOptions.keystore,FieldOptions.rtl,FieldOptions.cache,FieldOptions.db,FieldOptions.config,FieldOptions.resolve,FieldOptions.field,FieldOptions.filter,FieldOptions.custom,FieldOptions.worker,DocumentOptions.context,DocumentOptions.encoder,DocumentOptions.encode,DocumentOptions.resolution,DocumentOptions.tokenize,DocumentOptions.fastupdate,DocumentOptions.score,DocumentOptions.keystore,DocumentOptions.rtl,DocumentOptions.cache,DocumentOptions.db,DocumentOptions.doc,DocumentOptions.document,DocumentOptions.worker,DocumentOptions.priority,DocumentOptions.export,DocumentOptions.import,ContextOptions.depth,ContextOptions.bidirectional,ContextOptions.resolution,DocumentDescriptor.field,DocumentDescriptor.index,DocumentDescriptor.tag,DocumentDescriptor.store,DocumentDescriptor.id,TagOptions.field,TagOptions.tag,TagOptions.filter,TagOptions.custom,TagOptions.keystore,TagOptions.db,TagOptions.config,StoreOptions.field,StoreOptions.filter,StoreOptions.custom,StoreOptions.config,SearchOptions.query,SearchOptions.limit,SearchOptions.offset,SearchOptions.context,SearchOptions.suggest,SearchOptions.resolve,SearchOptions.enrich,SearchOptions.resolution,DocumentSearchOptions.query,DocumentSearchOptions.limit,DocumentSearchOptions.offset,DocumentSearchOptions.context,DocumentSearchOptions.suggest,DocumentSearchOptions.enrich,DocumentSearchOptions.tag,DocumentSearchOptions.field,DocumentSearchOptions.index,DocumentSearchOptions.pluck,DocumentSearchOptions.merge,DocumentSearchOptions.highlight,EncoderOptions.rtl,EncoderOptions.dedupe,EncoderOptions.split,EncoderOptions.include,EncoderOptions.exclude,EncoderOptions.prepare,EncoderOptions.finalize,EncoderOptions.filter,EncoderOptions.matcher,EncoderOptions.mapper,EncoderOptions.stemmer,EncoderOptions.replacer,EncoderOptions.minlength,EncoderOptions.maxlength,EncoderOptions.cache,EncoderSplitOptions.letter,EncoderSplitOptions.number,EncoderSplitOptions.symbol,EncoderSplitOptions.punctuation,EncoderSplitOptions.control,EncoderSplitOptions.char,PersistentOptions.name,PersistentOptions.field,PersistentOptions.type,PersistentOptions.db,ResolverOptions.index,ResolverOptions.query,ResolverOptions.limit,ResolverOptions.offset,ResolverOptions.enrich,ResolverOptions.resolve,ResolverOptions.suggest,ResolverOptions.and,ResolverOptions.or,ResolverOptions.xor,ResolverOptions.not;const FlexSearch={Index:Index,Charset:Charset,Encoder:Encoder,Document:Document,Worker:WorkerIndex,Resolver:Resolver,IndexedDB:IdxDB,Language:{}};{const a="undefined"==typeof self?"undefined"==typeof global?self:global:self;let b;(b=a.define)&&b.amd?b([],function(){return FlexSearch}):"object"==typeof a.exports?a.exports=FlexSearch:a.FlexSearch=FlexSearch}export default FlexSearch;export{Index,Document,Encoder,Charset,WorkerIndex as Worker,Resolver,IdxDB as IndexedDB}; \ No newline at end of file diff --git a/dist/module-min/lang/en.js b/dist/module-min/lang/en.js index c57a8aa..ea105df 100644 --- a/dist/module-min/lang/en.js +++ b/dist/module-min/lang/en.js @@ -1 +1 @@ -import{EncoderOptions}from"../type.js";export const filter=new Set(["a","about","above","after","again","against","all","also","am","an","and","any","are","arent","as","at","back","be","because","been","before","being","below","between","both","but","by","can","cannot","cant","come","could","couldnt","did","didnt","do","does","doesnt","doing","dont","down","during","each","even","few","for","from","further","get","go","good","had","hadnt","has","hasnt","have","havent","having","he","hed","her","here","heres","hers","herself","hes","him","himself","his","how","hows","i","id","if","ill","im","in","into","is","isnt","it","its","itself","ive","just","know","lets","like","lot","make","made","me","more","most","mustnt","my","myself","new","no","nor","not","now","of","off","on","once","one","only","or","other","ought","our","ours","ourselves","out","over","own","people","same","say","see","shant","she","shed","shell","shes","should","shouldnt","so","some","such","take","than","that","thats","the","their","theirs","them","themselves","then","there","theres","these","they","theyd","theyll","theyre","theyve","think","this","those","through","time","times","to","too","under","until","up","us","use","very","want","was","wasnt","way","we","wed","well","were","werent","weve","what","whats","when","whens","where","wheres","which","while","who","whom","whos","why","whys","will","with","wont","work","would","wouldnt","ya","you","youd","youll","your","youre","yours","yourself","yourselves","youve"]);export const stemmer=new Map([["ational",""],["iveness",""],["fulness",""],["ousness",""],["ization",""],["tional",""],["biliti",""],["icate",""],["ative",""],["alize",""],["iciti",""],["entli",""],["ousli",""],["alism",""],["ation",""],["aliti",""],["iviti",""],["ement",""],["izer",""],["able",""],["alli",""],["ator",""],["logi",""],["ical",""],["ance",""],["ence",""],["ness",""],["ble",""],["ment",""],["eli",""],["bli",""],["ful",""],["ant",""],["ent",""],["ism",""],["ate",""],["iti",""],["ous",""],["ive",""],["ize",""],["ing",""],["ion",""],["al",""],["ou",""],["er",""],["ic",""],["ly",""]]);const options={prepare:function(a){return a.replace(/´`’ʼ/g,"'").replace(/_+/g," ").replace(/&/g," and ").replace(/\$/g," USD ").replace(/£/g," GBP ").replace(/([a-z])'s\b/g,"$1 is").replace(/\bi'm\b/g,"i am").replace(/\b(can't|cannot)\b/g,"can not").replace(/\bwon't\b/g,"will not").replace(/([a-z])n't\b/g,"$1 not").replace(/([a-z])'ll\b/g,"$1 will").replace(/([a-z])'re\b/g,"$1 are").replace(/([a-z])'ve\b/g,"$1 have").replace(/([a-z])'d\b/g,"$1 would")},filter:filter,stemmer:stemmer};export default options; \ No newline at end of file +import{EncoderOptions}from"../type.js";export const filter=new Set(["a","about","above","after","again","against","all","also","am","an","and","any","are","arent","as","at","back","be","because","been","before","being","below","between","both","but","by","can","cannot","cant","come","could","couldnt","did","didnt","do","does","doesnt","doing","dont","down","during","each","even","few","for","from","further","get","go","good","had","hadnt","has","hasnt","have","havent","having","he","hed","her","here","heres","hers","herself","hes","him","himself","his","how","hows","i","id","if","ill","im","in","into","is","isnt","it","its","itself","ive","just","know","lets","like","lot","make","made","me","more","most","mustnt","my","myself","new","no","nor","not","now","of","off","on","once","one","only","or","other","ought","our","ours","ourselves","out","over","own","people","same","say","see","shant","she","shed","shell","shes","should","shouldnt","so","some","such","take","than","that","thats","the","their","theirs","them","themselves","then","there","theres","these","they","theyd","theyll","theyre","theyve","think","this","those","through","time","times","to","too","under","until","up","us","use","very","want","was","wasnt","way","we","wed","well","were","werent","weve","what","whats","when","whens","where","wheres","which","while","who","whom","whos","why","whys","will","with","wont","work","would","wouldnt","ya","you","youd","youll","your","youre","yours","yourself","yourselves","youve"]);export const stemmer=new Map([["ational",""],["iveness",""],["fulness",""],["ousness",""],["ization",""],["tional","tion"],["biliti",""],["icate",""],["ative",""],["alize",""],["iciti",""],["entli",""],["ousli",""],["alism",""],["ation",""],["aliti",""],["iviti",""],["ement",""],["izer",""],["able",""],["ible",""],["alli",""],["ator",""],["less",""],["logi",""],["ical",""],["ance",""],["ence",""],["ness",""],["ble",""],["ment",""],["eli",""],["bli",""],["ful",""],["ant",""],["ent",""],["ism",""],["ate",""],["iti",""],["ous",""],["ive",""],["ize",""],["ing",""],["ion",""],["ies","y"],["al",""],["ou",""],["er",""],["ed",""],["es","e"],["ic",""],["ly",""],["li",""],["s",""]]);const options={prepare:function(a){return a.replace(/´`’ʼ/g,"'").replace(/_+/g," ").replace(/&/g," and ").replace(/\$/g," USD ").replace(/£/g," GBP ").replace(/([a-z])'s\b/g,"$1 is").replace(/\bi'm\b/g,"i am").replace(/\b(can't|cannot)\b/g,"can not").replace(/\bwon't\b/g,"will not").replace(/([a-z])n't\b/g,"$1 not").replace(/([a-z])'ll\b/g,"$1 will").replace(/([a-z])'re\b/g,"$1 are").replace(/([a-z])'ve\b/g,"$1 have").replace(/([a-z])'d\b/g,"$1 would")},filter:filter,stemmer:stemmer};export default options; \ No newline at end of file diff --git a/dist/module/bundle.js b/dist/module/bundle.js index 8bd3219..95e5e38 100644 --- a/dist/module/bundle.js +++ b/dist/module/bundle.js @@ -287,10 +287,7 @@ const FlexSearch = { // Legacy Browser: this refers to window // ESM Browser: self refers to window // NodeJS: global refers to the global scope - const root = "undefined" != typeof global ? global : - //typeof window !== "undefined" ? window : - self; - //const root = self; + const root = "undefined" != typeof self ? self : "undefined" != typeof global ? global : self; let prop; // AMD (RequireJS) diff --git a/dist/module/lang/en.js b/dist/module/lang/en.js index c651a81..f5afb90 100644 --- a/dist/module/lang/en.js +++ b/dist/module/lang/en.js @@ -26,7 +26,7 @@ export const filter = new Set(["a", "about", "above", "after", "again", "against * @type {Map} */ -export const stemmer = new Map([["ational", ""], ["iveness", ""], ["fulness", ""], ["ousness", ""], ["ization", ""], ["tional", ""], ["biliti", ""], ["icate", ""], ["ative", ""], ["alize", ""], ["iciti", ""], ["entli", ""], ["ousli", ""], ["alism", ""], ["ation", ""], ["aliti", ""], ["iviti", ""], ["ement", ""], ["izer", ""], ["able", ""], ["alli", ""], ["ator", ""], ["logi", ""], ["ical", ""], ["ance", ""], ["ence", ""], ["ness", ""], ["ble", ""], ["ment", ""], ["eli", ""], ["bli", ""], ["ful", ""], ["ant", ""], ["ent", ""], ["ism", ""], ["ate", ""], ["iti", ""], ["ous", ""], ["ive", ""], ["ize", ""], ["ing", ""], ["ion", ""], ["al", ""], ["ou", ""], ["er", ""], ["ic", ""], ["ly", ""]]); +export const stemmer = new Map([["ational", ""], ["iveness", ""], ["fulness", ""], ["ousness", ""], ["ization", ""], ["tional", "tion"], ["biliti", ""], ["icate", ""], ["ative", ""], ["alize", ""], ["iciti", ""], ["entli", ""], ["ousli", ""], ["alism", ""], ["ation", ""], ["aliti", ""], ["iviti", ""], ["ement", ""], ["izer", ""], ["able", ""], ["ible", ""], ["alli", ""], ["ator", ""], ["less", ""], ["logi", ""], ["ical", ""], ["ance", ""], ["ence", ""], ["ness", ""], ["ble", ""], ["ment", ""], ["eli", ""], ["bli", ""], ["ful", ""], ["ant", ""], ["ent", ""], ["ism", ""], ["ate", ""], ["iti", ""], ["ous", ""], ["ive", ""], ["ize", ""], ["ing", ""], ["ion", ""], ["ies", "y"], ["al", ""], ["ou", ""], ["er", ""], ["ed", ""], ["es", "e"], ["ic", ""], ["ly", ""], ["li", ""], ["s", ""]]); /* he’s (= he is / he has) diff --git a/example/nodejs-esm/basic-export-import/index.js b/example/nodejs-esm/basic-export-import/index.js index 744c906..69121cf 100644 --- a/example/nodejs-esm/basic-export-import/index.js +++ b/example/nodejs-esm/basic-export-import/index.js @@ -1,4 +1,4 @@ -import { Index } from "flexsearch/esm"; +import { Index } from "flexsearch"; // you will need to keep the index configuration // they will not export, also every change to the diff --git a/example/nodejs-esm/basic-persistent/index.js b/example/nodejs-esm/basic-persistent/index.js index f9b47d7..ea77b0f 100644 --- a/example/nodejs-esm/basic-persistent/index.js +++ b/example/nodejs-esm/basic-persistent/index.js @@ -1,4 +1,4 @@ -import { Index } from "flexsearch/esm"; +import { Index } from "flexsearch"; import Sqlite from "flexsearch/db/sqlite"; // import Postgres from "flexsearch/db/postgres"; // import MongoDB from "flexsearch/db/mongodb"; diff --git a/example/nodejs-esm/basic-resolver/index.js b/example/nodejs-esm/basic-resolver/index.js index 8848171..f25b4b5 100644 --- a/example/nodejs-esm/basic-resolver/index.js +++ b/example/nodejs-esm/basic-resolver/index.js @@ -1,4 +1,4 @@ -import { Index } from "flexsearch/esm"; +import { Index } from "flexsearch"; // create a simple index which can store id-content-pairs const index = new Index({ diff --git a/example/nodejs-esm/basic-suggestion/index.js b/example/nodejs-esm/basic-suggestion/index.js index 8848171..f25b4b5 100644 --- a/example/nodejs-esm/basic-suggestion/index.js +++ b/example/nodejs-esm/basic-suggestion/index.js @@ -1,4 +1,4 @@ -import { Index } from "flexsearch/esm"; +import { Index } from "flexsearch"; // create a simple index which can store id-content-pairs const index = new Index({ diff --git a/example/nodejs-esm/basic-worker-export-import/config.js b/example/nodejs-esm/basic-worker-export-import/config.js index 907c96d..4464e7d 100644 --- a/example/nodejs-esm/basic-worker-export-import/config.js +++ b/example/nodejs-esm/basic-worker-export-import/config.js @@ -1,4 +1,4 @@ -import { Encoder } from "flexsearch/esm"; +import { Encoder } from "flexsearch"; import { promises as fs } from "fs"; (async function(){ diff --git a/example/nodejs-esm/basic-worker-export-import/index.js b/example/nodejs-esm/basic-worker-export-import/index.js index 67f7ab3..217e740 100644 --- a/example/nodejs-esm/basic-worker-export-import/index.js +++ b/example/nodejs-esm/basic-worker-export-import/index.js @@ -1,4 +1,4 @@ -import { Worker as WorkerIndex } from "flexsearch/esm"; +import { Worker as WorkerIndex } from "flexsearch"; const dirname = import.meta.dirname; // you will need to keep the index configuration diff --git a/example/nodejs-esm/basic-worker-extern-config/config.js b/example/nodejs-esm/basic-worker-extern-config/config.js index 3bf5a68..872ef84 100644 --- a/example/nodejs-esm/basic-worker-extern-config/config.js +++ b/example/nodejs-esm/basic-worker-extern-config/config.js @@ -1,4 +1,4 @@ -import { Encoder } from "flexsearch/esm"; +import { Encoder } from "flexsearch"; export default { tokenize: "forward", diff --git a/example/nodejs-esm/basic-worker-extern-config/index.js b/example/nodejs-esm/basic-worker-extern-config/index.js index 5038267..4735a96 100644 --- a/example/nodejs-esm/basic-worker-extern-config/index.js +++ b/example/nodejs-esm/basic-worker-extern-config/index.js @@ -1,4 +1,4 @@ -import { Worker as WorkerIndex } from "flexsearch/esm"; +import { Worker as WorkerIndex } from "flexsearch"; const dirname = import.meta.dirname; (async function(){ diff --git a/example/nodejs-esm/basic-worker/index.js b/example/nodejs-esm/basic-worker/index.js index 4797f39..5fef25d 100644 --- a/example/nodejs-esm/basic-worker/index.js +++ b/example/nodejs-esm/basic-worker/index.js @@ -1,4 +1,4 @@ -import { Worker as WorkerIndex } from "flexsearch/esm"; +import { Worker as WorkerIndex } from "flexsearch"; (async function(){ diff --git a/example/nodejs-esm/basic/index.js b/example/nodejs-esm/basic/index.js index 961cb16..1b6573d 100644 --- a/example/nodejs-esm/basic/index.js +++ b/example/nodejs-esm/basic/index.js @@ -1,4 +1,4 @@ -import { Index } from "flexsearch/esm"; +import { Index } from "flexsearch"; // create a simple index which can store id-content-pairs const index = new Index({ diff --git a/example/nodejs-esm/document-export-import/index.js b/example/nodejs-esm/document-export-import/index.js index 7f4f6f2..558101b 100644 --- a/example/nodejs-esm/document-export-import/index.js +++ b/example/nodejs-esm/document-export-import/index.js @@ -1,4 +1,4 @@ -import { Document, Charset } from "flexsearch/esm"; +import { Document, Charset } from "flexsearch"; import { promises as fs } from "fs"; const dirname = import.meta.dirname; diff --git a/example/nodejs-esm/document-persistent/index.js b/example/nodejs-esm/document-persistent/index.js index 34c3e5d..e5991e5 100644 --- a/example/nodejs-esm/document-persistent/index.js +++ b/example/nodejs-esm/document-persistent/index.js @@ -1,4 +1,4 @@ -import { Document, Charset } from "flexsearch/esm"; +import { Document, Charset } from "flexsearch"; import { promises as fs } from "fs"; const dirname = import.meta.dirname; diff --git a/example/nodejs-esm/document-worker-export-import/config.originalTitle.js b/example/nodejs-esm/document-worker-export-import/config.originalTitle.js index e04a664..b2e10c2 100644 --- a/example/nodejs-esm/document-worker-export-import/config.originalTitle.js +++ b/example/nodejs-esm/document-worker-export-import/config.originalTitle.js @@ -1,5 +1,5 @@ -import { Encoder, Charset } from "flexsearch/esm"; -import EnglishPreset from "flexsearch/esm/lang/en"; +import { Encoder, Charset } from "flexsearch"; +import EnglishPreset from "flexsearch/lang/en"; import { promises as fs } from "fs"; (async function(){ diff --git a/example/nodejs-esm/document-worker-export-import/config.primaryTitle.js b/example/nodejs-esm/document-worker-export-import/config.primaryTitle.js index e04a664..b2e10c2 100644 --- a/example/nodejs-esm/document-worker-export-import/config.primaryTitle.js +++ b/example/nodejs-esm/document-worker-export-import/config.primaryTitle.js @@ -1,5 +1,5 @@ -import { Encoder, Charset } from "flexsearch/esm"; -import EnglishPreset from "flexsearch/esm/lang/en"; +import { Encoder, Charset } from "flexsearch"; +import EnglishPreset from "flexsearch/lang/en"; import { promises as fs } from "fs"; (async function(){ diff --git a/example/nodejs-esm/document-worker-export-import/index.js b/example/nodejs-esm/document-worker-export-import/index.js index d553e2e..3892308 100644 --- a/example/nodejs-esm/document-worker-export-import/index.js +++ b/example/nodejs-esm/document-worker-export-import/index.js @@ -1,4 +1,4 @@ -import { Document } from "flexsearch/esm"; +import { Document } from "flexsearch"; import { promises as fs } from "fs"; const dirname = import.meta.dirname; diff --git a/example/nodejs-esm/document-worker-extern-config/config.originalTitle.js b/example/nodejs-esm/document-worker-extern-config/config.originalTitle.js index 566cbd0..e402c53 100644 --- a/example/nodejs-esm/document-worker-extern-config/config.originalTitle.js +++ b/example/nodejs-esm/document-worker-extern-config/config.originalTitle.js @@ -1,5 +1,5 @@ -import { Encoder, Charset } from "flexsearch/esm"; -import EnglishPreset from "flexsearch/esm/lang/en"; +import { Encoder, Charset } from "flexsearch"; +import EnglishPreset from "flexsearch/lang/en"; export default { tokenize: "forward", diff --git a/example/nodejs-esm/document-worker-extern-config/config.primaryTitle.js b/example/nodejs-esm/document-worker-extern-config/config.primaryTitle.js index 566cbd0..e402c53 100644 --- a/example/nodejs-esm/document-worker-extern-config/config.primaryTitle.js +++ b/example/nodejs-esm/document-worker-extern-config/config.primaryTitle.js @@ -1,5 +1,5 @@ -import { Encoder, Charset } from "flexsearch/esm"; -import EnglishPreset from "flexsearch/esm/lang/en"; +import { Encoder, Charset } from "flexsearch"; +import EnglishPreset from "flexsearch/lang/en"; export default { tokenize: "forward", diff --git a/example/nodejs-esm/document-worker-extern-config/index.js b/example/nodejs-esm/document-worker-extern-config/index.js index 430c353..8e54d53 100644 --- a/example/nodejs-esm/document-worker-extern-config/index.js +++ b/example/nodejs-esm/document-worker-extern-config/index.js @@ -1,4 +1,4 @@ -import { Document } from "flexsearch/esm"; +import { Document } from "flexsearch"; import { promises as fs } from "fs"; const dirname = import.meta.dirname; diff --git a/example/nodejs-esm/document-worker/index.js b/example/nodejs-esm/document-worker/index.js index 2d4a6d7..9a2f080 100644 --- a/example/nodejs-esm/document-worker/index.js +++ b/example/nodejs-esm/document-worker/index.js @@ -1,4 +1,4 @@ -import { Document } from "flexsearch/esm"; +import { Document } from "flexsearch"; import { promises as fs } from "fs"; const dirname = import.meta.dirname; diff --git a/example/nodejs-esm/document/index.js b/example/nodejs-esm/document/index.js index 9c53320..fbed4f3 100644 --- a/example/nodejs-esm/document/index.js +++ b/example/nodejs-esm/document/index.js @@ -1,4 +1,4 @@ -import { Document, Charset } from "flexsearch/esm"; +import { Document, Charset } from "flexsearch"; import fs from "fs"; const dirname = import.meta.dirname; diff --git a/example/nodejs-esm/language-pack/index.js b/example/nodejs-esm/language-pack/index.js index b904a73..9e1050f 100644 --- a/example/nodejs-esm/language-pack/index.js +++ b/example/nodejs-esm/language-pack/index.js @@ -1,5 +1,5 @@ -import { Index, Encoder, Charset } from "flexsearch/esm"; -import EnglishPreset from "flexsearch/esm/lang/en"; +import { Index, Encoder, Charset } from "flexsearch"; +import EnglishPreset from "flexsearch/lang/en"; const encoder = new Encoder( Charset.LatinSimple, diff --git a/package-lock.json b/package-lock.json index 38168b0..0117b2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "flexsearch", - "version": "0.8.135", + "version": "0.8.138", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "flexsearch", - "version": "0.8.135", + "version": "0.8.138", "funding": [ { "type": "github", diff --git a/package.json b/package.json index a873bc9..40d304e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "public": true, "preferGlobal": false, "name": "flexsearch", - "version": "0.8.135", + "version": "0.8.138", "description": "Next-Generation full-text search library for Browser and Node.js", "homepage": "https://github.com/nextapps-de/flexsearch/", "author": "Thomas Wilkerling", @@ -48,7 +48,8 @@ "import": "./dist/flexsearch.bundle.module.debug.js", "require": "./dist/flexsearch.bundle.debug.js" }, - "./esm": "./dist/flexsearch.bundle.module.min.js" + "./esm": "./dist/flexsearch.bundle.module.min.js", + "./esm/lang/*": "./dist/module/lang/*.js" }, "browser": { "flexsearch": "./dist/flexsearch.bundle.module.min.js", diff --git a/src/bundle.js b/src/bundle.js index cdd8669..7f72476 100644 --- a/src/bundle.js +++ b/src/bundle.js @@ -321,10 +321,9 @@ if(RELEASE !== "bundle.module" && // Legacy Browser: this refers to window // ESM Browser: self refers to window // NodeJS: global refers to the global scope - const root = typeof global !== "undefined" ? global : - //typeof window !== "undefined" ? window : + const root = typeof self !== "undefined" ? self : + typeof global !== "undefined" ? global : self; - //const root = self; let prop; // AMD (RequireJS) diff --git a/src/document/search.js b/src/document/search.js index 314e440..e834ba2 100644 --- a/src/document/search.js +++ b/src/document/search.js @@ -655,7 +655,7 @@ function get_tag(tag, key, limit, offset, enrich){ export function apply_enrich(ids){ - if(!SUPPORT_PERSISTENT || !this || !this.store) return ids; + if(!this || !this.store) return ids; /** @type {EnrichedSearchResults} */ const result = new Array(ids.length); diff --git a/src/lang/en.js b/src/lang/en.js index 0052366..cc4e102 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -228,7 +228,7 @@ export const stemmer = new Map([ ["fulness", ""], ["ousness", ""], ["ization", ""], - ["tional", ""], + ["tional", "tion"], ["biliti", ""], ["icate", ""], ["ative", ""], @@ -243,8 +243,10 @@ export const stemmer = new Map([ ["ement", ""], ["izer", ""], ["able", ""], + ["ible", ""], ["alli", ""], ["ator", ""], + ["less", ""], ["logi", ""], ["ical", ""], ["ance", ""], @@ -265,11 +267,16 @@ export const stemmer = new Map([ ["ize", ""], ["ing", ""], ["ion", ""], + ["ies", "y"], ["al", ""], ["ou", ""], ["er", ""], + ["ed", ""], + ["es", "e"], ["ic", ""], - ["ly", ""] + ["ly", ""], + ["li", ""], + ["s", ""] ]); /*