mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-10-01 23:56:41 +02:00
result highlighting
This commit is contained in:
448
dist/flexsearch.compact.module.debug.js
vendored
448
dist/flexsearch.compact.module.debug.js
vendored
@@ -5,8 +5,8 @@
|
||||
* Hosted by Nextapps GmbH
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
var v;
|
||||
function y(a, c, b) {
|
||||
var x;
|
||||
function B(a, c, b) {
|
||||
const e = typeof b, d = typeof a;
|
||||
if ("undefined" !== e) {
|
||||
if ("undefined" !== d) {
|
||||
@@ -43,20 +43,20 @@ function y(a, c, b) {
|
||||
}
|
||||
return "undefined" === d ? c : a;
|
||||
}
|
||||
function z() {
|
||||
function C() {
|
||||
return Object.create(null);
|
||||
}
|
||||
function aa(a, c) {
|
||||
return c.length - a.length;
|
||||
}
|
||||
function A(a) {
|
||||
function D(a) {
|
||||
return "string" === typeof a;
|
||||
}
|
||||
function F(a) {
|
||||
function H(a) {
|
||||
return "object" === typeof a;
|
||||
}
|
||||
function G(a, c) {
|
||||
if (A(c)) {
|
||||
function I(a, c) {
|
||||
if (D(c)) {
|
||||
a = a[c];
|
||||
} else {
|
||||
for (let b = 0; a && b < c.length; b++) {
|
||||
@@ -74,16 +74,16 @@ function G(a, c) {
|
||||
"\u03b8"], ["\u03d2", "\u03a5"], ["\u03d3", "\u03a5"], ["\u03d4", "\u03a5"], ["\u03d5", "\u03c6"], ["\u03d6", "\u03c0"], ["\u03f0", "\u03ba"], ["\u03f1", "\u03c1"], ["\u03f2", "\u03c2"], ["\u03f5", "\u03b5"], ["\u0439", "\u0438"], ["\u0450", "\u0435"], ["\u0451", "\u0435"], ["\u0453", "\u0433"], ["\u0457", "\u0456"], ["\u045c", "\u043a"], ["\u045d", "\u0438"], ["\u045e", "\u0443"], ["\u0477", "\u0475"], ["\u04c2", "\u0436"], ["\u04d1", "\u0430"], ["\u04d3", "\u0430"], ["\u04d7", "\u0435"], ["\u04db",
|
||||
"\u04d9"], ["\u04dd", "\u0436"], ["\u04df", "\u0437"], ["\u04e3", "\u0438"], ["\u04e5", "\u0438"], ["\u04e7", "\u043e"], ["\u04eb", "\u04e9"], ["\u04ed", "\u044d"], ["\u04ef", "\u0443"], ["\u04f1", "\u0443"], ["\u04f3", "\u0443"], ["\u04f5", "\u0447"]];
|
||||
const ca = /[^\p{L}\p{N}]+/u, da = /(\d{3})/g, ea = /(\D)(\d{3})/g, fa = /(\d{3})(\D)/g, J = "".normalize && /[\u0300-\u036f]/g;
|
||||
function K(a) {
|
||||
function L(a) {
|
||||
if (!this) {
|
||||
return new K(...arguments);
|
||||
return new L(...arguments);
|
||||
}
|
||||
for (let c = 0; c < arguments.length; c++) {
|
||||
this.assign(arguments[c]);
|
||||
}
|
||||
}
|
||||
K.prototype.assign = function(a) {
|
||||
this.normalize = y(a.normalize, !0, this.normalize);
|
||||
L.prototype.assign = function(a) {
|
||||
this.normalize = B(a.normalize, !0, this.normalize);
|
||||
let c = a.include, b = c || a.exclude || a.split;
|
||||
if ("object" === typeof b) {
|
||||
let e = !c, d = "";
|
||||
@@ -104,25 +104,25 @@ K.prototype.assign = function(a) {
|
||||
this.numeric = e;
|
||||
} else {
|
||||
try {
|
||||
this.split = y(b, ca, this.split);
|
||||
this.split = B(b, ca, this.split);
|
||||
} catch (e) {
|
||||
this.split = /\s+/;
|
||||
}
|
||||
this.numeric = y(this.numeric, !0);
|
||||
this.numeric = B(this.numeric, !0);
|
||||
}
|
||||
this.prepare = y(a.prepare, null, this.prepare);
|
||||
this.finalize = y(a.finalize, null, this.finalize);
|
||||
this.prepare = B(a.prepare, null, this.prepare);
|
||||
this.finalize = B(a.finalize, null, this.finalize);
|
||||
J || (this.mapper = new Map(ba));
|
||||
this.rtl = a.rtl || !1;
|
||||
this.dedupe = y(a.dedupe, !0, this.dedupe);
|
||||
this.filter = y((b = a.filter) && new Set(b), null, this.filter);
|
||||
this.matcher = y((b = a.matcher) && new Map(b), null, this.matcher);
|
||||
this.mapper = y((b = a.mapper) && new Map(b), null, this.mapper);
|
||||
this.stemmer = y((b = a.stemmer) && new Map(b), null, this.stemmer);
|
||||
this.replacer = y(a.replacer, null, this.replacer);
|
||||
this.minlength = y(a.minlength, 1, this.minlength);
|
||||
this.maxlength = y(a.maxlength, 0, this.maxlength);
|
||||
if (this.cache = b = y(a.cache, !0, this.cache)) {
|
||||
this.dedupe = B(a.dedupe, !0, this.dedupe);
|
||||
this.filter = B((b = a.filter) && new Set(b), null, this.filter);
|
||||
this.matcher = B((b = a.matcher) && new Map(b), null, this.matcher);
|
||||
this.mapper = B((b = a.mapper) && new Map(b), null, this.mapper);
|
||||
this.stemmer = B((b = a.stemmer) && new Map(b), null, this.stemmer);
|
||||
this.replacer = B(a.replacer, null, this.replacer);
|
||||
this.minlength = B(a.minlength, 1, this.minlength);
|
||||
this.maxlength = B(a.maxlength, 0, this.maxlength);
|
||||
if (this.cache = b = B(a.cache, !0, this.cache)) {
|
||||
this.J = null, this.O = "number" === typeof b ? b : 2e5, this.F = new Map(), this.H = new Map(), this.D = this.h = 128;
|
||||
}
|
||||
this.K = "";
|
||||
@@ -141,14 +141,14 @@ K.prototype.assign = function(a) {
|
||||
}
|
||||
return this;
|
||||
};
|
||||
K.prototype.encode = function(a) {
|
||||
L.prototype.encode = function(a) {
|
||||
if (this.cache && a.length <= this.h) {
|
||||
if (this.J) {
|
||||
if (this.F.has(a)) {
|
||||
return this.F.get(a);
|
||||
}
|
||||
} else {
|
||||
this.J = setTimeout(L, 50, this);
|
||||
this.J = setTimeout(ha, 50, this);
|
||||
}
|
||||
}
|
||||
this.normalize && (a = "function" === typeof this.normalize ? this.normalize(a) : J ? a.normalize("NFKD").replace(J, "").toLowerCase() : a.toLowerCase());
|
||||
@@ -178,7 +178,7 @@ K.prototype.encode = function(a) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
this.J = setTimeout(L, 50, this);
|
||||
this.J = setTimeout(ha, 50, this);
|
||||
}
|
||||
}
|
||||
let k;
|
||||
@@ -204,12 +204,12 @@ K.prototype.encode = function(a) {
|
||||
this.cache && a.length <= this.h && (this.F.set(a, b), this.F.size > this.O && (this.F.clear(), this.h = this.h / 1.1 | 0));
|
||||
return b;
|
||||
};
|
||||
function L(a) {
|
||||
function ha(a) {
|
||||
a.J = null;
|
||||
a.F.clear();
|
||||
a.H.clear();
|
||||
}
|
||||
;function ha(a) {
|
||||
;function ia(a) {
|
||||
M.call(a, "add");
|
||||
M.call(a, "append");
|
||||
M.call(a, "search");
|
||||
@@ -227,13 +227,13 @@ function M(a) {
|
||||
return c;
|
||||
};
|
||||
}
|
||||
;function ia(a, c, b, e, d, f, g, h) {
|
||||
;function ja(a, c, b, e, d, f, g, h) {
|
||||
(e = a(b ? b + "." + e : e, JSON.stringify(g))) && e.then ? e.then(function() {
|
||||
c.export(a, c, b, d, f + 1, h);
|
||||
}) : c.export(a, c, b, d, f + 1, h);
|
||||
}
|
||||
;N.prototype.add = function(a, c, b) {
|
||||
F(a) && (c = a, a = G(c, this.key));
|
||||
H(a) && (c = a, a = I(c, this.key));
|
||||
if (c && (a || 0 === a)) {
|
||||
if (!b && this.reg.has(a)) {
|
||||
return this.update(a, c);
|
||||
@@ -246,7 +246,7 @@ function M(a) {
|
||||
d && e.add(a, d, !1, !0);
|
||||
} else {
|
||||
if (d = k.G, !d || d(c)) {
|
||||
k.constructor === String ? k = ["" + k] : A(k) && (k = [k]), O(c, k, this.I, 0, e, a, k[0], b);
|
||||
k.constructor === String ? k = ["" + k] : D(k) && (k = [k]), O(c, k, this.I, 0, e, a, k[0], b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,7 +254,7 @@ function M(a) {
|
||||
for (e = 0; e < this.B.length; e++) {
|
||||
var f = this.B[e], g = this.R[e];
|
||||
d = this.tag.get(g);
|
||||
let h = z();
|
||||
let h = C();
|
||||
if ("function" === typeof f) {
|
||||
if (f = f(c), !f) {
|
||||
continue;
|
||||
@@ -265,10 +265,10 @@ function M(a) {
|
||||
continue;
|
||||
}
|
||||
f.constructor === String && (f = "" + f);
|
||||
f = G(c, f);
|
||||
f = I(c, f);
|
||||
}
|
||||
if (d && f) {
|
||||
A(f) && (f = [f]);
|
||||
D(f) && (f = [f]);
|
||||
for (let k = 0, l, m; k < f.length; k++) {
|
||||
l = f[k], h[l] || (h[l] = 1, (g = d.get(l)) ? m = g : d.set(l, m = []), b && m.includes(a) || (m.push(a), this.fastupdate && ((g = this.reg.get(a)) ? g.push(m) : this.reg.set(a, [m]))));
|
||||
}
|
||||
@@ -280,7 +280,7 @@ function M(a) {
|
||||
if (this.store && (!b || !this.store.has(a))) {
|
||||
let h;
|
||||
if (this.A) {
|
||||
h = z();
|
||||
h = C();
|
||||
for (let k = 0, l; k < this.A.length; k++) {
|
||||
l = this.A[k];
|
||||
if ((b = l.G) && !b(c)) {
|
||||
@@ -293,7 +293,7 @@ function M(a) {
|
||||
continue;
|
||||
}
|
||||
l = [l.S];
|
||||
} else if (A(l) || l.constructor === String) {
|
||||
} else if (D(l) || l.constructor === String) {
|
||||
h[l] = c[l];
|
||||
continue;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ function P(a, c, b, e, d, f) {
|
||||
P(a, c, b, e, d);
|
||||
}
|
||||
} else {
|
||||
c = c[d] || (c[d] = z()), d = b[++e], P(a, c, b, e, d);
|
||||
c = c[d] || (c[d] = C()), d = b[++e], P(a, c, b, e, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,8 +343,8 @@ function O(a, c, b, e, d, f, g, h) {
|
||||
}
|
||||
}
|
||||
}
|
||||
;function ja(a, c) {
|
||||
const b = z(), e = [];
|
||||
;function ka(a, c) {
|
||||
const b = C(), e = [];
|
||||
for (let d = 0, f; d < c.length; d++) {
|
||||
f = c[d];
|
||||
for (let g = 0; g < f.length; g++) {
|
||||
@@ -357,16 +357,16 @@ function O(a, c, b, e, d, f, g, h) {
|
||||
return e;
|
||||
}
|
||||
;N.prototype.search = function(a, c, b, e) {
|
||||
b || (!c && F(a) ? (b = a, a = "") : F(c) && (b = c, c = 0));
|
||||
b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0));
|
||||
let d = [];
|
||||
var f = [];
|
||||
let g, h, k, l, m, n, t = 0, p;
|
||||
if (b) {
|
||||
b.constructor === Array && (b = {index:b});
|
||||
a = b.query || a;
|
||||
var q = b.pluck;
|
||||
var r = b.pluck;
|
||||
h = b.merge;
|
||||
l = q || b.field || b.index;
|
||||
l = r || b.field || b.index;
|
||||
m = this.tag && b.tag;
|
||||
g = this.store && b.enrich;
|
||||
k = b.suggest;
|
||||
@@ -377,29 +377,29 @@ function O(a, c, b, e, d, f, g, h) {
|
||||
if (m) {
|
||||
m.constructor !== Array && (m = [m]);
|
||||
var u = [];
|
||||
for (let x = 0, r; x < m.length; x++) {
|
||||
r = m[x];
|
||||
if (A(r)) {
|
||||
for (let w = 0, q; w < m.length; w++) {
|
||||
q = m[w];
|
||||
if (D(q)) {
|
||||
throw Error("A tag option can't be a string, instead it needs a { field: tag } format.");
|
||||
}
|
||||
if (r.field && r.tag) {
|
||||
var w = r.tag;
|
||||
if (w.constructor === Array) {
|
||||
for (var B = 0; B < w.length; B++) {
|
||||
u.push(r.field, w[B]);
|
||||
if (q.field && q.tag) {
|
||||
var v = q.tag;
|
||||
if (v.constructor === Array) {
|
||||
for (var y = 0; y < v.length; y++) {
|
||||
u.push(q.field, v[y]);
|
||||
}
|
||||
} else {
|
||||
u.push(r.field, w);
|
||||
u.push(q.field, v);
|
||||
}
|
||||
} else {
|
||||
w = Object.keys(r);
|
||||
for (let D = 0, E, C; D < w.length; D++) {
|
||||
if (E = w[D], C = r[E], C.constructor === Array) {
|
||||
for (B = 0; B < C.length; B++) {
|
||||
u.push(E, C[B]);
|
||||
v = Object.keys(q);
|
||||
for (let E = 0, A, z; E < v.length; E++) {
|
||||
if (A = v[E], z = q[A], z.constructor === Array) {
|
||||
for (y = 0; y < z.length; y++) {
|
||||
u.push(A, z[y]);
|
||||
}
|
||||
} else {
|
||||
u.push(E, C);
|
||||
u.push(A, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,114 +412,137 @@ function O(a, c, b, e, d, f, g, h) {
|
||||
e = [];
|
||||
if (u.length) {
|
||||
for (f = 0; f < u.length; f += 2) {
|
||||
q = ka.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:q});
|
||||
r = la.call(this, u[f], u[f + 1], c, n, g), d.push({field:u[f], tag:u[f + 1], result:r});
|
||||
}
|
||||
}
|
||||
return e.length ? Promise.all(e).then(function(x) {
|
||||
for (let r = 0; r < x.length; r++) {
|
||||
d[r].result = x[r];
|
||||
return e.length ? Promise.all(e).then(function(w) {
|
||||
for (let q = 0; q < w.length; q++) {
|
||||
d[q].result = w[q];
|
||||
}
|
||||
return d;
|
||||
}) : d;
|
||||
}
|
||||
}
|
||||
A(l) && (l = [l]);
|
||||
D(l) && (l = [l]);
|
||||
}
|
||||
l || (l = this.field);
|
||||
u = !e && (this.worker || this.db) && [];
|
||||
for (let x = 0, r, D, E; x < l.length; x++) {
|
||||
D = l[x];
|
||||
let C;
|
||||
A(D) || (C = D, D = C.field, a = C.query || a, c = C.limit || c, n = C.offset || n, k = C.suggest || k, g = this.store && (C.enrich || g));
|
||||
for (let w = 0, q, E, A; w < l.length; w++) {
|
||||
E = l[w];
|
||||
let z;
|
||||
D(E) || (z = E, E = z.field, a = z.query || a, c = z.limit || c, n = z.offset || n, k = z.suggest || k, g = this.store && (z.enrich || g));
|
||||
if (e) {
|
||||
r = e[x];
|
||||
q = e[w];
|
||||
} else {
|
||||
if (w = C || b, B = this.index.get(D), m && (w.enrich = !1), u) {
|
||||
u[x] = B.search(a, c, w);
|
||||
w && g && (w.enrich = g);
|
||||
if (v = z || b, y = this.index.get(E), m && (v.enrich = !1), u) {
|
||||
u[w] = y.search(a, c, v);
|
||||
v && g && (v.enrich = g);
|
||||
continue;
|
||||
} else {
|
||||
r = B.search(a, c, w), w && g && (w.enrich = g);
|
||||
q = y.search(a, c, v), v && g && (v.enrich = g);
|
||||
}
|
||||
}
|
||||
E = r && r.length;
|
||||
if (m && E) {
|
||||
w = [];
|
||||
B = 0;
|
||||
for (let H = 0, I, va; H < m.length; H += 2) {
|
||||
I = this.tag.get(m[H]);
|
||||
if (!I) {
|
||||
if (console.warn("Tag '" + m[H] + ":" + m[H + 1] + "' will be skipped because there is no field '" + m[H] + "'."), k) {
|
||||
A = q && q.length;
|
||||
if (m && A) {
|
||||
v = [];
|
||||
y = 0;
|
||||
for (let G = 0, F, K; G < m.length; G += 2) {
|
||||
F = this.tag.get(m[G]);
|
||||
if (!F) {
|
||||
if (console.warn("Tag '" + m[G] + ":" + m[G + 1] + "' will be skipped because there is no field '" + m[G] + "'."), k) {
|
||||
continue;
|
||||
} else {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
if (va = (I = I && I.get(m[H + 1])) && I.length) {
|
||||
B++, w.push(I);
|
||||
if (K = (F = F && F.get(m[G + 1])) && F.length) {
|
||||
y++, v.push(F);
|
||||
} else if (!k) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
if (B) {
|
||||
r = ja(r, w);
|
||||
E = r.length;
|
||||
if (!E && !k) {
|
||||
if (y) {
|
||||
q = ka(q, v);
|
||||
A = q.length;
|
||||
if (!A && !k) {
|
||||
return d;
|
||||
}
|
||||
B--;
|
||||
y--;
|
||||
}
|
||||
}
|
||||
if (E) {
|
||||
f[t] = D, d.push(r), t++;
|
||||
if (A) {
|
||||
f[t] = E, d.push(q), t++;
|
||||
} else if (1 === l.length) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
if (u) {
|
||||
const x = this;
|
||||
return Promise.all(u).then(function(r) {
|
||||
return r.length ? x.search(a, c, b, r) : r;
|
||||
const w = this;
|
||||
return Promise.all(u).then(function(q) {
|
||||
return q.length ? w.search(a, c, b, q) : q;
|
||||
});
|
||||
}
|
||||
if (!t) {
|
||||
return d;
|
||||
}
|
||||
if (q && (!g || !this.store)) {
|
||||
if (r && (!g || !this.store)) {
|
||||
return d[0];
|
||||
}
|
||||
u = [];
|
||||
for (let x = 0, r; x < f.length; x++) {
|
||||
r = d[x];
|
||||
g && r.length && !r[0].doc && r.length && (r = la.call(this, r));
|
||||
if (q) {
|
||||
return r;
|
||||
for (let w = 0, q; w < f.length; w++) {
|
||||
q = d[w];
|
||||
g && q.length && !q[0].doc && q.length && (q = ma.call(this, q));
|
||||
if (r) {
|
||||
return q;
|
||||
}
|
||||
d[x] = {field:f[x], result:r};
|
||||
d[w] = {field:f[w], result:q};
|
||||
}
|
||||
return h ? ma(d, c) : p ? na(d, a, this.index, this.C, p) : d;
|
||||
return h ? na(d, c) : p ? oa(d, a, this.index, this.field, this.C, p) : d;
|
||||
};
|
||||
function na(a, c, b, e, d) {
|
||||
let f;
|
||||
for (let g = 0, h, k, l, m; g < a.length; g++) {
|
||||
h = a[g].result;
|
||||
k = a[g].field;
|
||||
l = b.get(k).encoder;
|
||||
m = e[k.indexOf(k)];
|
||||
l !== f && (f = l, f.encode(c));
|
||||
for (let n = 0; n < h.length; n++) {
|
||||
let t = "", p = G(h[n].doc, m), q = f.encode(p);
|
||||
for (let u = 0; u < q.length; u++) {
|
||||
t += q[u].replace(new RegExp("(" + q[u] + ")", "g"), d.replace("$1", p));
|
||||
function oa(a, c, b, e, d, f) {
|
||||
let g, h, k;
|
||||
for (let m = 0, n, t, p, r, u; m < a.length; m++) {
|
||||
n = a[m].result;
|
||||
t = a[m].field;
|
||||
r = b.get(t);
|
||||
p = r.encoder;
|
||||
k = r.tokenize;
|
||||
u = d[e.indexOf(t)];
|
||||
p !== g && (g = p, h = g.encode(c));
|
||||
for (let v = 0; v < n.length; v++) {
|
||||
let y = "";
|
||||
var l = I(n[v].doc, u);
|
||||
let w = g.encode(l);
|
||||
l = l.split(g.split);
|
||||
for (let q = 0, E, A; q < w.length; q++) {
|
||||
E = w[q];
|
||||
A = l[q];
|
||||
let z;
|
||||
for (let G = 0, F; G < h.length; G++) {
|
||||
if (F = h[G], "strict" === k) {
|
||||
if (E === F) {
|
||||
y += (y ? " " : "") + f.replace("$1", A);
|
||||
z = !0;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
const K = E.indexOf(F);
|
||||
if (-1 < K) {
|
||||
y += (y ? " " : "") + A.substring(0, K) + f.replace("$1", A.substring(K, F.length)) + A.substring(K + F.length);
|
||||
z = !0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
z || (y += (y ? " " : "") + l[q]);
|
||||
}
|
||||
console.log(a, b, d);
|
||||
h[n].T = t;
|
||||
n[v].T = y;
|
||||
}
|
||||
}
|
||||
return a;
|
||||
}
|
||||
function ma(a, c) {
|
||||
const b = [], e = z();
|
||||
function na(a, c) {
|
||||
const b = [], e = C();
|
||||
for (let d = 0, f, g; d < a.length; d++) {
|
||||
f = a[d];
|
||||
g = f.result;
|
||||
@@ -537,7 +560,7 @@ function ma(a, c) {
|
||||
}
|
||||
return b;
|
||||
}
|
||||
function ka(a, c, b, e, d) {
|
||||
function la(a, c, b, e, d) {
|
||||
let f = this.tag.get(a);
|
||||
if (!f) {
|
||||
return console.warn("Tag '" + a + "' was not found"), [];
|
||||
@@ -546,11 +569,11 @@ function ka(a, c, b, e, d) {
|
||||
if (a > b || e) {
|
||||
f = f.slice(e, e + b);
|
||||
}
|
||||
d && (f = la.call(this, f));
|
||||
d && (f = ma.call(this, f));
|
||||
return f;
|
||||
}
|
||||
}
|
||||
function la(a) {
|
||||
function ma(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)};
|
||||
@@ -574,13 +597,13 @@ function la(a) {
|
||||
a.cache = !1;
|
||||
b = new Map();
|
||||
let e = c.index || c.field || c;
|
||||
A(e) && (e = [e]);
|
||||
D(e) && (e = [e]);
|
||||
for (let d = 0, f, g; d < e.length; d++) {
|
||||
f = e[d], A(f) || (g = f, f = f.field), g = F(g) ? Object.assign({}, a, g) : a, b.set(f, new S(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Q(f, this.I), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].G = g.filter)), this.field[d] = f;
|
||||
f = e[d], D(f) || (g = f, f = f.field), g = H(g) ? Object.assign({}, a, g) : a, b.set(f, new S(g, this.reg)), g.custom ? this.C[d] = g.custom : (this.C[d] = Q(f, this.I), g.filter && ("string" === typeof this.C[d] && (this.C[d] = new String(this.C[d])), this.C[d].G = g.filter)), this.field[d] = f;
|
||||
}
|
||||
if (this.A) {
|
||||
a = c.store;
|
||||
A(a) && (a = [a]);
|
||||
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.S = g) : (this.A[d] = Q(g, this.I), f.filter && ("string" === typeof this.A[d] && (this.A[d] = new String(this.A[d])), this.A[d].G = f.filter));
|
||||
}
|
||||
@@ -614,15 +637,15 @@ function Q(a, c) {
|
||||
e < b.length && (b.length = e);
|
||||
return 1 < e ? b : b[0];
|
||||
}
|
||||
v = N.prototype;
|
||||
v.append = function(a, c) {
|
||||
x = N.prototype;
|
||||
x.append = function(a, c) {
|
||||
return this.add(a, c, !0);
|
||||
};
|
||||
v.update = function(a, c) {
|
||||
x.update = function(a, c) {
|
||||
return this.remove(a).add(a, c);
|
||||
};
|
||||
v.remove = function(a) {
|
||||
F(a) && (a = G(a, this.key));
|
||||
x.remove = function(a) {
|
||||
H(a) && (a = I(a, this.key));
|
||||
for (var c of this.index.values()) {
|
||||
c.remove(a, !0);
|
||||
}
|
||||
@@ -642,7 +665,7 @@ v.remove = function(a) {
|
||||
this.cache && this.cache.remove(a);
|
||||
return this;
|
||||
};
|
||||
v.clear = function() {
|
||||
x.clear = function() {
|
||||
for (const a of this.index.values()) {
|
||||
a.clear();
|
||||
}
|
||||
@@ -654,24 +677,24 @@ v.clear = function() {
|
||||
this.store && this.store.clear();
|
||||
return this;
|
||||
};
|
||||
v.contain = function(a) {
|
||||
x.contain = function(a) {
|
||||
return this.reg.has(a);
|
||||
};
|
||||
v.cleanup = function() {
|
||||
x.cleanup = function() {
|
||||
for (const a of this.index.values()) {
|
||||
a.cleanup();
|
||||
}
|
||||
return this;
|
||||
};
|
||||
v.get = function(a) {
|
||||
x.get = function(a) {
|
||||
return this.store.get(a);
|
||||
};
|
||||
v.set = function(a, c) {
|
||||
x.set = function(a, c) {
|
||||
this.store.set(a, c);
|
||||
return this;
|
||||
};
|
||||
v.searchCache = oa;
|
||||
v.export = function(a, c, b, e, d, f) {
|
||||
x.searchCache = pa;
|
||||
x.export = function(a, c, b, e, d, f) {
|
||||
let g;
|
||||
"undefined" === typeof f && (g = new Promise(k => {
|
||||
f = k;
|
||||
@@ -699,13 +722,13 @@ v.export = function(a, c, b, e, d, f) {
|
||||
f();
|
||||
return;
|
||||
}
|
||||
ia(a, this, b, c, e, d, h, f);
|
||||
ja(a, this, b, c, e, d, h, f);
|
||||
}
|
||||
return g;
|
||||
};
|
||||
v.import = function(a, c) {
|
||||
x.import = function(a, c) {
|
||||
if (c) {
|
||||
switch(A(c) && (c = JSON.parse(c)), a) {
|
||||
switch(D(c) && (c = JSON.parse(c)), a) {
|
||||
case "tag":
|
||||
this.D = c;
|
||||
break;
|
||||
@@ -727,8 +750,8 @@ v.import = function(a, c) {
|
||||
}
|
||||
}
|
||||
};
|
||||
ha(N.prototype);
|
||||
function oa(a, c, b) {
|
||||
ia(N.prototype);
|
||||
function pa(a, c, b) {
|
||||
a = ("object" === typeof a ? "" + a.query : a).toLowerCase();
|
||||
let e = this.cache.get(a);
|
||||
if (!e) {
|
||||
@@ -768,32 +791,32 @@ R.prototype.clear = function() {
|
||||
this.cache.clear();
|
||||
this.h = "";
|
||||
};
|
||||
const pa = {normalize:function(a) {
|
||||
const qa = {normalize:function(a) {
|
||||
return a.toLowerCase();
|
||||
}, dedupe:!1};
|
||||
const T = 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 qa = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), ra = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"];
|
||||
const sa = {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 ta = /[\x00-\x7F]+/g;
|
||||
const ra = new Map([["ae", "a"], ["oe", "o"], ["sh", "s"], ["kh", "k"], ["th", "t"], ["pf", "f"]]), sa = [/([^aeo])h(.)/g, "$1$2", /([aeo])h([^aeo]|$)/g, "$1$2", /([^0-9])\1+/g, "$1"];
|
||||
const ta = {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 ua = /[\x00-\x7F]+/g;
|
||||
const va = /[\x00-\x7F]+/g;
|
||||
const wa = /[\x00-\x7F]+/g;
|
||||
var xa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:pa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:T}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:T, matcher:qa, replacer:ra}, LatinExtra:{normalize:!0, dedupe:!0, mapper:T, replacer:ra.concat([/(?!^)[aeo]/g, ""]), matcher:qa}, LatinSoundex:{normalize:!0, dedupe:!1, include:{letter:!0}, finalize:function(a) {
|
||||
var xa = {LatinExact:{normalize:!1, dedupe:!1}, LatinDefault:qa, LatinSimple:{normalize:!0, dedupe:!0}, LatinBalance:{normalize:!0, dedupe:!0, mapper:T}, LatinAdvanced:{normalize:!0, dedupe:!0, mapper:T, matcher:ra, replacer:sa}, LatinExtra:{normalize:!0, dedupe:!0, mapper:T, replacer:sa.concat([/(?!^)[aeo]/g, ""]), matcher:ra}, 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 = sa[e];
|
||||
for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = sa[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) {
|
||||
let e = c.charAt(0), d = ta[e];
|
||||
for (let f = 1, g; f < c.length && (g = c.charAt(f), "h" === g || "w" === g || !(g = ta[g]) || g === d || (e += g, d = g, 4 !== e.length)); f++) {
|
||||
}
|
||||
a[b] = e;
|
||||
}
|
||||
}}, ArabicDefault:{rtl:!0, normalize:!1, dedupe:!0, prepare:function(a) {
|
||||
return ("" + a).replace(ta, " ");
|
||||
return ("" + a).replace(ua, " ");
|
||||
}}, CjkDefault:{normalize:!1, dedupe:!0, split:"", prepare:function(a) {
|
||||
return ("" + a).replace(ua, "");
|
||||
return ("" + a).replace(va, "");
|
||||
}}, CyrillicDefault:{normalize:!1, dedupe:!0, prepare:function(a) {
|
||||
return ("" + a).replace(wa, " ");
|
||||
}}};
|
||||
const ya = {memory:{resolution:1}, performance:{resolution:6, fastupdate:!0, context:{depth:1, resolution:3}}, match:{tokenize:"forward"}, score:{resolution:9, context:{depth:2, resolution:9}}};
|
||||
z();
|
||||
C();
|
||||
S.prototype.add = function(a, c, b, e) {
|
||||
if (c && (a || 0 === a)) {
|
||||
if (!e && !b && this.reg.has(a)) {
|
||||
@@ -801,19 +824,19 @@ S.prototype.add = function(a, c, b, e) {
|
||||
}
|
||||
c = this.encoder.encode(c);
|
||||
if (e = c.length) {
|
||||
const l = z(), m = z(), n = this.depth, t = this.resolution;
|
||||
const l = C(), m = C(), n = this.depth, t = this.resolution;
|
||||
for (let p = 0; p < e; p++) {
|
||||
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) : U(t, e, p), g = "";
|
||||
let r = c[this.rtl ? e - 1 - p : p];
|
||||
var d = r.length;
|
||||
if (d && (n || !m[r])) {
|
||||
var f = this.score ? this.score(c, r, p, null, 0) : U(t, e, p), g = "";
|
||||
switch(this.tokenize) {
|
||||
case "full":
|
||||
if (2 < d) {
|
||||
for (f = 0; f < d; f++) {
|
||||
for (var h = d; h > f; h--) {
|
||||
g = q.substring(f, h);
|
||||
var k = this.score ? this.score(c, q, p, g, f) : U(t, e, p, d, f);
|
||||
g = r.substring(f, h);
|
||||
var k = this.score ? this.score(c, r, p, g, f) : U(t, e, p, d, f);
|
||||
V(this, m, g, k, a, b);
|
||||
}
|
||||
}
|
||||
@@ -822,24 +845,24 @@ S.prototype.add = function(a, c, b, e) {
|
||||
case "reverse":
|
||||
if (1 < d) {
|
||||
for (h = d - 1; 0 < h; h--) {
|
||||
g = q[h] + g, k = this.score ? this.score(c, q, p, g, h) : U(t, e, p, d, h), V(this, m, g, k, a, b);
|
||||
g = r[h] + g, k = this.score ? this.score(c, r, p, g, h) : U(t, e, p, d, h), V(this, m, g, k, a, b);
|
||||
}
|
||||
g = "";
|
||||
}
|
||||
case "forward":
|
||||
if (1 < d) {
|
||||
for (h = 0; h < d; h++) {
|
||||
g += q[h], V(this, m, g, f, a, b);
|
||||
g += r[h], V(this, m, g, f, a, b);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (V(this, m, q, f, a, b), n && 1 < e && p < e - 1) {
|
||||
for (d = z(), g = this.P, f = q, h = Math.min(n + 1, e - p), d[f] = 1, k = 1; k < h; k++) {
|
||||
if ((q = c[this.rtl ? e - 1 - p - k : p + k]) && !d[q]) {
|
||||
d[q] = 1;
|
||||
const u = this.score ? this.score(c, f, p, q, k) : U(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), w = this.bidirectional && q > f;
|
||||
V(this, l, w ? f : q, u, a, b, w ? q : f);
|
||||
if (V(this, m, r, f, a, b), n && 1 < e && p < e - 1) {
|
||||
for (d = C(), g = this.P, f = r, h = Math.min(n + 1, e - p), d[f] = 1, k = 1; k < h; k++) {
|
||||
if ((r = c[this.rtl ? e - 1 - p - k : p + k]) && !d[r]) {
|
||||
d[r] = 1;
|
||||
const u = this.score ? this.score(c, f, p, r, k) : U(g + (e / 2 > g ? 0 : 1), e, p, h - 1, k - 1), v = this.bidirectional && r > f;
|
||||
V(this, l, v ? f : r, u, a, b, v ? r : f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -854,7 +877,7 @@ S.prototype.add = function(a, c, b, e) {
|
||||
function V(a, c, b, e, d, f, g) {
|
||||
let h = g ? a.ctx : a.map, k;
|
||||
if (!c[b] || g && !(k = c[b])[g]) {
|
||||
g ? (c = k || (c[b] = z()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h])));
|
||||
g ? (c = k || (c[b] = C()), c[g] = 1, (k = h.get(g)) ? h = k : h.set(g, h = new Map())) : c[b] = 1, (k = h.get(b)) ? h = k : h.set(b, h = []), h = h[e] || (h[e] = []), f && h.includes(d) || (h.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(h) : a.reg.set(d, [h])));
|
||||
}
|
||||
}
|
||||
function U(a, c, b, e, d) {
|
||||
@@ -891,7 +914,7 @@ function U(a, c, b, e, d) {
|
||||
return e.length ? e = 1 < e.length ? [].concat.apply([], e) : e[0] : e;
|
||||
}
|
||||
;S.prototype.search = function(a, c, b) {
|
||||
b || (!c && F(a) ? (b = a, a = "") : F(c) && (b = c, c = 0));
|
||||
b || (!c && H(a) ? (b = a, a = "") : H(c) && (b = c, c = 0));
|
||||
var e = [], d = 0;
|
||||
if (b) {
|
||||
a = b.query || a;
|
||||
@@ -912,7 +935,7 @@ function U(a, c, b, e, d) {
|
||||
}
|
||||
var h = 0, k = 0;
|
||||
if (1 < b) {
|
||||
var l = z();
|
||||
var l = C();
|
||||
const n = [];
|
||||
for (let t = 0, p; t < b; t++) {
|
||||
if ((p = a[t]) && !l[p]) {
|
||||
@@ -921,9 +944,9 @@ function U(a, c, b, e, d) {
|
||||
} else {
|
||||
return e;
|
||||
}
|
||||
const q = p.length;
|
||||
h = Math.max(h, q);
|
||||
k = k ? Math.min(k, q) : q;
|
||||
const r = p.length;
|
||||
h = Math.max(h, r);
|
||||
k = k ? Math.min(k, r) : r;
|
||||
}
|
||||
}
|
||||
a = n;
|
||||
@@ -971,60 +994,55 @@ function U(a, c, b, e, d) {
|
||||
a: {
|
||||
a = e;
|
||||
e = this.resolution;
|
||||
m = a.length;
|
||||
b = [];
|
||||
f = z();
|
||||
for (let n = 0, t, p, q, u; n < e; n++) {
|
||||
for (k = 0; k < m; k++) {
|
||||
if (q = a[k], n < q.length && (t = q[n])) {
|
||||
m = g;
|
||||
b = a.length;
|
||||
g = [];
|
||||
f = C();
|
||||
for (let n = 0, t, p, r, u; n < e; n++) {
|
||||
for (k = 0; k < b; k++) {
|
||||
if (r = a[k], n < r.length && (t = r[n])) {
|
||||
for (l = 0; l < t.length; l++) {
|
||||
p = t[l], (h = f[p]) ? f[p]++ : (h = 0, f[p] = 1), u = b[h] || (b[h] = []), u.push(p);
|
||||
p = t[l], (h = f[p]) ? f[p]++ : (h = 0, f[p] = 1), u = g[h] || (g[h] = []), u.push(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (a = b.length) {
|
||||
if (g) {
|
||||
if (1 < b.length) {
|
||||
if (a = g.length) {
|
||||
if (m) {
|
||||
if (1 < g.length) {
|
||||
b: {
|
||||
g = b;
|
||||
a = [];
|
||||
e = z();
|
||||
m = g.length;
|
||||
for (h = m - 1; 0 <= h; h--) {
|
||||
for (a = [], e = C(), m = g.length, h = m - 1; 0 <= h; h--) {
|
||||
for (m = g[h], f = m.length, k = 0; k < f; k++) {
|
||||
if (b = m[k], !e[b]) {
|
||||
if (e[b] = 1, d) {
|
||||
d--;
|
||||
} else {
|
||||
if (a.push(b), a.length === c) {
|
||||
c = a;
|
||||
break b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
c = a;
|
||||
}
|
||||
} else {
|
||||
c = b[0];
|
||||
a = (g = g[0]).length > c || d ? g.slice(d, c + d) : g;
|
||||
}
|
||||
b = c;
|
||||
g = a;
|
||||
} else {
|
||||
if (a < m) {
|
||||
if (a < b) {
|
||||
e = [];
|
||||
break a;
|
||||
}
|
||||
b = b[a - 1];
|
||||
g = g[a - 1];
|
||||
if (c || d) {
|
||||
if (b.length > c || d) {
|
||||
b = b.slice(d, c + d);
|
||||
if (g.length > c || d) {
|
||||
g = g.slice(d, c + d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
e = b;
|
||||
e = g;
|
||||
}
|
||||
return e;
|
||||
};
|
||||
@@ -1099,14 +1117,14 @@ function Y(a, c) {
|
||||
return new S(a);
|
||||
}
|
||||
if (a) {
|
||||
var b = A(a) ? a : a.preset;
|
||||
var b = D(a) ? a : a.preset;
|
||||
b && (ya[b] || console.warn("Preset not found: " + b), a = Object.assign({}, ya[b], a));
|
||||
} else {
|
||||
a = {};
|
||||
}
|
||||
b = a.context || {};
|
||||
const e = A(a.encoder) ? xa[a.encoder] : a.encode || a.encoder || pa;
|
||||
this.encoder = e.encode ? e : "object" === typeof e ? new K(e) : {encode:e};
|
||||
const e = D(a.encoder) ? xa[a.encoder] : a.encode || a.encoder || qa;
|
||||
this.encoder = e.encode ? e : "object" === typeof e ? new L(e) : {encode:e};
|
||||
let d;
|
||||
this.resolution = a.resolution || 9;
|
||||
this.tokenize = d = a.tokenize || "strict";
|
||||
@@ -1122,21 +1140,21 @@ function Y(a, c) {
|
||||
this.rtl = e.rtl || a.rtl || !1;
|
||||
this.cache = (d = a.cache || null) && new R(d);
|
||||
}
|
||||
v = S.prototype;
|
||||
v.clear = function() {
|
||||
x = S.prototype;
|
||||
x.clear = function() {
|
||||
this.map.clear();
|
||||
this.ctx.clear();
|
||||
this.reg.clear();
|
||||
this.cache && this.cache.clear();
|
||||
return this;
|
||||
};
|
||||
v.append = function(a, c) {
|
||||
x.append = function(a, c) {
|
||||
return this.add(a, c, !0);
|
||||
};
|
||||
v.contain = function(a) {
|
||||
x.contain = function(a) {
|
||||
return this.reg.has(a);
|
||||
};
|
||||
v.update = function(a, c) {
|
||||
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);
|
||||
};
|
||||
@@ -1154,7 +1172,7 @@ function Z(a) {
|
||||
}
|
||||
return c;
|
||||
}
|
||||
v.cleanup = function() {
|
||||
x.cleanup = function() {
|
||||
if (!this.fastupdate) {
|
||||
return console.info('Cleanup the index isn\'t required when not using "fastupdate".'), this;
|
||||
}
|
||||
@@ -1162,8 +1180,8 @@ v.cleanup = function() {
|
||||
this.depth && Z(this.ctx);
|
||||
return this;
|
||||
};
|
||||
v.searchCache = oa;
|
||||
v.export = function(a, c, b, e, d, f) {
|
||||
x.searchCache = pa;
|
||||
x.export = function(a, c, b, e, d, f) {
|
||||
let g = !0;
|
||||
"undefined" === typeof f && (g = new Promise(l => {
|
||||
f = l;
|
||||
@@ -1173,7 +1191,7 @@ v.export = function(a, c, b, e, d, f) {
|
||||
case 0:
|
||||
h = "reg";
|
||||
if (this.fastupdate) {
|
||||
k = z();
|
||||
k = C();
|
||||
for (let l of this.reg.keys()) {
|
||||
k[l] = 1;
|
||||
}
|
||||
@@ -1197,12 +1215,12 @@ v.export = function(a, c, b, e, d, f) {
|
||||
"undefined" === typeof b && f && f();
|
||||
return;
|
||||
}
|
||||
ia(a, c || this, b, h, e, d, k, f);
|
||||
ja(a, c || this, b, h, e, d, k, f);
|
||||
return g;
|
||||
};
|
||||
v.import = function(a, c) {
|
||||
x.import = function(a, c) {
|
||||
if (c) {
|
||||
switch(A(c) && (c = JSON.parse(c)), a) {
|
||||
switch(D(c) && (c = JSON.parse(c)), a) {
|
||||
case "cfg":
|
||||
this.h = !!c.opt;
|
||||
break;
|
||||
@@ -1218,7 +1236,7 @@ v.import = function(a, c) {
|
||||
}
|
||||
}
|
||||
};
|
||||
v.serialize = function(a = !0) {
|
||||
x.serialize = function(a = !0) {
|
||||
if (!this.reg.size) {
|
||||
return "";
|
||||
}
|
||||
@@ -1254,8 +1272,8 @@ v.serialize = function(a = !0) {
|
||||
for (let t = 0, p; t < h.length; t++) {
|
||||
p = h[t] || [""];
|
||||
l = "";
|
||||
for (let q = 0; q < p.length; q++) {
|
||||
l += (l ? "," : "") + ("string" === b ? '"' + p[q] + '"' : p[q]);
|
||||
for (let r = 0; r < p.length; r++) {
|
||||
l += (l ? "," : "") + ("string" === b ? '"' + p[r] + '"' : p[r]);
|
||||
}
|
||||
l = "[" + l + "]";
|
||||
k += (k ? "," : "") + l;
|
||||
@@ -1268,7 +1286,7 @@ v.serialize = function(a = !0) {
|
||||
d = "index.ctx=new Map([" + d + "]);";
|
||||
return a ? "function inject(index){" + c + e + d + "}" : c + e + d;
|
||||
};
|
||||
ha(S.prototype);
|
||||
export default {Index:S, Charset:xa, Encoder:K, Document:N, Worker:null, Resolver:null, IndexedDB:null, Language:{}};
|
||||
ia(S.prototype);
|
||||
export default {Index:S, Charset:xa, Encoder:L, Document:N, Worker:null, Resolver:null, IndexedDB:null, Language:{}};
|
||||
|
||||
export const Index=S;export const Charset=xa;export const Encoder=K;export const Document=N;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={};
|
||||
export const Index=S;export const Charset=xa;export const Encoder=L;export const Document=N;export const Worker=null;export const Resolver=null;export const IndexedDB=null;export const Language={};
|
Reference in New Issue
Block a user