1
0
mirror of https://github.com/nextapps-de/flexsearch.git synced 2025-10-04 17:11:33 +02:00
This commit is contained in:
Thomas Wilkerling
2025-05-21 10:57:43 +02:00
parent e9c26f06b4
commit 103f617ad5
174 changed files with 16528 additions and 14980 deletions

View File

@@ -1,5 +1,5 @@
/**!
* FlexSearch.js v0.8.167 (Bundle/Debug)
* FlexSearch.js v0.8.200 (Bundle/Debug)
* Author and Copyright: Thomas Wilkerling
* Licence: Apache-2.0
* Hosted by Nextapps GmbH
@@ -22,16 +22,16 @@ function u(a, c, b) {
return b.concat(a);
}
if (c === Map) {
var g = new Map(b);
var h = new Map(b);
for (var e of a) {
g.set(e[0], e[1]);
h.set(e[0], e[1]);
}
return g;
return h;
}
if (c === Set) {
e = new Set(b);
for (g of a.values()) {
e.add(g);
for (h of a.values()) {
e.add(h);
}
return e;
}
@@ -78,7 +78,7 @@ r.assign = function(a) {
}
try {
this.split = new RegExp("[" + (c ? "^" : "") + d + "]+", "u");
} catch (g) {
} catch (h) {
console.error("Your split configuration:", b, "is not supported on this platform. It falls back to using simple whitespace splitter instead: /s+/."), this.split = /\s+/;
}
} else {
@@ -186,27 +186,27 @@ r.encode = function(a, c) {
this.prepare && (a = this.prepare(a));
this.numeric && 3 < a.length && (a = a.replace(C, "$1 $2").replace(D, "$1 $2").replace(B, "$1 "));
const b = !(this.dedupe || this.mapper || this.filter || this.matcher || this.stemmer || this.replacer);
let f = [], d = x(), g, e, k = this.split || "" === this.split ? a.split(this.split) : [a];
for (let n = 0, h, w; n < k.length; n++) {
if ((h = w = k[n]) && !(h.length < this.minlength || h.length > this.maxlength)) {
let f = [], d = x(), h, e, k = this.split || "" === this.split ? a.split(this.split) : [a];
for (let n = 0, g, w; n < k.length; n++) {
if ((g = w = k[n]) && !(g.length < this.minlength || g.length > this.maxlength)) {
if (c) {
if (d[h]) {
if (d[g]) {
continue;
}
d[h] = 1;
d[g] = 1;
} else {
if (g === h) {
if (h === g) {
continue;
}
g = h;
h = g;
}
if (b) {
f.push(h);
f.push(g);
} else {
if (!this.filter || ("function" === typeof this.filter ? this.filter(h) : !this.filter.has(h))) {
if (this.cache && h.length <= this.o) {
if (!this.filter || ("function" === typeof this.filter ? this.filter(g) : !this.filter.has(g))) {
if (this.cache && g.length <= this.o) {
if (this.l) {
var l = this.j.get(h);
var l = this.j.get(g);
if (l || "" === l) {
l && f.push(l);
continue;
@@ -218,39 +218,39 @@ r.encode = function(a, c) {
if (this.stemmer) {
this.u || (this.u = new RegExp("(?!^)(" + this.h + ")$"));
let v;
for (; v !== h && 2 < h.length;) {
v = h, h = h.replace(this.u, p => this.stemmer.get(p));
for (; v !== g && 2 < g.length;) {
v = g, g = g.replace(this.u, p => this.stemmer.get(p));
}
}
if (h && (this.mapper || this.dedupe && 1 < h.length)) {
if (g && (this.mapper || this.dedupe && 1 < g.length)) {
l = "";
for (let v = 0, p = "", m, q; v < h.length; v++) {
m = h.charAt(v), m === p && this.dedupe || ((q = this.mapper && this.mapper.get(m)) || "" === q ? q === p && this.dedupe || !(p = q) || (l += q) : l += p = m);
for (let v = 0, p = "", m, q; v < g.length; v++) {
m = g.charAt(v), m === p && this.dedupe || ((q = this.mapper && this.mapper.get(m)) || "" === q ? q === p && this.dedupe || !(p = q) || (l += q) : l += p = m);
}
h = l;
g = l;
}
this.matcher && 1 < h.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), h = h.replace(this.s, v => this.matcher.get(v)));
if (h && this.replacer) {
for (l = 0; h && l < this.replacer.length; l += 2) {
h = h.replace(this.replacer[l], this.replacer[l + 1]);
this.matcher && 1 < g.length && (this.s || (this.s = new RegExp("(" + this.g + ")", "g")), g = g.replace(this.s, v => this.matcher.get(v)));
if (g && this.replacer) {
for (l = 0; g && l < this.replacer.length; l += 2) {
g = g.replace(this.replacer[l], this.replacer[l + 1]);
}
}
this.cache && w.length <= this.o && (this.j.set(w, h), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0));
if (h) {
if (h !== w) {
this.cache && w.length <= this.o && (this.j.set(w, g), this.j.size > this.A && (this.j.clear(), this.o = this.o / 1.1 | 0));
if (g) {
if (g !== w) {
if (c) {
if (d[h]) {
if (d[g]) {
continue;
}
d[h] = 1;
d[g] = 1;
} else {
if (e === h) {
if (e === g) {
continue;
}
e = h;
e = g;
}
}
f.push(h);
f.push(g);
}
}
}
@@ -270,23 +270,25 @@ function G(a) {
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 ? a.slice(b, b + c) : a;
}
let f = [];
for (let d = 0, g, e; d < a.length; d++) {
if ((g = a[d]) && (e = g.length)) {
for (let d = 0, h, e; d < a.length; d++) {
if ((h = a[d]) && (e = h.length)) {
if (b) {
if (b >= e) {
b -= e;
continue;
}
b < e && (g = c ? g.slice(b, b + c) : g.slice(b), e = g.length, b = 0);
h = h.slice(b, b + c);
e = h.length;
b = 0;
}
e > c && (g = g.slice(0, c), e = c);
e > c && (h = h.slice(0, c), e = c);
if (!f.length && e >= c) {
return g;
return h;
}
f.push(g);
f.push(h);
c -= e;
if (!c) {
break;
@@ -300,9 +302,9 @@ I.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 f = 0, d, g; f < b.length; f++) {
if ((d = b[f]) && (g = d.length)) {
if (d[g - 1] === a) {
for (let f = 0, d, h; f < b.length; f++) {
if ((d = b[f]) && (h = d.length)) {
if (d[h - 1] === a) {
d.pop();
} else {
const e = d.indexOf(a);
@@ -321,22 +323,26 @@ function J(a, c) {
let b = 0;
var f = "undefined" === typeof c;
if (a.constructor === Array) {
for (let d = 0, g, e; d < a.length; d++) {
if ((g = a[d]) && g.length) {
for (let d = 0, h, e, k; d < a.length; d++) {
if ((h = a[d]) && h.length) {
if (f) {
b++;
} else {
if (e = g.indexOf(c), 0 <= e) {
if (1 < g.length) {
g.splice(e, 1);
b++;
break;
} else {
delete a[d];
}
} else {
b++;
return 1;
}
e = h.indexOf(c);
if (0 <= e) {
if (1 < h.length) {
return h.splice(e, 1), 1;
}
delete a[d];
if (b) {
return 1;
}
k = 1;
} else {
if (k) {
return 1;
}
b++;
}
}
}
@@ -357,18 +363,18 @@ I.prototype.add = function(a, c, b, f) {
c = this.encoder.encode(c, !f);
const n = c.length;
if (n) {
const h = x(), w = x(), v = this.resolution;
const g = x(), w = x(), v = this.resolution;
for (let p = 0; p < n; p++) {
let m = c[this.rtl ? n - 1 - p : p];
var d = m.length;
if (d && (f || !w[m])) {
var g = this.score ? this.score(c, m, p, null, 0) : L(v, n, p), e = "";
var h = this.score ? this.score(c, m, p, null, 0) : L(v, n, p), e = "";
switch(this.tokenize) {
case "full":
if (2 < d) {
for (let q = 0, t; q < d; q++) {
for (g = d; g > q; g--) {
e = m.substring(q, g);
for (h = d; h > q; h--) {
e = m.substring(q, h);
t = this.rtl ? d - 1 - q : q;
var k = this.score ? this.score(c, m, p, e, t) : L(v, n, p, d, t);
M(this, w, e, k, a, b);
@@ -389,17 +395,17 @@ I.prototype.add = function(a, c, b, f) {
case "forward":
if (1 < d) {
for (k = 0; k < d; k++) {
e += m[this.rtl ? d - 1 - k : k], M(this, w, e, g, a, b);
e += m[this.rtl ? d - 1 - k : k], M(this, w, e, h, a, b);
}
break;
}
default:
if (M(this, w, m, g, a, b), f && 1 < n && p < n - 1) {
for (d = x(), e = this.v, g = m, k = Math.min(f + 1, this.rtl ? p + 1 : n - p), d[g] = 1, l = 1; l < k; l++) {
if (M(this, w, m, h, a, b), f && 1 < n && p < n - 1) {
for (d = x(), e = this.v, h = m, k = Math.min(f + 1, this.rtl ? p + 1 : n - p), d[h] = 1, l = 1; l < k; l++) {
if ((m = c[this.rtl ? n - 1 - p - l : p + l]) && !d[m]) {
d[m] = 1;
const q = this.score ? this.score(c, g, p, m, l - 1) : L(e + (n / 2 > e ? 0 : 1), n, p, k - 1, l - 1), t = this.bidirectional && m > g;
M(this, h, t ? g : m, q, a, b, t ? m : g);
const q = this.score ? this.score(c, h, p, m, l - 1) : L(e + (n / 2 > e ? 0 : 1), n, p, k - 1, l - 1), t = this.bidirectional && m > h;
M(this, g, t ? h : m, q, a, b, t ? m : h);
}
}
}
@@ -411,10 +417,10 @@ I.prototype.add = function(a, c, b, f) {
}
return this;
};
function M(a, c, b, f, d, g, e) {
function M(a, c, b, f, d, h, e) {
let k = e ? a.ctx : a.map, l;
if (!c[b] || e && !(l = c[b])[e]) {
e ? (c = l || (c[b] = x()), c[e] = 1, (l = k.get(e)) ? k = l : k.set(e, k = new Map())) : c[b] = 1, (l = k.get(b)) ? k = l : k.set(b, k = []), k = k[f] || (k[f] = []), g && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k])));
e ? (c = l || (c[b] = x()), c[e] = 1, (l = k.get(e)) ? k = l : k.set(e, k = new Map())) : c[b] = 1, (l = k.get(b)) ? k = l : k.set(b, k = []), k = k[f] || (k[f] = []), h && k.includes(d) || (k.push(d), a.fastupdate && ((c = a.reg.get(d)) ? c.push(k) : a.reg.set(d, [k])));
}
}
function L(a, c, b, f, d) {
@@ -427,45 +433,45 @@ function L(a, c, b, f, d) {
a = b.query || a;
c = b.limit || c;
d = b.offset || 0;
var g = b.context;
var h = b.context;
var e = b.suggest;
var k = !0;
var l = b.resolution;
}
"undefined" === typeof k && (k = !0);
g = this.depth && !1 !== g;
a = this.encoder.encode(a, !g);
h = this.depth && !1 !== h;
a = this.encoder.encode(a, !h);
b = a.length;
c = c || (k ? 100 : 0);
if (1 === b) {
return e = d, (d = N(this, a[0], "")) && d.length ? H.call(this, d, c, e) : [];
}
if (2 === b && g && !e) {
if (2 === b && h && !e) {
return e = d, (d = N(this, a[1], a[0])) && d.length ? H.call(this, d, c, e) : [];
}
k = x();
var n = 0;
if (g) {
var h = a[0];
if (h) {
var g = a[0];
n = 1;
}
l || 0 === l || (l = h ? this.v : this.resolution);
l || 0 === l || (l = g ? this.v : this.resolution);
for (let m, q; n < b; n++) {
if ((q = a[n]) && !k[q]) {
k[q] = 1;
m = N(this, q, h);
m = N(this, q, g);
a: {
g = m;
h = m;
var w = f, v = e, p = l;
let t = [];
if (g && g.length) {
if (g.length <= p) {
w.push(g);
if (h && h.length) {
if (h.length <= p) {
w.push(h);
m = void 0;
break a;
}
for (let y = 0, z; y < p; y++) {
if (z = g[y]) {
if (z = h[y]) {
t[y] = z;
}
}
@@ -481,26 +487,26 @@ function L(a, c, b, f, d) {
f = m;
break;
}
h && (e && m && f.length || (h = q));
g && (e && m && f.length || (g = q));
}
e && h && n === b - 1 && !f.length && (l = this.resolution, h = "", n = -1, k = x());
e && g && n === b - 1 && !f.length && (l = this.resolution, g = "", n = -1, k = x());
}
a: {
a = f;
f = a.length;
h = a;
g = a;
if (1 < f) {
b: {
f = e;
h = a.length;
g = a.length;
e = [];
b = x();
for (let m = 0, q, t, y, z; m < l; m++) {
for (n = 0; n < h; n++) {
for (n = 0; n < g; n++) {
if (y = a[n], m < y.length && (q = y[m])) {
for (g = 0; g < q.length; g++) {
if (t = q[g], (k = b[t]) ? b[t]++ : (k = 0, b[t] = 1), z = e[k] || (e[k] = []), z.push(t), c && k === h - 1 && z.length - d === c) {
h = d ? z.slice(d) : z;
for (h = 0; h < q.length; h++) {
if (t = q[h], (k = b[t]) ? b[t]++ : (k = 0, b[t] = 1), z = e[k] || (e[k] = []), z.push(t), c && k === g - 1 && z.length - d === c) {
g = d ? z.slice(d) : z;
break b;
}
}
@@ -514,11 +520,11 @@ function L(a, c, b, f, d) {
for (a = [], l = x(), f = e.length, k = f - 1; 0 <= k; k--) {
if (b = (f = e[k]) && f.length) {
for (n = 0; n < b; n++) {
if (h = f[n], !l[h]) {
if (l[h] = 1, d) {
if (g = f[n], !l[g]) {
if (l[g] = 1, d) {
d--;
} else {
if (a.push(h), a.length === c) {
if (a.push(g), a.length === c) {
break c;
}
}
@@ -528,12 +534,12 @@ function L(a, c, b, f, d) {
}
}
} else {
a = (e = e[0]).length > c || d ? e.slice(d, c + d) : e;
a = (e = e[0]) && c && e.length > c || d ? e.slice(d, c + d) : e;
}
e = a;
} else {
if (a < h) {
h = [];
if (a < g) {
g = [];
break b;
}
e = e[a - 1];
@@ -544,13 +550,13 @@ function L(a, c, b, f, d) {
}
}
}
h = e;
g = e;
}
} else if (1 === f) {
c = H.call(null, a[0], c, d);
break a;
}
c = h;
c = g;
}
return c;
};