bundle v0.7.0
25
.babelrc
@@ -1,26 +1,5 @@
|
||||
{
|
||||
"plugins": [
|
||||
["conditional-compile", {
|
||||
"define": {
|
||||
"DEBUG": false,
|
||||
"PROFILER": false,
|
||||
"POLYFILL": true,
|
||||
"SUPPORT_WORKER": true,
|
||||
"SUPPORT_ENCODER": true,
|
||||
"SUPPORT_CACHE": true,
|
||||
"SUPPORT_ASYNC": true,
|
||||
"SUPPORT_PRESET": true,
|
||||
"SUPPORT_SUGGESTION": true,
|
||||
"SUPPORT_SERIALIZE": true,
|
||||
"SUPPORT_INFO": true,
|
||||
"SUPPORT_DOCUMENT": true,
|
||||
"SUPPORT_WHERE": true,
|
||||
"SUPPORT_PAGINATION": true,
|
||||
"SUPPORT_OPERATOR": true,
|
||||
"SUPPORT_CALLBACK": true,
|
||||
"SUPPORT_LANG": false
|
||||
}
|
||||
}],
|
||||
"babel-plugin-minify-constant-folding",
|
||||
"babel-plugin-minify-dead-code-elimination",
|
||||
"babel-plugin-minify-flip-comparisons",
|
||||
@@ -38,9 +17,7 @@
|
||||
"babel-plugin-transform-undefined-to-void"
|
||||
],
|
||||
"ignore": [
|
||||
"config.js",
|
||||
"bundle.js",
|
||||
"export.js"
|
||||
"config/**"
|
||||
],
|
||||
"minified": true,
|
||||
"compact": true,
|
||||
|
6
.gitattributes
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
src/css/winbox.css -linguist-detectable
|
||||
index.html -linguist-detectable
|
||||
bench/** -linguist-detectable
|
||||
dist/** -linguist-detectable
|
||||
doc/** -linguist-detectable
|
||||
task/** -linguist-detectable
|
6
.gitignore
vendored
@@ -1,11 +1,13 @@
|
||||
.idea
|
||||
.nyc_output
|
||||
.db
|
||||
!*.keep
|
||||
coverage
|
||||
perf
|
||||
node_modules
|
||||
server
|
||||
!*.keep
|
||||
tmp
|
||||
log
|
||||
issue
|
||||
issue
|
||||
data
|
||||
node
|
||||
|
@@ -1,3 +0,0 @@
|
||||
language: node_js
|
||||
node_js: stable
|
||||
after_success: cd test && npm run coverage
|
28
README.md
@@ -1,20 +1,15 @@
|
||||
<p align="center">
|
||||
<br>
|
||||
<img src="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/doc/flexsearch.svg" alt="Search Library" width="50%">
|
||||
<br><br>
|
||||
<a target="_blank" href="https://www.npmjs.com/package/flexsearch"><img src="https://img.shields.io/npm/v/flexsearch.svg"></a>
|
||||
<a target="_blank" href="https://travis-ci.org/nextapps-de/flexsearch"><img src="https://travis-ci.org/nextapps-de/flexsearch.svg?branch=master"></a>
|
||||
<a target="_blank" href="https://coveralls.io/github/nextapps-de/flexsearch?branch=master"><img src="https://coveralls.io/repos/github/nextapps-de/flexsearch/badge.svg?branch=master&v=0"></a>
|
||||
<a target="_blank" href="https://www.codacy.com/app/ts-thomas/FlexSearch?utm_source=github.com&utm_medium=referral&utm_content=nextapps-de/flexsearch&utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/a896e010f6b4429aa7bc9a89550320a7"/></a>
|
||||
<a target="_blank" href="https://github.com/nextapps-de/flexsearch/issues"><img src="https://img.shields.io/github/issues/nextapps-de/flexsearch.svg"></a>
|
||||
<a target="_blank" href="https://github.com/nextapps-de/flexsearch/blob/master/LICENSE.md"><img src="https://img.shields.io/npm/l/flexsearch.svg"></a>
|
||||
</p>
|
||||
<h1 align="center">
|
||||
<img src="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.7.0/doc/flexsearch-logo-glass.svg" alt="FlexSearch.js: Next-Generation full text search library for Browser and Node.js">
|
||||
<p></p>
|
||||
</h1>
|
||||
|
||||
<h2></h2>
|
||||
<a target="_blank" href="https://www.npmjs.com/package/flexsearch"><img src="https://img.shields.io/npm/v/flexsearch.svg"></a>
|
||||
<a target="_blank" href="https://travis-ci.org/nextapps-de/flexsearch"><img src="https://travis-ci.org/nextapps-de/flexsearch.svg?branch=master"></a>
|
||||
<a target="_blank" href="https://coveralls.io/github/nextapps-de/flexsearch?branch=master"><img src="https://coveralls.io/repos/github/nextapps-de/flexsearch/badge.svg?branch=master&v=0"></a>
|
||||
<a target="_blank" href="https://github.com/nextapps-de/flexsearch/blob/master/LICENSE.md"><img src="https://img.shields.io/npm/l/flexsearch.svg"></a>
|
||||
|
||||
### FlexSearch v0.7.0 (Beta)
|
||||
|
||||
Beta is now available. Please test the new version and post back issues and suggestions. The Beta will pushed to the master branch in 2 weeks.
|
||||
### FlexSearch v0.7.0
|
||||
|
||||
Read the documentation of new features and changes:<br>
|
||||
<a href="https://github.com/nextapps-de/flexsearch/blob/0.7.0/doc/0.7.0.md">https://github.com/nextapps-de/flexsearch/blob/0.7.0/doc/0.7.0.md</a>
|
||||
@@ -437,11 +432,6 @@ FlexSearch introduce a new scoring mechanism called __Contextual Search__ which
|
||||
The basic idea of this concept is to limit relevance by its context instead of calculating relevance through the whole (unlimited) distance.<!--Imagine you add a text block of some sentences to an index ID. Assuming the query includes a combination of first and last word from this text block, are they really relevant to each other?-->
|
||||
In this way contextual search also <a href="https://raw.githack.com/nextapps-de/flexsearch/master/test/matching.html" target="_blank">improves the results of relevance-based queries</a> on a large amount of text data.
|
||||
|
||||
<!--
|
||||
> "TF-IDF and all kinds of variations (like BM25) is a big mistake in searching algorithms today. They don't provide neither: a meaningful relevance of a term nor the importance of it! Like many pseudo-intelligent algorithms this is also just an example of mathematical stupidity." — Thomas Wilkerling, _Contextual-based Scoring_, 2018
|
||||
#### Model of context-based scoring
|
||||
-->
|
||||
|
||||
<p align="center">
|
||||
<img src="https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@master/doc/contextual-index.svg">
|
||||
</p>
|
||||
|
159
bench/bench.js
@@ -1,8 +1,9 @@
|
||||
import { text_data } from "./data/gulliver.js"; // , text_queries, text_queries_multi
|
||||
import { text_data } from "../demo/data/gulliver.js";
|
||||
|
||||
export let suite = {};
|
||||
export const test = {};
|
||||
const result = document.getElementById("result").appendChild(document.createTextNode("running..."));
|
||||
const match = window.location.hash.indexOf("match") !== -1;
|
||||
export const queue = [];
|
||||
let lib;
|
||||
|
||||
@@ -19,12 +20,6 @@ const params = (function(){
|
||||
return obj;
|
||||
}());
|
||||
|
||||
// const text_queries_notfound = [
|
||||
//
|
||||
// "undefined1 undefined2 undefined3",
|
||||
// "undefined"
|
||||
// ];
|
||||
|
||||
let runs;
|
||||
let duration;
|
||||
|
||||
@@ -38,6 +33,66 @@ else{
|
||||
duration = parseFloat(params["duration"] || "5") * 1000;
|
||||
}
|
||||
|
||||
if(match){
|
||||
|
||||
text_data.push('zero one two three four five six seven eight nine ten');
|
||||
text_data.push('four two zero one three ten five seven eight six nine');
|
||||
text_data.push('zero one two three four five six seven eight nine ten');
|
||||
}
|
||||
|
||||
// queue.push({
|
||||
// name: "add",
|
||||
// init: null,
|
||||
// test: null,
|
||||
// start: null,
|
||||
// prepare: null,
|
||||
// fn: function(){
|
||||
// lib.init();
|
||||
// lib.add(text_data);
|
||||
// },
|
||||
// end: null,
|
||||
// complete: null,
|
||||
// count: text_data.length
|
||||
// });
|
||||
//
|
||||
// queue.push({
|
||||
// name: "update",
|
||||
// init: null,
|
||||
// test: null,
|
||||
// start: function(){
|
||||
// lib.init();
|
||||
// lib.add(text_data);
|
||||
// },
|
||||
// prepare: null,
|
||||
// fn: function(){
|
||||
// lib.add(text_data);
|
||||
// },
|
||||
// end: null,
|
||||
// complete: null,
|
||||
// count: text_data.length
|
||||
// });
|
||||
//
|
||||
// let index;
|
||||
//
|
||||
// queue.push({
|
||||
// name: "remove",
|
||||
// init: null,
|
||||
// test: null,
|
||||
// start: function(){
|
||||
// lib.init();
|
||||
// lib.add(text_data);
|
||||
// index = 0;
|
||||
// },
|
||||
// prepare: null,
|
||||
// fn: function(){
|
||||
// lib.remove(index++);
|
||||
// },
|
||||
// end: null,
|
||||
// complete: null,
|
||||
// cycle: text_data.length,
|
||||
// count: 1
|
||||
// });
|
||||
|
||||
queue.push({
|
||||
name: "query-single",
|
||||
init: null,
|
||||
@@ -57,7 +112,8 @@ queue.push({
|
||||
lib.query("houyhnhnms");
|
||||
},
|
||||
end: null,
|
||||
complete: null
|
||||
complete: null,
|
||||
count: 10
|
||||
});
|
||||
|
||||
queue.push({
|
||||
@@ -74,7 +130,39 @@ queue.push({
|
||||
lib.query("lord high chancellor");
|
||||
},
|
||||
end: null,
|
||||
complete: null
|
||||
complete: null,
|
||||
count: 5
|
||||
});
|
||||
|
||||
queue.push({
|
||||
name: "query-long",
|
||||
init: null,
|
||||
test: null,
|
||||
start: null,
|
||||
prepare: null,
|
||||
fn: function(){
|
||||
lib.query("there were six spanish pieces of four pistoles");
|
||||
lib.query("glumdalclitch and i attended the king and queen in a progress");
|
||||
lib.query("only in this island of luggnagg the appetite for living was not so eager");
|
||||
},
|
||||
end: null,
|
||||
complete: null,
|
||||
count: 3
|
||||
});
|
||||
|
||||
queue.push({
|
||||
name: "query-dupes",
|
||||
init: null,
|
||||
test: null,
|
||||
start: null,
|
||||
prepare: null,
|
||||
fn: function(){
|
||||
lib.query("gulliver gulliver gulliver");
|
||||
lib.query("italians homunceletino italians homunceletino");
|
||||
},
|
||||
end: null,
|
||||
complete: null,
|
||||
count: 2
|
||||
});
|
||||
|
||||
queue.push({
|
||||
@@ -84,11 +172,13 @@ queue.push({
|
||||
start: null,
|
||||
prepare: null,
|
||||
fn: function(){
|
||||
lib.query("undefined1 undefined2 undefined3");
|
||||
lib.query("undefined");
|
||||
lib.query("undefineda undefinedb undefinedc");
|
||||
lib.query("lord high undefined");
|
||||
},
|
||||
end: null,
|
||||
complete: null
|
||||
complete: null,
|
||||
count: 3
|
||||
});
|
||||
|
||||
// #####################################################################################
|
||||
@@ -102,7 +192,7 @@ window.onload = function(){
|
||||
lib.init();
|
||||
lib.add(text_data);
|
||||
|
||||
setTimeout(perform, 200);
|
||||
setTimeout(match ? perform_match : perform, 200);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -143,11 +233,11 @@ function perform(){
|
||||
|
||||
const test = queue[current];
|
||||
|
||||
if(current === 0) check_test(test) || msg("Main test failed");
|
||||
if(current === 0) check_test(test) || msg("Main test failed!");
|
||||
|
||||
let elapsed = 0, memory = 0;
|
||||
let status = true;
|
||||
let loops = 0, cycle = 1, now = 0;
|
||||
let loops = 0, cycle = 1, now = 0, max_cycle = test.cycle, inner_count = test.count;
|
||||
|
||||
if(status){
|
||||
|
||||
@@ -170,12 +260,30 @@ function perform(){
|
||||
|
||||
if(test.end) test.end(loops);
|
||||
|
||||
// console.log(test.name);
|
||||
// console.log("duration", duration);
|
||||
// console.log("elapsed", elapsed);
|
||||
// console.log("cycle", cycle);
|
||||
// console.log("loops", loops);
|
||||
|
||||
cycle *= duration / (elapsed || 1);
|
||||
//cycle = loops / (elapsed || 1) * (duration - elapsed);
|
||||
|
||||
// if(cycle < 0){
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
|
||||
if(max_cycle && (cycle > max_cycle)){
|
||||
|
||||
cycle = max_cycle;
|
||||
}
|
||||
}
|
||||
|
||||
if(test.complete) test.complete();
|
||||
}
|
||||
|
||||
loops *= inner_count || 1;
|
||||
current++;
|
||||
|
||||
if(window === window.top){
|
||||
@@ -184,7 +292,7 @@ function perform(){
|
||||
}
|
||||
else{
|
||||
|
||||
window.top.postMessage(test.name + "," + (status ? Math.ceil(1000 / elapsed * loops) : 0) + "," + (status ? Math.ceil(memory / loops) : 0), location.protocol + "//" + location.hostname) //"https://nextapps-de.github.io" "https://raw.githack.com"
|
||||
window.top.postMessage(test.name + "," + (status ? Math.ceil(1000 / elapsed * loops) : 0) + "," + (status ? Math.ceil(memory / loops) : 0), location.protocol + "//" + location.hostname); //"https://nextapps-de.github.io" "https://raw.githack.com"
|
||||
}
|
||||
|
||||
if(current < queue.length){
|
||||
@@ -196,3 +304,24 @@ function perform(){
|
||||
current = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function perform_match(){
|
||||
|
||||
const test = queue[current];
|
||||
const query = decodeURI(params["query"]);
|
||||
|
||||
check_test(test) || msg("Main test failed!");
|
||||
|
||||
const res = lib.query(query);
|
||||
|
||||
if(window === window.top){
|
||||
|
||||
result.nodeValue = JSON.stringify(res);
|
||||
}
|
||||
else{
|
||||
|
||||
window.top.postMessage(JSON.stringify(res), location.protocol + "//" + location.hostname);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -80,27 +80,34 @@
|
||||
<hr>
|
||||
<table id="benchmarks" cellpadding="5" cellspacing="5">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Library</th>
|
||||
<th>Size</th>
|
||||
<th>Memory</th>
|
||||
<th>Query (Single Term)</th>
|
||||
<th>Query (Multi Term)</th>
|
||||
<th>Query (Not Found)</th>
|
||||
<th>Index</th>
|
||||
<th>Score</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Library</th>
|
||||
<th hidden>Size</th>
|
||||
<th>Memory *</th>
|
||||
<!--
|
||||
<th>Add</th>
|
||||
<th>Update</th>
|
||||
<th>Remove</th>
|
||||
-->
|
||||
<th>Query (Single Term)</th>
|
||||
<th>Query (Multi Term)</th>
|
||||
<th>Query (Long)</th>
|
||||
<th>Query (Dupes)</th>
|
||||
<th>Query (Not Found)</th>
|
||||
<th>Index</th>
|
||||
<th>Score</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="result"></tbody>
|
||||
</table>
|
||||
<br>
|
||||
To measure memory you have to run in Chrome browser.<br><br>
|
||||
* To measure memory you have to run in Chrome browser.<br><br>
|
||||
<b>Single Tests:</b>
|
||||
<ul id="lib"></ul>
|
||||
<iframe id="iframe" hidden></iframe>
|
||||
<script src="dist/mikado.min.js"></script>
|
||||
<script src="https://rawcdn.githack.com/nextapps-de/mikado/0.7.4/dist/mikado.min.js"></script>
|
||||
<script src="tpl/row.js"></script>
|
||||
<script src="tpl/lib.js"></script>
|
||||
<script src="main.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
@@ -9,6 +9,8 @@
|
||||
|
||||
const modes = window.location.hash.indexOf("modes") !== -1;
|
||||
const encode = window.location.hash.indexOf("encode") !== -1;
|
||||
const update = window.location.hash.indexOf("update") !== -1;
|
||||
|
||||
let keep;
|
||||
let repeat;
|
||||
let index = -1;
|
||||
@@ -19,10 +21,10 @@
|
||||
"flexsearch-match", "flexsearch-memory", "flexsearch-score",
|
||||
"flexsearch-speed"
|
||||
]:[
|
||||
/*"flexsearch-0.6.2",*/ "flexsearch-0.6.3", "flexsearch-0.7.0",
|
||||
"bm25", "bulksearch", "elasticlunr",
|
||||
"flexsearch", "flexsearch-0.6.3", "fuse",
|
||||
"fuzzysearch", "js-search", "jsii",
|
||||
"lunr", "wade"
|
||||
"fuse", "lunr", "wade"
|
||||
]);
|
||||
|
||||
list.render(lib);
|
||||
@@ -52,44 +54,52 @@
|
||||
|
||||
const test = encode ? [
|
||||
|
||||
"size", "memory", "encode"
|
||||
"size", "memory",
|
||||
"encode"
|
||||
|
||||
]: update ? [
|
||||
|
||||
"size", "memory",
|
||||
"add", "update", "remove",
|
||||
]:[
|
||||
"size", "memory",
|
||||
"add", "query-single",
|
||||
"query-multi", "not-found"
|
||||
//"add",
|
||||
"query-single", "query-multi", "query-long", "query-dupes", "not-found"
|
||||
];
|
||||
|
||||
const current = new Array(lib.length);
|
||||
|
||||
let size = {
|
||||
|
||||
"bm25": 1,
|
||||
"bulksearch": 1,
|
||||
"elasticlunr": 1,
|
||||
"flexsearch": 1,
|
||||
"flexsearch-0.6.3": 1,
|
||||
"fuse": 1,
|
||||
"fuzzysearch": 1,
|
||||
"js-search": 1,
|
||||
"jsii": 1,
|
||||
"lunr": 1,
|
||||
"wade": 1,
|
||||
|
||||
"flexsearch-balance": 3.0,
|
||||
"flexsearch-default": 3.0,
|
||||
"flexsearch-fast": 3.0,
|
||||
"flexsearch-match": 3.0,
|
||||
"flexsearch-memory": 3.0,
|
||||
"flexsearch-score": 3.0,
|
||||
"flexsearch-speed": 3.0
|
||||
};
|
||||
// let size = {
|
||||
//
|
||||
// "bm25": 1,
|
||||
// "bulksearch": 1,
|
||||
// "elasticlunr": 1,
|
||||
// "fuse": 1,
|
||||
// "fuzzysearch": 1,
|
||||
// "js-search": 1,
|
||||
// "jsii": 1,
|
||||
// "lunr": 1,
|
||||
// "wade": 1,
|
||||
//
|
||||
// "flexsearch-0.6.2": 1,
|
||||
// "flexsearch-0.6.3": 1,
|
||||
// "flexsearch-0.7.0": 1,
|
||||
//
|
||||
// "flexsearch-balance": 1,
|
||||
// "flexsearch-default": 1,
|
||||
// "flexsearch-fast": 1,
|
||||
// "flexsearch-match": 1,
|
||||
// "flexsearch-memory": 1,
|
||||
// "flexsearch-score": 1,
|
||||
// "flexsearch-speed": 1
|
||||
// };
|
||||
|
||||
for(let x = 0; x < lib.length; x++){
|
||||
|
||||
current[x] = {
|
||||
|
||||
"name": lib[x],
|
||||
"size": size[lib[x]],
|
||||
"size": 1, //size[lib[x]],
|
||||
"memory": 0,
|
||||
"score": "",
|
||||
"index": ""
|
221
bench/match.html
Normal file
@@ -0,0 +1,221 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Matching Test</title>
|
||||
<style>
|
||||
body{
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table td{
|
||||
padding: 1em 2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Relevance Scoring Comparison</h2>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<hr>
|
||||
<div id="container">
|
||||
<table>
|
||||
<tr>
|
||||
<th style="width: 200px"><b>Query</b></th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
<tr id="test-1">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-2">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-3">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-4">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-5">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-6">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-7">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-8">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-9">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-10">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-11">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-12">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="11">
|
||||
<br>
|
||||
Contextual Search Test:
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="test-13">
|
||||
<td> </td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<hr>
|
||||
<div style="line-height: 2em">
|
||||
<div style="display:inline-block; width:16px; height:16px; background: #f00"></div> Either no results or relevant content was not included in results.<br>
|
||||
<div style="display:inline-block; width:16px; height:16px; background: orange"></div> Most relevant results was not found in the first place.<br>
|
||||
<div style="display:inline-block; width:16px; height:16px; background: #0a0"></div> Most relevant results was successfully found in the first place.<br>
|
||||
<b>Note:</b> Open console and type e.g. <i>data[493]</i>
|
||||
</div>
|
||||
<iframe id="iframe" hidden></iframe>
|
||||
<script type="module" src="match.js"></script>
|
||||
</body>
|
||||
</html>
|
146
bench/match.js
Normal file
@@ -0,0 +1,146 @@
|
||||
import { text_data as data } from "../demo/data/gulliver.js";
|
||||
|
||||
const headers = document.getElementsByTagName("th");
|
||||
const iframe = document.getElementsByTagName("iframe")[0];
|
||||
const encode = false;
|
||||
const lib = encode ? [
|
||||
|
||||
"flexsearch-balance", "flexsearch-default", "flexsearch-fast",
|
||||
"flexsearch-match", "flexsearch-memory", "flexsearch-score",
|
||||
"flexsearch-speed"
|
||||
]:[
|
||||
/*"flexsearch-0.6.2", "flexsearch-0.6.3",*/ "flexsearch-0.7.0-match",
|
||||
"bm25", "bulksearch", "elasticlunr",
|
||||
"fuzzysearch", "js-search", "jsii",
|
||||
"fuse", "lunr", "wade"
|
||||
];
|
||||
|
||||
let promise;
|
||||
|
||||
window.onmessage = function(event){
|
||||
|
||||
if(event.origin === location.protocol + "//" + location.hostname){
|
||||
|
||||
const results = JSON.parse(event.data);
|
||||
//console.log(results);
|
||||
promise(results);
|
||||
promise = null;
|
||||
}
|
||||
};
|
||||
|
||||
window.data = data;
|
||||
|
||||
//iframe.src = "test/" + lib[0].toLowerCase() + "/?query=gulliver" + (encode ? "&encode=true" : "") + "#match";
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
await do_test("test-1", "without breach of modesty", [2684]);
|
||||
await do_test("test-2", "went softly stream", [2432]);
|
||||
await do_test("test-3", "princes of the ambition", [2259, 396]);
|
||||
await do_test("test-4", "five-thousand leagues", [7]);
|
||||
await do_test("test-5", "raise up soft", [2069]);
|
||||
await do_test("test-6", "disgust the bigness", [946]);
|
||||
await do_test("test-7", "bignes of splaknuk", [781]);
|
||||
await do_test("test-8", "matematikal musikal instruments", [1480]);
|
||||
await do_test("test-9", "composition of minerals gums juices vegetables", [1676, 2337]);
|
||||
await do_test("test-10", "general camberlayhn", [520]);
|
||||
await do_test("test-11", "the end defeat", [2209]);
|
||||
await do_test("test-12", "fast chief", [1275]);
|
||||
await do_test("test-13", "zero one three ten", [2721, 2720, 2722]);
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
async function do_test(id, query, ref){
|
||||
|
||||
const nodes = document.getElementById(id).getElementsByTagName("td");
|
||||
nodes[0].firstChild.nodeValue = query;
|
||||
|
||||
for(let i = 0, current; i < lib.length; i++){
|
||||
|
||||
current = lib[i];
|
||||
headers[i + 1].firstChild.nodeValue = current.replace("-0.7.0-match", "");
|
||||
|
||||
let results = await new Promise(function(resolve){
|
||||
|
||||
promise = resolve;
|
||||
iframe.src = "test/" + (id === "test-13" && current === "flexsearch-0.7.0-match" ? "flexsearch-0.7.0-context" : current) +
|
||||
"/?query=" + decodeURI(query) + (encode ? "&encode=true" : "") + "#match";
|
||||
});
|
||||
|
||||
if(results.length){
|
||||
|
||||
switch(current){
|
||||
|
||||
// case "flexsearch":
|
||||
// break;
|
||||
//
|
||||
// case "bulksearch":
|
||||
// break;
|
||||
//
|
||||
// case "fuse":
|
||||
// break;
|
||||
|
||||
case "elasticlunr":
|
||||
results = results.map(val => val.ref);
|
||||
break;
|
||||
|
||||
case "lunr":
|
||||
results = results.map(val => val.ref);
|
||||
break;
|
||||
|
||||
case "wade":
|
||||
results = results.map(val => val.index);
|
||||
break;
|
||||
|
||||
case "js-search":
|
||||
results = results.map(val => val.id);
|
||||
break;
|
||||
|
||||
case "jsii":
|
||||
results = results.map(val => val.id);
|
||||
break;
|
||||
|
||||
case "bm25":
|
||||
results = results.map(val => val.id);
|
||||
break;
|
||||
|
||||
case "fuzzysearch":
|
||||
results = results.map(val => data.indexOf(val));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const node = nodes[lib.indexOf(current) + 1];
|
||||
const style = node.style;
|
||||
|
||||
for(let a = 0; a < ref.length; a++){
|
||||
|
||||
const current = ref[a];
|
||||
|
||||
node.firstChild.nodeValue = results[0] || "-";
|
||||
style.color = "#fff";
|
||||
style.backgroundColor = "";
|
||||
|
||||
|
||||
if((results[a] === current) ||
|
||||
(results[a] === ("" + current))){
|
||||
|
||||
if(style.backgroundColor !== "orange"){
|
||||
|
||||
style.backgroundColor = "#0a0";
|
||||
}
|
||||
}
|
||||
else if(!results.length ||
|
||||
((results.indexOf(current) === -1) &&
|
||||
(results.indexOf(("" + current)) === -1))){
|
||||
|
||||
style.backgroundColor = "#f00";
|
||||
break;
|
||||
}
|
||||
else{
|
||||
|
||||
style.backgroundColor = "orange";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,528 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Matching Test</title>
|
||||
<style>
|
||||
body{
|
||||
font-family: sans-serif;
|
||||
}
|
||||
table td{
|
||||
padding: 1em 2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Relevance Scoring Comparison</h2>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<hr>
|
||||
<div id="container">
|
||||
<table>
|
||||
<tr>
|
||||
<th><b>Query</b></th>
|
||||
<th>flexsearch</th>
|
||||
<th>bulksearch</th>
|
||||
<th>elasticlunr</th>
|
||||
<th>lunr</th>
|
||||
<th>wade</th>
|
||||
<th>fuse</th>
|
||||
<th>jssearch</th>
|
||||
<th>jsii</th>
|
||||
<th>bm25</th>
|
||||
<th>fuzzysearch</th>
|
||||
</tr>
|
||||
<tr id="test-1">
|
||||
<td style="width: 200px"></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-2">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-3">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-4">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-5">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-6">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-7">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-8">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-9">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-10">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-11">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr id="test-12">
|
||||
<td></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="10">
|
||||
<br>
|
||||
Contextual Search Test:
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="test-13">
|
||||
<td style="width: 200px"></td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
<td>wait ...</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<hr>
|
||||
<div style="line-height: 2em">
|
||||
<div style="display:inline-block; width:16px; height:16px; background: #f00"></div> Either no results or relevant content was not included in results.<br>
|
||||
<div style="display:inline-block; width:16px; height:16px; background: orange"></div> Most relevant results was not found in the first place.<br>
|
||||
<div style="display:inline-block; width:16px; height:16px; background: #0a0"></div> Most relevant results was successfully found in the first place.<br>
|
||||
<b>Note:</b> Open console and type e.g. <i>data[493]</i>
|
||||
</div>
|
||||
<script src="../dist/flexsearch.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/nextapps-de/bulksearch@master/bulksearch.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/weixsong/elasticlunr.js@0.9.6/example/elasticlunr.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/lunr@2.1.6/lunr.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/kbrsh/wade@master/dist/wade.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/krisk/Fuse@3.0.4/dist/fuse.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/js-search@1.3.7/dist/umd/js-search.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/BitSet.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/JSii.js"></script>
|
||||
<script src="https://gistcdn.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
|
||||
<script src="https://rawcdn.githack.com/jeancroy/FuzzySearch/cbcdd8307d70a209b1cbf17a535158d5c21840d7/dist/FuzzySearch.min.js"></script>
|
||||
<script src="../data/gulliver.js"></script>
|
||||
<script>
|
||||
|
||||
var data = [];
|
||||
|
||||
setTimeout(function(){
|
||||
|
||||
var new_data = text_data;
|
||||
var tmp = '';
|
||||
|
||||
for(var i = 0; i < new_data.length; i++){
|
||||
|
||||
if(new_data[i].length > 2) {
|
||||
|
||||
tmp += new_data[i] + '. ';
|
||||
|
||||
if((tmp.length > 1000) || (i === new_data.length - 1)){
|
||||
|
||||
data.push(tmp.replace(/{[^}]*}/g, ''));
|
||||
tmp = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.push('zero one two three four five six seven eight nine ten.');
|
||||
data.push('zero one two three four five six seven eight nine ten.');
|
||||
data.push('four two zero one three ten five seven eight six nine.');
|
||||
data.push('zero one two three four five six seven eight nine ten.');
|
||||
data.push('zero one two three four five six seven eight nine ten.');
|
||||
|
||||
tmp = null;
|
||||
new_data = null;
|
||||
text_data = null;
|
||||
|
||||
var bulksearch;
|
||||
var flexsearch;
|
||||
var elasticsearch;
|
||||
var lunrsearch;
|
||||
var wade;
|
||||
var fuse;
|
||||
var jssearch;
|
||||
var jsii;
|
||||
var bm25;
|
||||
var fuzzysearch;
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
bulksearch = new BulkSearch({
|
||||
type: 'short', // this type specifies the maximum bitlength of assigned IDs!
|
||||
encode: 'extra',
|
||||
multi: true
|
||||
});
|
||||
|
||||
console.time('bulksearch');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
bulksearch.add(i, data[i]);
|
||||
}
|
||||
|
||||
console.timeEnd('bulksearch');
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
flexsearch = new FlexSearch({
|
||||
encode: 'extra',
|
||||
tokenize: 'strict',
|
||||
threshold: 0,
|
||||
resolution: 9,
|
||||
depth: 3
|
||||
});
|
||||
|
||||
console.time('flexsearch');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
flexsearch.add(i, data[i]);
|
||||
}
|
||||
|
||||
console.timeEnd('flexsearch');
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
elasticsearch = elasticlunr(function () {
|
||||
this.setRef('id');
|
||||
this.addField('content');
|
||||
});
|
||||
|
||||
console.time('elasticsearch');
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
elasticsearch.addDoc({id: i, content: data[i]});
|
||||
}
|
||||
|
||||
console.timeEnd('elasticsearch');
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
console.time('lunr');
|
||||
|
||||
lunrsearch = lunr(function(){
|
||||
this.ref('id');
|
||||
this.field('content');
|
||||
for(var i = 0; i < data.length; i++){
|
||||
this.add({id: i, content: data[i]});
|
||||
}
|
||||
});
|
||||
|
||||
console.timeEnd('lunr');
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
var wadesearch = function(query){
|
||||
return wade(query).sort(sort_by_score_down);
|
||||
};
|
||||
|
||||
function sort_by_score_down(a, b){
|
||||
var sum = a.score - b.score;
|
||||
return sum < 0 ? 1 : sum > 0 ? -1 : 0;
|
||||
}
|
||||
|
||||
console.time('wade');
|
||||
wade = Wade(data.slice(0));
|
||||
console.timeEnd('wade');
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
var payload = [];
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
payload[i] = {id: i, content: data[i]};
|
||||
}
|
||||
|
||||
// Note: fuse adds async?
|
||||
console.time('fuse');
|
||||
|
||||
fuse = new Fuse(payload.slice(0), {
|
||||
keys: ['content'],
|
||||
id: 'id',
|
||||
shouldSort: true,
|
||||
threshold: 0.6,
|
||||
location: 0,
|
||||
distance: 100,
|
||||
findAllMatches: true,
|
||||
maxPatternLength: 32,
|
||||
minMatchCharLength: 1
|
||||
});
|
||||
|
||||
console.timeEnd('fuse');
|
||||
|
||||
// payload = null;
|
||||
// data = null;
|
||||
// return;
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
jssearch = new JsSearch.Search('id');
|
||||
jssearch.addIndex('content');
|
||||
console.time('jssearch');
|
||||
jssearch.addDocuments(payload.slice(0));
|
||||
console.timeEnd('jssearch');
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
var payload = [];
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
payload[i] = {id: i, text: data[i]};
|
||||
}
|
||||
|
||||
jsii = new JSii();
|
||||
|
||||
console.time('jsii');
|
||||
jsii.feedDocs(payload.slice(0));
|
||||
console.timeEnd('jsii');
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
bm25 = new BM25();
|
||||
|
||||
console.time('bm25');
|
||||
for(var i = 0; i < data.length; i++){
|
||||
bm25.addDocument({id: i, body: data[i]});
|
||||
}
|
||||
bm25.updateIdf();
|
||||
console.timeEnd('bm25');
|
||||
|
||||
payload = null;
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
console.time('fuzzysearch');
|
||||
fuzzysearch = new FuzzySearch({source:data.slice(0)});
|
||||
console.timeEnd('fuzzysearch');
|
||||
|
||||
// -----------------------------------------------------------
|
||||
|
||||
do_test('test-1', 'without breach of modesty', [493]);
|
||||
do_test('test-2', 'went softly stream', [446]);
|
||||
do_test('test-3', 'princes of the ambition', [72, 408]);
|
||||
do_test('test-4', 'five-thousand leagues', [2]);
|
||||
do_test('test-5', 'i already observed', [458, 346]);
|
||||
do_test('test-6', 'disgust the bigness', [175]);
|
||||
do_test('test-7', 'bignes of splaknuk', [146]);
|
||||
do_test('test-8', 'matematikal musikal instruments', [267]);
|
||||
do_test('test-9', 'composition of minerals gums juices vegetables', [303]);
|
||||
do_test('test-10', 'lalkon the camberlayhn', [99]);
|
||||
do_test('test-11', 'to be at all this is', [184]);
|
||||
do_test('test-12', 'matical sical strument', [267]);
|
||||
do_test('test-13', 'zero one three ten', [504]);
|
||||
|
||||
// ---------------------------------------
|
||||
|
||||
function do_test(id, query, ref){
|
||||
|
||||
var nodes = document.getElementById(id).getElementsByTagName('td');
|
||||
|
||||
nodes[0].innerHTML = query;
|
||||
|
||||
for(var i = 1; i < nodes.length; i++){
|
||||
|
||||
var results;
|
||||
|
||||
switch(i){
|
||||
|
||||
case 1:
|
||||
results = flexsearch.search(query, {suggest: true});
|
||||
break;
|
||||
|
||||
case 2:
|
||||
results = bulksearch.search(query, {suggest: true});
|
||||
break;
|
||||
|
||||
case 3:
|
||||
results = elasticsearch.search(query).map(function(val){return val.ref});
|
||||
break;
|
||||
|
||||
case 4:
|
||||
results = lunrsearch.search(query).map(function(val){return val.ref});
|
||||
break;
|
||||
|
||||
case 5:
|
||||
results = wadesearch(query).map(function(val){return val.index});
|
||||
break;
|
||||
|
||||
case 6:
|
||||
results = fuse.search(query);
|
||||
break;
|
||||
|
||||
case 7:
|
||||
results = jssearch.search(query).map(function(val){return val.id});
|
||||
break;
|
||||
|
||||
case 8:
|
||||
results = jsii.search(query).docs.map(function(val){return val.id});
|
||||
break;
|
||||
|
||||
case 9:
|
||||
results = bm25.search(query).map(function(val){return val.id});
|
||||
break;
|
||||
|
||||
case 10:
|
||||
results = fuzzysearch.search(query).map(function(val){
|
||||
for(var i = 0; i < data.length; i++){
|
||||
if(val === data[i]) return i;
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
for(var a = 0; a < ref.length; a++){
|
||||
|
||||
var current = ref[a];
|
||||
|
||||
nodes[i].innerHTML = results[0] || '-';
|
||||
nodes[i].style.color = '#fff';
|
||||
|
||||
if((results[0] === current) || (results[0] === String(current))){
|
||||
|
||||
nodes[i].style.backgroundColor = '#0a0';
|
||||
break;
|
||||
}
|
||||
else if(!results.length || ((results.indexOf(current) === -1) && (results.indexOf(String(current)) === -1))){
|
||||
|
||||
if(nodes[i].style.backgroundColor !== 'orange'){
|
||||
|
||||
nodes[i].style.backgroundColor = '#f00';
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
nodes[i].style.backgroundColor = 'orange';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, 50);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -22,7 +22,7 @@
|
||||
<div id="container"></div>
|
||||
<hr>
|
||||
<script src="../dist/flexsearch.compact.js"></script>
|
||||
<script src="../data/gulliver.js"></script>
|
||||
<script src="../demo/data/gulliver.js"></script>
|
||||
<script>
|
||||
|
||||
(function(){
|
@@ -17,7 +17,7 @@
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<hr>
|
||||
<script src="../dist/flexsearch.min.js"></script>
|
||||
<script src="../data/gulliver.js"></script>
|
||||
<script src="../demo/data/gulliver.js"></script>
|
||||
<div id="container">
|
||||
<table>
|
||||
<tr>
|
@@ -3,7 +3,9 @@
|
||||
"scripts": {
|
||||
"server": "node server.js"
|
||||
},
|
||||
"dependencies": {},
|
||||
"dependencies": {
|
||||
"google-closure-compiler": "^20210505.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"web-servo": "^0.5.1"
|
||||
}
|
@@ -13,13 +13,13 @@
|
||||
<script type="module" src="src/bundle.js"></script>
|
||||
-->
|
||||
|
||||
<script src="../../dist/flexsearch.light.js"></script>
|
||||
<script src="../../../dist/flexsearch.light.js"></script>
|
||||
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
//import { text_data } from "./../../data/gulliver.js";
|
||||
//import FlexSearch from "../../node_modules/flexsearch/src/bundle.js";
|
||||
import { suite } from "../../bench.js";
|
||||
//import { text_data } from "../../../demo/data/gulliver.js";
|
||||
//import FlexSearch from "../../../node_modules/flexsearch/src/bundle.js";
|
||||
|
||||
let lib, split = /[^a-z]+/;
|
||||
|
||||
@@ -29,11 +29,17 @@
|
||||
|
||||
lib = new FlexSearch({
|
||||
|
||||
// encode: str => str.toLowerCase().split(split),
|
||||
// tokenize: "strict",
|
||||
// threshold: 8,
|
||||
// resolution: 9,
|
||||
// depth: 1
|
||||
|
||||
encode: str => str.toLowerCase().split(split),
|
||||
tokenize: "strict",
|
||||
threshold: 8,
|
||||
resolution: 9,
|
||||
depth: 1
|
||||
depth: 2
|
||||
});
|
||||
|
||||
//window.test = lib;
|
||||
@@ -46,6 +52,17 @@
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
lib.remove(id);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
105
bench/old/test/flexsearch/test.html
Normal file
@@ -0,0 +1,105 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.7.0</h2><hr/>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
|
||||
|
||||
<script src="src/config.js"></script>
|
||||
<script type="module" src="src/bundle.js"></script>
|
||||
<!--
|
||||
<script src="../../dist/flexsearch.light.js"></script>
|
||||
-->
|
||||
<script type="module">
|
||||
|
||||
// import { encode, rtl, tokenize } from "./src/lang/latin/default.js";
|
||||
// import { stemmer, filter, matcher } from "./src/lang/de.js";
|
||||
|
||||
const index = new FlexSearch({
|
||||
doc: {
|
||||
id: "id",
|
||||
field: ["title", "subtitle"]
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
index.add({
|
||||
id: 0,
|
||||
title: "test1",
|
||||
subtitle: "test1"
|
||||
});
|
||||
|
||||
index.add({
|
||||
id: 1,
|
||||
title: "test2",
|
||||
subtitle: "test2"
|
||||
});
|
||||
|
||||
// index.search([{
|
||||
// field: ["title", "subtitle"],
|
||||
// query: "foo",
|
||||
// bool: "or"
|
||||
// },{
|
||||
// field: ["title", "subtitle"],
|
||||
// query: "bar",
|
||||
// bool: "or"
|
||||
// },{
|
||||
// field: ["title", "subtitle"],
|
||||
// query: "test",
|
||||
// bool: "or"
|
||||
// }]);
|
||||
//
|
||||
// index.search({
|
||||
// "and": [{
|
||||
// "or": [{
|
||||
// field: "title",
|
||||
// query: "foo"
|
||||
// },{
|
||||
// field: "title",
|
||||
// query: "bar"
|
||||
// }]
|
||||
// },{
|
||||
// "not": [{
|
||||
// field: "content",
|
||||
// query: "foo"
|
||||
// },{
|
||||
// field: "content",
|
||||
// query: "bar"
|
||||
// }]
|
||||
// }]
|
||||
// });
|
||||
//
|
||||
// index.search({
|
||||
// "and": [{
|
||||
// field: "title",
|
||||
// query: ["foo", "bar"]
|
||||
// },{
|
||||
// field: "content",
|
||||
// query: ["foo", "bar"],
|
||||
// bool: "not" // applies to the query array
|
||||
// }]
|
||||
// });
|
||||
|
||||
console.log(index.search(
|
||||
[{
|
||||
field: ["title", "subtitle"],
|
||||
query: "foo",
|
||||
bool: "or"
|
||||
},{
|
||||
field: ["title", "subtitle"],
|
||||
query: "bar",
|
||||
bool: "or"
|
||||
},{
|
||||
field: ["title", "subtitle"],
|
||||
query: "test",
|
||||
bool: "or"
|
||||
}]
|
||||
));
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -11,7 +11,7 @@
|
||||
<script src="https://gistcdn.githack.com/vlad-x/a25e0c5c1eeb6bf6aa38/raw/02d1a1703e4a99a7c733c85097f583579f6af4e2/bm25.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
@@ -24,11 +24,25 @@
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
|
||||
lib.addDocument({id: i, body: data[i]});
|
||||
}
|
||||
|
||||
lib.updateIdf();
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
|
||||
lib.addDocument({id: i, body: data[i]});
|
||||
}
|
||||
|
||||
lib.updateIdf();
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
// not implemented
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/gh/nextapps-de/bulksearch@master/bulksearch.light.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
init: function(){
|
||||
|
||||
lib = new BulkSearch({
|
||||
|
||||
type: "short",
|
||||
encode: "icase",
|
||||
multi: false,
|
||||
@@ -31,9 +32,17 @@
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
update: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.update(i, data[i]);
|
||||
}
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/gh/weixsong/elasticlunr.js@0.9.6/example/elasticlunr.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
init: function(){
|
||||
|
||||
lib = elasticlunr(function(){
|
||||
|
||||
this.addField("content");
|
||||
this.setRef("id");
|
||||
});
|
||||
@@ -27,6 +28,14 @@
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.addDoc({ id: i, content: data[i] });
|
||||
}
|
||||
},
|
||||
update: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.addDoc({ id: i, content: data[i] });
|
||||
}
|
||||
},
|
||||
|
59
bench/test/flexsearch-0.6.2/index.html
Normal file
@@ -0,0 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.6.2</h2><hr/>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
|
||||
<script src="https://rawcdn.githack.com/nextapps-de/flexsearch/0.6.22/dist/flexsearch.light.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["flexsearch-0.6.2"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new FlexSearch({
|
||||
|
||||
encode: "icase",
|
||||
tokenize: "strict",
|
||||
resolution: 9,
|
||||
threshold: 8,
|
||||
depth: 1
|
||||
});
|
||||
|
||||
window["lib"] = lib;
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
lib.remove(id);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
FlexSearch v0.6.30
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(n,C,D){let t;(t=D.define)&&t.amd?t([],function(){return C}):(t=D.modules)?t[n.toLowerCase()]=C:"object"===typeof exports?module.exports=C:D[n]=C})("FlexSearch",function(){function n(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:T++;this.init(a,b);D(this,"index",function(){return Object.keys(this.c)});D(this,"length",function(){return this.index.length})}function C(a,b){const c=a.length,g=H(b),d=[];for(let h=0,f=0;h<c;h++){const e=a[h];if(g&&b(e)||!g&&!b[e])d[f++]=e}return d}
|
||||
function D(a,b,c){Object.defineProperty(a,b,{get:c})}function t(a){return new RegExp(a,"g")}function K(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function I(a,b,c,g,d,h,f,e){if(b[c])return b[c];d=d?(e-(f||e/1.5))*h+(f||e/1.5)*d:h;b[c]=d;d>=f&&(a=a[e-(d+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=g);return d}function M(a,b){if(a){const c=Object.keys(a);for(let g=0,d=c.length;g<d;g++){const h=c[g],f=a[h];if(f)for(let e=0,k=f.length;e<k;e++)if(f[e]===b){1===k?delete a[h]:f.splice(e,
|
||||
1);break}else"object"===typeof f[e]&&M(f[e],b)}}}function U(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function N(a,b,c){return a?{page:a,next:b?""+b:null,result:c}:c}function E(a){return"string"===typeof a}function H(a){return"function"===typeof a}function J(a){return"undefined"===typeof a}function P(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=y();return b}function y(){return Object.create(null)}const B={encode:"icase",b:"forward",split:/\W+/,cache:!1,async:!1,m:!1,i:!1,l:!1,a:9,threshold:0,depth:0},
|
||||
O=[];let T=0;const Q={},R={};n.create=function(a,b){return new n(a,b)};n.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&O.push(t(b),a[b]);return this};n.registerEncoder=function(a,b){F[a]=b.bind(F);return this};n.registerLanguage=function(a,b){Q[a]=b.filter;R[a]=b.stemmer;return this};n.encode=function(a,b){return F[a](b)};n.prototype.init=function(a,b){this.j=[];if(b){var c=b.preset;a=b}else a||(a=B),c=a.preset;b={};this.b=a.tokenize||b.b||this.b||B.b;this.split=J(c=a.split)?this.split||
|
||||
B.split:E(c)?t(c):c;this.i=a.rtl||this.i||B.i;this.threshold=J(c=a.threshold)?b.threshold||this.threshold||B.threshold:c;this.a=J(c=a.resolution)?c=b.a||this.a||B.a:c;c<=this.threshold&&(this.a=this.threshold+1);this.depth="strict"!==this.b||J(c=a.depth)?b.depth||this.depth||B.depth:c;this.g=(c=J(c=a.encode)?b.encode||B.encode:c)&&F[c]&&F[c].bind(F)||(H(c)?c:this.g||!1);(c=a.matcher)&&this.addMatcher(c);if(c=(b=a.lang)||a.filter){E(c)&&(c=Q[c]);if(c.constructor===Array){{var g=this.g;const h=y();
|
||||
for(let f=0;f<c.length;f++){const e=g?g(c[f]):c[f];h[e]=1}c=h}}this.filter=c}if(c=b||a.stemmer){var d;a=E(c)?R[c]:c;b=this.g;c=[];for(d in a)a.hasOwnProperty(d)&&(g=b?b(d):d,c.push(t(g+"($|\\W)"),b?b(a[d]):a[d]));this.stemmer=d=c}this.h=P(this.a-(this.threshold||0));this.f=y();this.c=y();return this};n.prototype.encode=function(a){a&&(O.length&&(a=K(a,O)),this.j.length&&(a=K(a,this.j)),this.g&&(a=this.g(a)),this.stemmer&&(a=K(a,this.stemmer)));return a};n.prototype.addMatcher=function(a){const b=
|
||||
this.j;for(const c in a)a.hasOwnProperty(c)&&b.push(t(c),a[c]);return this};n.prototype.add=function(a,b,c,g,d){if(b&&E(b)&&(a||0===a)){const u="@"+a;if(this.c[u]&&!g)return this.update(a,b);if(!d&&c)return this.add(a,b,null,g,!0),c(),this;b=this.encode(b);if(!b.length)return this;c=this.b;b=H(c)?c(b):b.split(this.split);this.filter&&(b=C(b,this.filter));g=y();g._ctx=y();d=b.length;const r=this.threshold,v=this.depth,w=this.a,p=this.h,m=this.i;for(let q=0;q<d;q++){var h=b[q];if(h){var f=h.length,
|
||||
e=(m?q+1:d-q)/d,k="";switch(c){case "reverse":case "both":for(var l=f;--l;)k=h[l]+k,I(p,g,k,a,m?1:(f-l)/f,e,r,w-1);k="";case "forward":for(l=0;l<f;l++)k+=h[l],I(p,g,k,a,m?(l+1)/f:1,e,r,w-1);break;case "full":for(l=0;l<f;l++){const G=(m?l+1:f-l)/f;for(let x=f;x>l;x--)k=h.substring(l,x),I(p,g,k,a,G,e,r,w-1)}break;default:if(f=I(p,g,h,a,1,e,r,w-1),v&&1<d&&f>=r)for(f=g._ctx[h]||(g._ctx[h]=y()),h=this.f[h]||(this.f[h]=P(w-(r||0))),e=q-v,k=q+v+1,0>e&&(e=0),k>d&&(k=d);e<k;e++)e!==q&&I(h,f,b[e],a,0,w-(e<
|
||||
q?q-e:e-q),r,w-1)}}}this.c[u]=1}return this};n.prototype.update=function(a,b,c){this.c["@"+a]&&E(b)&&(this.remove(a),this.add(a,b,c,!0));return this};n.prototype.remove=function(a,b,c){const g="@"+a;if(this.c[g]){if(!c&&b)return this.remove(a,null,!0),b(),this;for(b=0;b<this.a-(this.threshold||0);b++)M(this.h[b],a);this.depth&&M(this.f,a);delete this.c[g]}return this};n.prototype.search=function(a,b,c,g){b&&H(b)?(c=b,b=1E3):b||0===b||(b=1E3);var d=[],h=a;if("object"===typeof a){var f=!1;b=a.limit;
|
||||
var e=a.threshold;var k=!1;a=a.query}e||(e=this.threshold||0);if(!g&&c)return c(this.search(h,b,null,!0)),this;if(!a||!E(a))return d;h=this.encode(a);if(!h.length)return d;a=this.b;a=H(a)?a(h):h.split(this.split);this.filter&&(a=C(a,this.filter));c=a.length;g=!0;h=[];var l=y(),u,r=0;1<c&&(this.depth&&"strict"===this.b?u=!0:a.sort(U));var v;if(!u||(v=this.f))for(var w=this.a;r<c;r++){var p=a[r];if(p){if(u){if(!m)if(v[p]){var m=p;l[p]=1}else if(!k)return d;if(k&&r===c-1&&!h.length)u=!1,p=m||p,l[p]=
|
||||
0;else if(!m)continue}if(!l[p]){var q=[],G=!1;let z=0;if(m=u?v[m]:this.h){let S;for(let L=0;L<w-e;L++)if(S=m[L]&&m[L][p])q[z++]=S,G=!0}if(G)m=p,h[h.length]=1<z?q.concat.apply([],q):q[0];else{g=!1;break}l[p]=1}}}else g=!1;if(g)a:{let z;d=[];!0===f?(f="0",e=""):e=f&&f.split(":");k=h.length;if(1<k){u=y();m=0;w=!0;g=0;var x;for(e&&(2===e.length?e=!1:e=x=parseInt(e[0],10));m<k;m++){l=m===k-1;v=h[m];c=v.length;if(!c){d=N(f,z,v);break a}if(w)if(A){r=A.length;for(a=0;a<r;a++)u["@"+A[a]]=1;var A=null;w=!1}else{A=
|
||||
v;continue}p=!1;for(a=0;a<c;a++)if(r=v[a],q="@"+r,(G=u[q]||0)&&G===m){if(l){if(!x||--x<g)if(d[g++]=r,b&&g===b){d=N(f,g+(e||0),d);break a}}else u[q]=m+1;p=!0}if(!p)break}A&&(d=A)}else k&&(d=h[0],e&&(e=parseInt(e[0],10)));b&&(A=d.length,e&&e>A&&(e=0),x=e||0,z=x+b,z<A?d=d.slice(x,z):(z=0,x&&(d=d.slice(x))));d=N(f,z,d)}return d};n.prototype.clear=function(){return this.destroy().init()};n.prototype.destroy=function(){this.h=this.f=this.c=null;return this};(function(){const a=t("\\s+"),b=t("[^a-z0-9 ]"),
|
||||
c=[t("[-/]")," ",b,"",a," "];return function(g){{g=K(g.toLowerCase(),c);let h="",f="";var d="";for(let e=0;e<g.length;e++){const k=g[e];if(k!==f)if(e&&"h"===k){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f)&&d||" "===f)h+=k}else h+=k;d=e===g.length-1?"":g[e+1];f=k}g=h}return g}})();const F={icase:function(a){return a.toLowerCase()}};return n}(!1),this);
|
@@ -8,32 +8,27 @@
|
||||
<h2>Benchmark: flexsearch-0.6.3</h2><hr/>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
|
||||
<!--
|
||||
<script src="../../node_modules/flexsearch/src/config.js"></script>
|
||||
<script type="module" src="../../node_modules/flexsearch/src/bundle.js"></script>
|
||||
-->
|
||||
<script src="flexsearch.light.js"></script>
|
||||
<script src="https://rawcdn.githack.com/nextapps-de/flexsearch/0.6.32/dist/flexsearch.light.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
//import FlexSearch from "../../node_modules/flexsearch/src/bundle.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["flexsearch"] = {
|
||||
suite["flexsearch-0.6.3"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new FlexSearch({
|
||||
|
||||
//encode: "icase",
|
||||
encode: "icase",
|
||||
tokenize: "strict",
|
||||
threshold: 99999,
|
||||
resolution: 99999,
|
||||
resolution: 9,
|
||||
threshold: 8,
|
||||
depth: 1
|
||||
});
|
||||
|
||||
window.test = lib;
|
||||
window["lib"] = lib;
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
@@ -42,6 +37,17 @@
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
lib.remove(id);
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query);
|
||||
|
51
bench/test/flexsearch-0.7.0-context/index.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.7.0</h2><hr/>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
|
||||
<script type="module">
|
||||
|
||||
import Index from "../../../src/index.js";
|
||||
//import Document from "../../../src/document.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["flexsearch-0.7.0-match"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new Index({ context: { depth: 2 } });
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query, 10, { suggest: true });
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.update(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
lib.remove(id);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
57
bench/test/flexsearch-0.7.0-match/index.html
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.7.0</h2><hr/>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
|
||||
<script type="module">
|
||||
|
||||
import Index from "../../../src/index.js";
|
||||
//import Document from "../../../src/document.js";
|
||||
import { encode } from "../../../src/lang/latin/advanced.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
suite["flexsearch-0.7.0-match"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new Index({
|
||||
|
||||
encode: encode,
|
||||
tokenize: "reverse",
|
||||
resolution: 20
|
||||
});
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query, 10, { suggest: true });
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.update(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
lib.remove(id);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
66
bench/test/flexsearch-0.7.0/index.html
Normal file
@@ -0,0 +1,66 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.7.0</h2><hr/>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
|
||||
<script src="../../../dist/flexsearch.light.js"></script>
|
||||
<script type="module">
|
||||
|
||||
//import Index from "../../../src/index.js";
|
||||
//import Document from "../../../src/document.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib, split = /[^a-z]+/;
|
||||
|
||||
suite["flexsearch-0.7.0"] = {
|
||||
|
||||
init: function(){
|
||||
|
||||
lib = new FlexSearch.Index({
|
||||
|
||||
encode: str => str.toLowerCase().split(split),
|
||||
tokenize: "strict",
|
||||
resolution: 1,
|
||||
minlength: 1,
|
||||
optimize: false,
|
||||
fastupdate: false,
|
||||
context: {
|
||||
depth: 1,
|
||||
bidirectional: false,
|
||||
resolution: 1
|
||||
},
|
||||
doc: "body"
|
||||
});
|
||||
},
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.search(query, 9999);
|
||||
},
|
||||
update: function(id){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.update(i, data[i]);
|
||||
}
|
||||
},
|
||||
remove: function(id){
|
||||
|
||||
lib.remove(id);
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -11,7 +11,7 @@
|
||||
<script src="../../dist/flexsearch.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="../../dist/flexsearch.light.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="../../dist/flexsearch.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="../../dist/flexsearch.light.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="../../dist/flexsearch.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
add: function(data){
|
||||
|
||||
for(let i = 0, len = data.length; i < len; i++){
|
||||
|
||||
lib.add(i, data[i]);
|
||||
}
|
||||
},
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="../../dist/flexsearch.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="../../dist/flexsearch.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="../../dist/flexsearch.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
|
@@ -1,54 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Benchmark</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Benchmark: flexsearch-0.7.0</h2><hr/>
|
||||
<h4>Indexed Text: "Gulliver's Travels" (Swift Jonathan 1726)</h4>
|
||||
<div id="result" style="white-space: pre; font-family: Monospaced, monospace"></div>
|
||||
|
||||
<script src="src/config.js"></script>
|
||||
<script type="module" src="src/bundle.js"></script>
|
||||
<!--
|
||||
<script src="../../dist/flexsearch.light.js"></script>
|
||||
-->
|
||||
<script type="module">
|
||||
|
||||
import { encode, split } from "./src/lang/latin/icase.js";
|
||||
import { stemmer, filter } from "./src/lang/de.js";
|
||||
|
||||
let lib = new FlexSearch({
|
||||
|
||||
encode: encode,
|
||||
split: split,
|
||||
stemmer: stemmer,
|
||||
filter: filter,
|
||||
matcher: {
|
||||
"test": "test"
|
||||
},
|
||||
tokenize: "strict",
|
||||
doc: {
|
||||
id: "id",
|
||||
field: "content"
|
||||
}
|
||||
});
|
||||
|
||||
lib.add({
|
||||
id: 0,
|
||||
content: " TESTA TESTA "
|
||||
});
|
||||
|
||||
lib.add({
|
||||
id: 1,
|
||||
content: " TEST TEST "
|
||||
});
|
||||
|
||||
//lib.add(1, " TEST TEST ");
|
||||
|
||||
console.log(lib.search(" test test "));
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -11,7 +11,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/gh/krisk/Fuse@3.3.0/dist/fuse.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
const payload = new Array(length);
|
||||
|
||||
for(let i = 0; i < length; i++){
|
||||
|
||||
payload[i] = {id: i, content: data[i]};
|
||||
}
|
||||
|
||||
lib = new Fuse(payload, {
|
||||
|
||||
keys: ["content"],
|
||||
id: "id",
|
||||
shouldSort: true,
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="https://rawcdn.githack.com/jeancroy/FuzzySearch/cbcdd8307d70a209b1cbf17a535158d5c21840d7/dist/FuzzySearch.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/js-search@1.4.2/dist/umd/js-search.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
const payload = [];
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
|
||||
payload[i] = {id: i, content: data[i]};
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/gh/karussell/jsii@master/web/js/src/JSii.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
@@ -27,7 +27,12 @@
|
||||
const payload = [];
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
payload[i] = {id: i, text: data[i]};
|
||||
|
||||
payload[i] = {
|
||||
|
||||
id: i,
|
||||
text: data[i]
|
||||
};
|
||||
}
|
||||
|
||||
lib.feedDocs(payload);
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/npm/lunr@2.3.5/lunr.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
@@ -21,16 +21,24 @@
|
||||
add: function(data){
|
||||
|
||||
lib = lunr(function(){
|
||||
|
||||
this.ref("id");
|
||||
this.field("content");
|
||||
|
||||
for(let i = 0; i < data.length; i++){
|
||||
this.add({id: i, content: data[i]});
|
||||
|
||||
this.add({
|
||||
|
||||
id: i,
|
||||
content: data[i]
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
query: function(query){
|
||||
|
||||
return lib.query(function(q) {
|
||||
|
||||
q.term(query, { wildcard: lunr.Query.wildcard.LEADING })
|
||||
});
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/gh/kbrsh/wade@0.3.3/dist/wade.min.js"></script>
|
||||
<script type="module">
|
||||
|
||||
import { suite } from "./../../bench.js";
|
||||
import { suite } from "../../bench.js";
|
||||
|
||||
let lib;
|
||||
|
||||
|
@@ -1,9 +1,11 @@
|
||||
<tr>
|
||||
<td>{{data.name}}</td>
|
||||
<td style="background-color:{{data.color_size}}">{{data.size}}</td>
|
||||
<td style="background-color:{{data.color_size}}" hidden>{{data.size}}</td>
|
||||
<td style="background-color:{{data.color_memory}}">{{data.memory}}</td>
|
||||
<td style="background-color:{{data['color_query-single']}}">{{data['query-single']}}</td>
|
||||
<td style="background-color:{{data['color_query-multi']}}">{{data['query-multi']}}</td>
|
||||
<td style="background-color:{{data['color_query-long']}}">{{data['query-long']}}</td>
|
||||
<td style="background-color:{{data['color_query-dupes']}}">{{data['query-dupes']}}</td>
|
||||
<td style="background-color:{{data['color_not-found']}}">{{data['not-found']}}</td>
|
||||
<td style="background-color:{{data.color_index}}"><b>{{data.index}}</b></td>
|
||||
<td style="background-color:{{data.color_score}}"><b>{{data.score}}</b></td>
|
||||
|
@@ -9,6 +9,9 @@ Mikado.register({
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"a": {
|
||||
"hidden": true
|
||||
},
|
||||
"s": [
|
||||
"'background-color:' + data.color_size"
|
||||
],
|
||||
@@ -43,6 +46,24 @@ Mikado.register({
|
||||
"data['query-multi']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
"'background-color:' + data['color_query-long']"
|
||||
],
|
||||
"x": [
|
||||
"data['query-long']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
"'background-color:' + data['color_query-dupes']"
|
||||
],
|
||||
"x": [
|
||||
"data['query-dupes']"
|
||||
]
|
||||
},
|
||||
{
|
||||
"t": "td",
|
||||
"s": [
|
||||
|
26772
data/movies.js
56
dist/flexsearch.bundle.js
vendored
@@ -1,34 +1,34 @@
|
||||
/**!
|
||||
* FlexSearch.js v0.7.0-beta (Bundle)
|
||||
* FlexSearch.js v0.7.0 (Bundle)
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Licence: Apache-2.0
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
(function _f(self){'use strict';try{if(module)self=module}catch(e){}self._factory=_f;var u;function v(a){return"undefined"!==typeof a?a:!0}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=x();return b}function x(){return Object.create(null)}function aa(a,b){return b.length-a.length}function B(a){return"string"===typeof a}function D(a){return"object"===typeof a}function E(a){return"function"===typeof a};const ba=/[\u0300-\u036f]/g;function ca(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function da(a,b){const c=Object.keys(a),d=c.length,e=[];let f="",g=0;for(let h=0,k,m;h<d;h++)k=c[h],(m=a[k])?(e[g++]=F(b?"(?!\\b)"+k+"(\\b|_)":k),e[g++]=m):f+=(f?"|":"")+k;f&&(e[g++]=F(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function G(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function F(a){return new RegExp(a,"g")}
|
||||
function ea(a){let b="",c="";for(let d=0,e=a.length,f;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b};var ha={encode:fa,B:!1,C:""};const ia=/[\W_]+/;function fa(a){return ja(this,ca(a).toLowerCase(),!1,ia)};const ka={},H={};function la(a){I(a,"add");I(a,"append");I(a,"search");I(a,"update");I(a,"remove")}function I(a,b){a[b+"Async"]=function(){const c=this,d=arguments;var e=d[d.length-1];let f;E(e)&&(f=e,delete d[d.length-1]);e=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,d);c.async=!1;g(h)})});return f?(e.then(f),this):e}};function ma(a,b,c,d){var e=a.length;let f=[],g,h,k=0;d&&(d=[]);for(--e;0<=e;e--){const m=a[e],n=m.length,r=x();let t=!g;for(let q=0;q<n;q++){const l=m[q],p=l.length;if(p)for(let y=0,z,A;y<p;y++)if(A=l[y],g){if(g[A]){if(!e)if(c)c--;else if(f[k++]=A,k===b)return f;if(e||d)r[A]=1;t=!0}if(d&&(h[A]=(z=h[A])?z++:z=1,z<n)){const C=d[z-1]||(d[z-1]=[]);C[C.length]=A}}else r[A]=1}if(d)g||(h=r);else if(!t)return[];g=r}if(d)for(let m=d.length-1,n,r;0<=m;m--){n=d[m];r=n.length;for(let t=0,q;t<r;t++)if(q=n[t],
|
||||
!g[q]){if(c)c--;else if(f[k++]=q,k===b)return f;g[q]=1}}return f}function na(a,b){const c=x(),d=x(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!d[k]&&(d[k]=1,e[e.length]=k)}return e};function J(a){this.l=!0!==a&&a;this.cache=x();this.h=[]}function oa(a,b,c){D(a)&&(a=a.query);let d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}J.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};J.prototype.get=function(a){const b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){const c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};const ra={memory:{charset:"latin:extra",D:3,A:3,o:!1,s:"memory"},performance:{threshold:8,A:3,context:{depth:1,F:!0}},match:{charset:"latin:extra",C:"full",D:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,F:!0}},"default":{D:3,threshold:0,depth:3}};function sa(a,b,c,d,e,f){setTimeout(function(){const g=a(c,JSON.stringify(f));g&&g.then?g.then(function(){b.export(a,b,c,d,e+1)}):b.export(a,b,c,d,e+1)})};function K(a,b){if(!(this instanceof K))return new K(a);var c;if(a){B(a)?a=ra[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;B(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=H[c]);B(d)&&(d=ka[d])}else a={};let e,f,g=a.context||{};this.encode=a.encode||c&&c.encode||fa;this.register=b||x();this.D=e=a.resolution||9;this.C=b=c&&c.C||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.F=v(g.bidirectional);this.s=f=v(a.optimize);this.o=v(a.fastupdate);this.A=a.minlength||1;this.map=
|
||||
f?w(e):x();this.l=e=g.resolution||1;this.h=f?w(e):x();this.B=c&&c.B||a.rtl;this.I=(b=a.matcher||d&&d.I)&&da(b,!1);this.K=(b=a.stemmer||d&&d.K)&&da(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=x();for(let h=0,k=c.length;h<k;h++)d[c[h]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new J(b)}
|
||||
function ja(a,b,c,d){if(b&&(c&&(b=G(b,c)),a.I&&(b=G(b,a.I)),a.K&&1<b.length&&(b=G(b,a.K)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(let e=0,f=0;e<c;e++){const g=b[e];g&&!a[g]&&(d[f++]=g)}a=d}else a=b;return a}return b}u=K.prototype;u.append=function(a,b){return this.add(a,b,!0)};
|
||||
u.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){const m=this.depth,n=this.D,r=x(),t=x();for(let q=0;q<d;q++){let l=b[this.B?d-1-q:q];var e=l.length;if(l&&e>=this.A&&(m||!r[l])){var f=L(n,d,q),g="";switch(this.C){case "full":if(3<e){for(f=0;f<e;f++)for(var h=e;h>f;h--)if(h-f>=this.A){var k=L(n,d,q,e,f);g=l.substring(f,h);M(this,r,g,k,a,c)}break}case "reverse":if(2<e){for(h=e-1;0<h;h--)g=l[h]+g,g.length>=this.A&&M(this,r,g,
|
||||
L(n,d,q,e,h),a,c);g=""}case "forward":if(1<e)for(h=0;h<e;h++)g+=l[h],g.length>=this.A&&M(this,r,g,f,a,c);break;default:if(M(this,r,l,f,a,c),m&&1<d&&q<d-1)for(e=this.l,g=x(),f=l,h=Math.min(m+1,d-q),g[f]=1,k=1;k<h;k++)if((l=b[this.B?d-1-q-k:q+k])&&l.length>=this.A&&!g[l]){g[l]=1;const p=this.F&&l>f;M(this,t,p?f:l,L(e+(d/2>e?0:1),d,q,h-1,k-1),a,c,p?l:f)}}}}this.o||(this.register[a]=1)}return this};function L(a,b,c,d,e){return c&&1<a?b+(d||0)<=a?c+(e||0):(a-1)/(b+(d||0))*(c+(e||0))+1|0:0}
|
||||
function M(a,b,c,d,e,f,g){let h=g?a.h:a.map;if(!b[c]||g&&!b[c][g])a.s&&(h=h[d]),g?(b=b[c]||(b[c]=x()),b[g]=1,h=h[g]||(h[g]=x())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[d]||(h[d]=[])),f&&-1!==h.indexOf(e)||(h[h.length]=e,a.o&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=h))}
|
||||
u.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);let d=[],e;let f,g=0;if(c){b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(a),e=a.length,1<e)){c=x();var k=[];for(let n=0,r=0,t;n<e;n++)if((t=a[n])&&t.length>=this.A&&!c[t])if(this.s||f||this.map[t])k[r++]=t,c[t]=1;else return d;a=k;e=a.length}if(!e)return d;b||(b=100);h=this.depth&&1<e&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<e&&a.sort(aa);for(let n,r;c<e;c++){r=a[c];h?(n=ta(this,d,f,b,g,2===e,r,m),f&&!1===n&&d.length||
|
||||
(m=r)):n=ta(this,d,f,b,g,1===e,r);if(n)return n;if(f&&c===e-1){k=d.length;if(!k){if(h){h=0;c=-1;continue}return d}if(1===k)return ua(d[0],b,g)}}return ma(d,b,g,f)};
|
||||
function ta(a,b,c,d,e,f,g,h){let k=[],m=h?a.h:a.map;a.s||(m=va(m,g,h,a.F));if(m){let n=0;const r=Math.min(m.length,h?a.l:a.D);for(let t=0,q=0,l,p;t<r;t++)if(l=m[t])if(a.s&&(l=va(l,g,h,a.F)),e&&l&&f&&(p=l.length,p<=e?(e-=p,l=null):(l=l.slice(e),e=0)),l&&(k[n++]=l,f&&(q+=l.length,q>=d)))break;if(n){if(f)return ua(k,d,0);b[b.length]=k;return}}return!c&&k}function ua(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
|
||||
function va(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
u.remove=function(a,b){const c=this.register[a];if(c){if(this.o)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else N(this.map,a,this.D,this.s),this.depth&&N(this.h,a,this.l,this.s);b||delete this.register[a];if(this.cache){b=this.cache;for(let d=0,e,f;d<b.h.length;d++)f=b.h[d],e=b.cache[f],-1!==e.indexOf(a)&&(b.h.splice(d--,1),delete b.cache[f])}}return this};
|
||||
function N(a,b,c,d,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,c);for(let g=0,h;g<e;g++)if(h=a[g])f=N(h,b,c,d,e),d||f||delete a[g]}else for(let g in a)(f=N(a[g],b,c,d,e))||delete a[g];return f}u.searchCache=oa;
|
||||
u.export=function(a,b,c,d,e){let f,g;switch(e||(e=0)){case 0:f="reg";if(this.o){g=x();for(let h in this.register)g[h]=1}else g=this.register;break;case 1:f="cfg";g={doc:0,opt:this.s?1:0};break;case 2:f="map";g=this.map;break;case 3:f="ctx";g=this.h;break;default:return}sa(a,b||this,c?c+"."+f:f,d,e,g);return!0};u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "cfg":this.s=!!b.opt;break;case "reg":this.o=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};la(K.prototype);function wa(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new K(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let xa=0;function O(a){var b;a?E(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());const c=self.exports,d=this;this.m=ya(b,c,a.worker);this.h=x();if(this.m){if(c)this.m.on("message",function(e){d.h[e.id](e.msg);delete d.h[e.id]});else this.m.onmessage=function(e){e=e.data;d.h[e.id](e.msg);delete d.h[e.id]};this.m.postMessage({task:"init",factory:b,options:a})}}P("add");P("append");P("search");P("update");P("remove");
|
||||
function P(a){O.prototype[a]=O.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;E(d)&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){setTimeout(function(){b.h[++xa]=f;b.m.postMessage({task:a,id:xa,args:c})})});return e?(d.then(e),this):d}}
|
||||
function ya(a,b,c){let d;try{d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+wa.toString()],{type:"text/javascript"}))):new Worker(B(c)?c:"worker/worker.js",{type:"module"})}catch(e){}return d};function R(a){if(!(this instanceof R))return new R(a);var b=a.document||a.doc||a,c;this.L=[];this.h=[];this.G=[];this.register=x();this.key=(c=b.key||b.id)&&S(c,this.G)||"id";this.o=v(a.fastupdate);this.H=(c=b.store)&&!0!==c&&[];this.store=c&&x();this.J=(c=b.tag)&&S(c,this.G);this.l=c&&x();this.cache=(c=a.cache)&&new J(c);a.cache=!1;this.m=a.worker;this.async=!1;c=x();let d=b.index||b.field||b;B(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],B(f)||(g=f,f=f.field),g=D(g)?Object.assign({},a,g):a,
|
||||
this.m&&(c[f]=new O(g),c[f].m||(this.m=!1)),this.m||(c[f]=new K(g,this.register)),this.L[e]=S(f,this.G),this.h[e]=f;if(this.H)for(a=b.store,B(a)&&(a=[a]),b=0;b<a.length;b++)this.H[b]=S(a[b],this.G);this.index=c}function S(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function T(a,b){if(B(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
|
||||
function U(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)U(a,b,c,d,e);else b=b[e]||(b[e]=x()),e=c[++d],U(a,b,c,d,e)}function V(a,b,c,d,e,f,g,h){a=a[g];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)V(a,b,c,d,e,f,g,h);else g=b[++d],V(a,b,c,d,e,f,g,h)}u=R.prototype;
|
||||
u.add=function(a,b,c){D(a)&&(b=a,a=T(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let d=0,e,f;d<this.h.length;d++)f=this.h[d],e=this.L[d],B(e)&&(e=[e]),V(b,e,this.G,0,this.index[f],a,e[0],c);if(this.J){let d=T(b,this.J),e=x();B(d)&&(d=[d]);for(let f=0,g,h;f<d.length;f++)if(g=d[f],!e[g]&&(e[g]=1,h=this.l[g]||(this.l[g]=[]),!c||-1===h.indexOf(a)))if(h[h.length]=a,this.o){const k=this.register[a]||(this.register[a]=[]);k[k.length]=h}}if(this.store){let d;if(this.H){d=
|
||||
x();for(let e=0,f;e<this.H.length;e++)f=this.H[e],B(f)?d[f]=b[f]:U(b,d,f,0,f[0])}this.store[a]=d||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
u.remove=function(a){D(a)&&(a=T(a,this.key));if(this.register[a]){var b=this.o&&!this.m;for(var c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);if(this.J&&!b)for(let d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&delete this.store[a];delete this.register[a]}return this};
|
||||
u.search=function(a,b,c,d){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);let e=[],f=[],g,h,k,m,n,r,t=0;if(c)if(c.constructor===Array)k=c,c=null;else{k=(g=c.pluck)||c.index||c.field||c;m=c.tag;h=this.store&&c.enrich;n="and"===c.bool;b=c.limit||100;r=c.offset||0;if(m&&(B(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=za.call(this,m[l],b,r,h))e[e.length]=p,t++;return t?e:[]}B(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const q=!d&&(this.m||this.async)&&[];for(let l=
|
||||
0,p,y,z;l<k.length;l++){let A;y=k[l];B(y)||(A=y,y=y.field);if(q)q[l]=this.index[y].searchAsync(a,b,A||c);else{d?p=d[l]:p=this.index[y].search(a,b,A||c);z=p&&p.length;if(m&&z){const C=[];let pa=0;n&&(C[0]=[p]);for(let W=0,qa,Q;W<m.length;W++)if(qa=m[W],z=(Q=this.l[qa])&&Q.length)pa++,C[C.length]=n?[Q]:Q;pa&&(p=n?ma(C,b||100,r||0):na(p,C),z=p.length)}if(z)f[t]=y,e[t++]=p;else if(n)return[]}}if(q){const l=this;return new Promise(function(p){Promise.all(q).then(function(y){p(l.search(a,b,c,y))})})}if(!t)return[];
|
||||
if(g&&(!h||!this.store))return e[0];for(let l=0,p;l<f.length;l++){p=e[l];p.length&&h&&(p=Aa.call(this,p));if(g)return p;e[l]={field:f[l],result:p}}return e};function za(a,b,c,d){let e=this.l[a],f=e&&e.length-c;if(f&&0<f){if(f>b||c)e=e.slice(c,c+b);d&&(e=Aa.call(this,e));return{tag:a,result:e}}}function Aa(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
|
||||
u.set=function(a,b){this.store[a]=b;return this};u.searchCache=oa;u.export=function(a,b,c,d,e){e||(e=0);d||(d=0);if(d<this.h.length){const f=this.h[d],g=this.index[f];b=this;setTimeout(function(){g.export(a,b,e?f.replace(":","-"):"",d,e++)||(d++,e=1,b.export(a,b,f,d,e))})}else{let f;switch(e){case 1:c="tag";f=this.l;break;case 2:c="store";f=this.store;break;default:return}sa(a,this,c,d,e,f)}};
|
||||
u.import=function(a,b){if(b)switch(B(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.o=!1;this.register=b;for(let d=0,e;d<this.h.length;d++)e=this.index[this.h[d]],e.register=b,e.o=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};la(R.prototype);var Ca={encode:Ba,B:!1,C:""};const Da=/[\W_]+/,Ea=[F("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",F("[\u00e8\u00e9\u00ea\u00eb]"),"e",F("[\u00ec\u00ed\u00ee\u00ef]"),"i",F("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",F("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",F("[\u00fd\u0177\u00ff]"),"y",F("\u00f1"),"n",F("[\u00e7c]"),"k",F("\u00df"),"s",F(" & ")," and "];function Ba(a){return ja(this,ca(a).toLowerCase(),!a.normalize&&Ea,Da)};var Ga={encode:Fa,B:!1,C:"strict"};const Ha=/[^a-z0-9]+/,Ia={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Fa(a){a=Ba.call(this,a).join(" ");const b=[];if(a){const c=a.split(Ha),d=c.length;for(let e=0,f,g=0;e<d;e++)if((a=c[e])&&(!this.filter||!this.filter[a])){f=a[0];let h=Ia[f]||f,k=h;for(let m=1;m<a.length;m++){f=a[m];const n=Ia[f]||f;n&&n!==k&&(h+=n,k=n)}b[g++]=h}}return b};var Ka={encode:Ja,B:!1,C:""};const La=[F("ae"),"a",F("oe"),"o",F("sh"),"s",F("th"),"t",F("ph"),"f",F("pf"),"f"];function Ja(a,b){a&&(a=Fa.call(this,a).join(" "),2<a.length&&(a=G(a,La)),b||(1<a.length&&(a=ea(a)),a&&(a=a.split(" "))));return a};var Na={encode:Ma,B:!1,C:""};const Oa=F("(?!\\b)[aeiouy]");function Ma(a){a&&(a=Ja.call(this,a,!0),1<a.length&&(a=a.replace(Oa,"")),1<a.length&&(a=ea(a)),a&&(a=a.split(" ")));return a};H["latin:default"]=ha;H["latin:simple"]=Ca;H["latin:balance"]=Ga;H["latin:advanced"]=Ka;H["latin:extra"]=Na;const X=self;let Y;const Z={Index:K,Document:R,Worker:O,registerCharset:function(a,b){H[a]=b},registerLanguage:function(a,b){ka[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));
|
||||
(function _f(self){'use strict';try{if(module)self=module}catch(e){}self._factory=_f;var t;function u(a){return"undefined"!==typeof a?a:!0}function aa(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=v();return b}function v(){return Object.create(null)}function ba(a,b){return b.length-a.length}function x(a){return"string"===typeof a}function C(a){return"object"===typeof a}function D(a){return"function"===typeof a};const ca=/[\u0300-\u036f]/g;function da(a){a.normalize&&(a=a.normalize("NFD").replace(ca,""));return a}function ea(a,b){const c=Object.keys(a),d=c.length,e=[];let f="",g=0;for(let h=0,k,m;h<d;h++)k=c[h],(m=a[k])?(e[g++]=E(b?"(?!\\b)"+k+"(\\b|_)":k),e[g++]=m):f+=(f?"|":"")+k;f&&(e[g++]=E(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]="");return e}function F(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function E(a){return new RegExp(a,"g")}
|
||||
function fa(a){let b="",c="";for(let d=0,e=a.length,f;d<e;d++)(f=a[d])!==c&&(b+=c=f);return b};var ia={encode:ha,B:!1,C:""};const ja=/[\W_]+/;function ha(a){return ka(this,da(a).toLowerCase(),!1,ja)};const la={},H={};function ma(a){I(a,"add");I(a,"append");I(a,"search");I(a,"update");I(a,"remove")}function I(a,b){a[b+"Async"]=function(){const c=this,d=arguments;var e=d[d.length-1];let f;D(e)&&(f=e,delete d[d.length-1]);e=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,d);c.async=!1;g(h)})});return f?(e.then(f),this):e}};function na(a,b,c,d){const e=a.length;let f=[],g,h,k=0;d&&(d=[]);for(let m=e-1;0<=m;m--){const n=a[m],w=n.length,q=v();let r=!g;for(let l=0;l<w;l++){const p=n[l],z=p.length;if(z)for(let B=0,A,y;B<z;B++)if(y=p[B],g){if(g[y]){if(!m)if(c)c--;else if(f[k++]=y,k===b)return f;if(m||d)q[y]=1;r=!0}if(d&&(h[y]=(A=h[y])?++A:A=1,A<e)){const G=d[A-2]||(d[A-2]=[]);G[G.length]=y}}else q[y]=1}if(d)g||(h=q);else if(!r)return[];g=q}if(d)for(let m=d.length-1,n,w;0<=m;m--){n=d[m];w=n.length;for(let q=0,r;q<w;q++)if(r=
|
||||
n[q],!g[r]){if(c)c--;else if(f[k++]=r,k===b)return f;g[r]=1}}return f}function oa(a,b){const c=v(),d=v(),e=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!d[k]&&(d[k]=1,e[e.length]=k)}return e};function J(a){this.l=!0!==a&&a;this.cache=v();this.h=[]}function pa(a,b,c){C(a)&&(a=a.query);let d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}J.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};J.prototype.get=function(a){const b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){const c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};const ra={memory:{charset:"latin:extra",D:3,A:3,m:!1,s:"memory"},performance:{threshold:8,A:3,context:{depth:1,F:!0}},match:{charset:"latin:extra",C:"full",D:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,F:!0}},"default":{D:3,threshold:0,depth:3}};function sa(a,b,c,d,e,f){setTimeout(function(){const g=a(c,JSON.stringify(f));g&&g.then?g.then(function(){b.export(a,b,c,d,e+1)}):b.export(a,b,c,d,e+1)})};function K(a,b){if(!(this instanceof K))return new K(a);var c;if(a){x(a)?a=ra[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;x(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=H[c]);x(d)&&(d=la[d])}else a={};let e,f,g=a.context||{};this.encode=a.encode||c&&c.encode||ha;this.register=b||v();this.D=e=a.resolution||9;this.C=b=c&&c.C||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.F=u(g.bidirectional);this.s=f=u(a.optimize);this.m=u(a.fastupdate);this.A=a.minlength||1;this.map=
|
||||
f?aa(e):v();this.l=e=g.resolution||1;this.h=f?aa(e):v();this.B=c&&c.B||a.rtl;this.I=(b=a.matcher||d&&d.I)&&ea(b,!1);this.K=(b=a.stemmer||d&&d.K)&&ea(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=v();for(let h=0,k=c.length;h<k;h++)d[c[h]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new J(b)}
|
||||
function ka(a,b,c,d){if(b&&(c&&(b=F(b,c)),a.I&&(b=F(b,a.I)),a.K&&1<b.length&&(b=F(b,a.K)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(let e=0,f=0;e<c;e++){const g=b[e];g&&!a[g]&&(d[f++]=g)}a=d}else a=b;return a}return b}t=K.prototype;t.append=function(a,b){return this.add(a,b,!0)};
|
||||
t.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(d=b.length){const m=v(),n=v(),w=this.depth,q=this.D;for(let r=0;r<d;r++){let l=b[this.B?d-1-r:r];var e=l.length;if(l&&e>=this.A&&(w||!n[l])){var f=L(q,d,r),g="";switch(this.C){case "full":if(3<e){for(f=0;f<e;f++)for(var h=e;h>f;h--)if(h-f>=this.A){var k=L(q,d,r,e,f);g=l.substring(f,h);M(this,n,g,k,a,c)}break}case "reverse":if(2<e){for(h=e-1;0<h;h--)g=l[h]+g,g.length>=this.A&&M(this,n,
|
||||
g,L(q,d,r,e,h),a,c);g=""}case "forward":if(1<e){for(h=0;h<e;h++)g+=l[h],g.length>=this.A&&M(this,n,g,f,a,c);break}default:if(M(this,n,l,f,a,c),w&&1<d&&r<d-1)for(e=v(),g=this.l,f=l,h=Math.min(w+1,d-r),e[f]=1,k=1;k<h;k++)if((l=b[this.B?d-1-r-k:r+k])&&l.length>=this.A&&!e[l]){e[l]=1;const p=this.F&&l>f;M(this,m,p?f:l,L(g+(d/2>g?0:1),d,r,h-1,k-1),a,c,p?l:f)}}}}this.m||(this.register[a]=1)}}return this};function L(a,b,c,d,e){return c&&1<a?b+(d||0)<=a?c+(e||0):(a-1)/(b+(d||0))*(c+(e||0))+1|0:0}
|
||||
function M(a,b,c,d,e,f,g){let h=g?a.h:a.map;if(!b[c]||g&&!b[c][g])a.s&&(h=h[d]),g?(b=b[c]||(b[c]=v()),b[g]=1,h=h[g]||(h[g]=v())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[d]||(h[d]=[])),f&&-1!==h.indexOf(e)||(h[h.length]=e,a.m&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=h))}
|
||||
t.search=function(a,b,c){C(a)?(c=a,a=c.query):C(b)&&(c=b);let d=[],e;let f,g=0;if(c){b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(a),e=a.length,1<e)){c=v();var k=[];for(let n=0,w=0,q;n<e;n++)if((q=a[n])&&q.length>=this.A&&!c[q])if(this.s||f||this.map[q])k[w++]=q,c[q]=1;else return d;a=k;e=a.length}if(!e)return d;b||(b=100);h=this.depth&&1<e&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<e&&a.sort(ba);for(let n,w;c<e;c++){w=a[c];h?(n=ta(this,d,f,b,g,2===e,w,m),f&&!1===n&&d.length||
|
||||
(m=w)):n=ta(this,d,f,b,g,1===e,w);if(n)return n;if(f&&c===e-1){k=d.length;if(!k){if(h){h=0;c=-1;continue}return d}if(1===k)return ua(d[0],b,g)}}return na(d,b,g,f)};
|
||||
function ta(a,b,c,d,e,f,g,h){let k=[],m=h?a.h:a.map;a.s||(m=va(m,g,h,a.F));if(m){let n=0;const w=Math.min(m.length,h?a.l:a.D);for(let q=0,r=0,l,p;q<w;q++)if(l=m[q])if(a.s&&(l=va(l,g,h,a.F)),e&&l&&f&&(p=l.length,p<=e?(e-=p,l=null):(l=l.slice(e),e=0)),l&&(k[n++]=l,f&&(r+=l.length,r>=d)))break;if(n){if(f)return ua(k,d,0);b[b.length]=k;return}}return!c&&k}function ua(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
|
||||
function va(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}t.contain=function(a){return!!this.register[a]};t.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
t.remove=function(a,b){const c=this.register[a];if(c){if(this.m)for(let d=0,e;d<c.length;d++)e=c[d],e.splice(e.indexOf(a),1);else N(this.map,a,this.D,this.s),this.depth&&N(this.h,a,this.l,this.s);b||delete this.register[a];if(this.cache){b=this.cache;for(let d=0,e,f;d<b.h.length;d++)f=b.h[d],e=b.cache[f],-1!==e.indexOf(a)&&(b.h.splice(d--,1),delete b.cache[f])}}return this};
|
||||
function N(a,b,c,d,e){let f=0;if(a.constructor===Array)if(e)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{e=Math.min(a.length,c);for(let g=0,h;g<e;g++)if(h=a[g])f=N(h,b,c,d,e),d||f||delete a[g]}else for(let g in a)(f=N(a[g],b,c,d,e))||delete a[g];return f}t.searchCache=pa;
|
||||
t.export=function(a,b,c,d,e){let f,g;switch(e||(e=0)){case 0:f="reg";if(this.m){g=v();for(let h in this.register)g[h]=1}else g=this.register;break;case 1:f="cfg";g={doc:0,opt:this.s?1:0};break;case 2:f="map";g=this.map;break;case 3:f="ctx";g=this.h;break;default:return}sa(a,b||this,c?c+"."+f:f,d,e,g);return!0};t.import=function(a,b){if(b)switch(x(b)&&(b=JSON.parse(b)),a){case "cfg":this.s=!!b.opt;break;case "reg":this.m=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};ma(K.prototype);function wa(a){a=a.data;var b=self._index;const c=a.args;var d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new K(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};let xa=0;function O(a){var b;a?D(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());const c=self.exports,d=this;this.o=ya(b,c,a.worker);this.h=v();if(this.o){if(c)this.o.on("message",function(e){d.h[e.id](e.msg);delete d.h[e.id]});else this.o.onmessage=function(e){e=e.data;d.h[e.id](e.msg);delete d.h[e.id]};this.o.postMessage({task:"init",factory:b,options:a})}}P("add");P("append");P("search");P("update");P("remove");
|
||||
function P(a){O.prototype[a]=O.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments);var d=c[c.length-1];let e;D(d)&&(e=d,c.splice(c.length-1,1));d=new Promise(function(f){setTimeout(function(){b.h[++xa]=f;b.o.postMessage({task:a,id:xa,args:c})})});return e?(d.then(e),this):d}}
|
||||
function ya(a,b,c){let d;try{d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+wa.toString()],{type:"text/javascript"}))):new Worker(x(c)?c:"worker/worker.js",{type:"module"})}catch(e){}return d};function Q(a){if(!(this instanceof Q))return new Q(a);var b=a.document||a.doc||a,c;this.L=[];this.h=[];this.G=[];this.register=v();this.key=(c=b.key||b.id)&&S(c,this.G)||"id";this.m=u(a.fastupdate);this.H=(c=b.store)&&!0!==c&&[];this.store=c&&v();this.J=(c=b.tag)&&S(c,this.G);this.l=c&&v();this.cache=(c=a.cache)&&new J(c);a.cache=!1;this.o=a.worker;this.async=!1;c=v();let d=b.index||b.field||b;x(d)&&(d=[d]);for(let e=0,f,g;e<d.length;e++)f=d[e],x(f)||(g=f,f=f.field),g=C(g)?Object.assign({},a,g):a,
|
||||
this.o&&(c[f]=new O(g),c[f].o||(this.o=!1)),this.o||(c[f]=new K(g,this.register)),this.L[e]=S(f,this.G),this.h[e]=f;if(this.H)for(a=b.store,x(a)&&(a=[a]),b=0;b<a.length;b++)this.H[b]=S(a[b],this.G);this.index=c}function S(a,b){const c=a.split(":");let d=0;for(let e=0;e<c.length;e++)a=c[e],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function T(a,b){if(x(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
|
||||
function U(a,b,c,d,e){a=a[e];if(d===c.length-1)b[e]=a;else if(a)if(a.constructor===Array)for(b=b[e]=Array(a.length),e=0;e<a.length;e++)U(a,b,c,d,e);else b=b[e]||(b[e]=v()),e=c[++d],U(a,b,c,d,e)}function V(a,b,c,d,e,f,g,h){a=a[g];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)e.add(f,a[b],!0,!0);return}a=a.join(" ")}e.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)V(a,b,c,d,e,f,g,h);else g=b[++d],V(a,b,c,d,e,f,g,h)}t=Q.prototype;
|
||||
t.add=function(a,b,c){C(a)&&(b=a,a=T(b,this.key));if(b&&(a||0===a)){if(!c&&this.register[a])return this.update(a,b);for(let d=0,e,f;d<this.h.length;d++)f=this.h[d],e=this.L[d],x(e)&&(e=[e]),V(b,e,this.G,0,this.index[f],a,e[0],c);if(this.J){let d=T(b,this.J),e=v();x(d)&&(d=[d]);for(let f=0,g,h;f<d.length;f++)if(g=d[f],!e[g]&&(e[g]=1,h=this.l[g]||(this.l[g]=[]),!c||-1===h.indexOf(a)))if(h[h.length]=a,this.m){const k=this.register[a]||(this.register[a]=[]);k[k.length]=h}}if(this.store&&(!c||!this.store[a])){let d;
|
||||
if(this.H){d=v();for(let e=0,f;e<this.H.length;e++)f=this.H[e],x(f)?d[f]=b[f]:U(b,d,f,0,f[0])}this.store[a]=d||b}}return this};t.append=function(a,b){return this.add(a,b,!0)};t.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
t.remove=function(a){C(a)&&(a=T(a,this.key));if(this.register[a]){for(var b=0;b<this.h.length&&(this.index[this.h[b]].remove(a,!this.o),!this.m);b++);if(this.J&&!this.m)for(let c in this.l){b=this.l[c];const d=b.indexOf(a);-1!==d&&(1<b.length?b.splice(d,1):delete this.l[c])}this.store&&delete this.store[a];delete this.register[a]}return this};
|
||||
t.search=function(a,b,c,d){C(a)?(c=a,a=c.query):C(b)&&(c=b,b=0);let e=[],f=[],g,h,k,m,n,w,q=0;if(c)if(c.constructor===Array)k=c,c=null;else{k=(g=c.pluck)||c.index||c.field||c;m=c.tag;h=this.store&&c.enrich;n="and"===c.bool;b=c.limit||100;w=c.offset||0;if(m&&(x(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=za.call(this,m[l],b,w,h))e[e.length]=p,q++;return q?e:[]}x(k)&&(k=[k])}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const r=!d&&(this.o||this.async)&&[];for(let l=0,p,z,B;l<k.length;l++){let A;
|
||||
z=k[l];x(z)||(A=z,z=z.field);if(r)r[l]=this.index[z].searchAsync(a,b,A||c);else{d?p=d[l]:p=this.index[z].search(a,b,A||c);B=p&&p.length;if(m&&B){const y=[];let G=0;n&&(y[0]=[p]);for(let X=0,qa,R;X<m.length;X++)if(qa=m[X],B=(R=this.l[qa])&&R.length)G++,y[y.length]=n?[R]:R;G&&(p=n?na(y,b||100,w||0):oa(p,y),B=p.length)}if(B)f[q]=z,e[q++]=p;else if(n)return[]}}if(r){const l=this;return new Promise(function(p){Promise.all(r).then(function(z){p(l.search(a,b,c,z))})})}if(!q)return[];if(g&&(!h||!this.store))return e[0];
|
||||
for(let l=0,p;l<f.length;l++){p=e[l];p.length&&h&&(p=Aa.call(this,p));if(g)return p;e[l]={field:f[l],result:p}}return e};function za(a,b,c,d){let e=this.l[a],f=e&&e.length-c;if(f&&0<f){if(f>b||c)e=e.slice(c,c+b);d&&(e=Aa.call(this,e));return{tag:a,result:e}}}function Aa(a){const b=Array(a.length);for(let c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}t.contain=function(a){return!!this.register[a]};t.get=function(a){return this.store[a]};t.set=function(a,b){this.store[a]=b;return this};
|
||||
t.searchCache=pa;t.export=function(a,b,c,d,e){e||(e=0);d||(d=0);if(d<this.h.length){const f=this.h[d],g=this.index[f];b=this;setTimeout(function(){g.export(a,b,e?f.replace(":","-"):"",d,e++)||(d++,e=1,b.export(a,b,f,d,e))})}else{let f;switch(e){case 1:c="tag";f=this.l;break;case 2:c="store";f=this.store;break;default:return}sa(a,this,c,d,e,f)}};
|
||||
t.import=function(a,b){if(b)switch(x(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.m=!1;this.register=b;for(let d=0,e;d<this.h.length;d++)e=this.index[this.h[d]],e.register=b,e.m=!1;break;case "store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1];c&&a&&this.index[c].import(a,b)}};ma(Q.prototype);var Ca={encode:Ba,B:!1,C:""};const Da=/[\W_]+/,Ea=[E("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",E("[\u00e8\u00e9\u00ea\u00eb]"),"e",E("[\u00ec\u00ed\u00ee\u00ef]"),"i",E("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",E("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",E("[\u00fd\u0177\u00ff]"),"y",E("\u00f1"),"n",E("[\u00e7c]"),"k",E("\u00df"),"s",E(" & ")," and "];function Ba(a){return ka(this,da(a).toLowerCase(),!a.normalize&&Ea,Da)};var Ga={encode:Fa,B:!1,C:"strict"};const Ha=/[^a-z0-9]+/,Ia={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Fa(a){a=Ba.call(this,a).join(" ");const b=[];if(a){const c=a.split(Ha),d=c.length;for(let e=0,f,g=0;e<d;e++)if((a=c[e])&&(!this.filter||!this.filter[a])){f=a[0];let h=Ia[f]||f,k=h;for(let m=1;m<a.length;m++){f=a[m];const n=Ia[f]||f;n&&n!==k&&(h+=n,k=n)}b[g++]=h}}return b};var Ka={encode:Ja,B:!1,C:""};const La=[E("ae"),"a",E("oe"),"o",E("sh"),"s",E("th"),"t",E("ph"),"f",E("pf"),"f",E("(?![aeo])h(?![aeo])"),"",E("(?!^[aeo])h(?!^[aeo])"),""];function Ja(a,b){a&&(a=Fa.call(this,a).join(" "),2<a.length&&(a=F(a,La)),b||(1<a.length&&(a=fa(a)),a&&(a=a.split(" "))));return a};var Na={encode:Ma,B:!1,C:""};const Oa=E("(?!\\b)[aeo]");function Ma(a){a&&(a=Ja.call(this,a,!0),1<a.length&&(a=a.replace(Oa,"")),1<a.length&&(a=fa(a)),a&&(a=a.split(" ")));return a};H["latin:default"]=ia;H["latin:simple"]=Ca;H["latin:balance"]=Ga;H["latin:advanced"]=Ka;H["latin:extra"]=Na;const W=self;let Y;const Z={Index:K,Document:Q,Worker:O,registerCharset:function(a,b){H[a]=b},registerLanguage:function(a,b){la[a]=b}};(Y=W.define)&&Y.amd?Y([],function(){return Z}):W.exports?W.exports=Z:W.FlexSearch=Z;}(this));
|
||||
|
42
dist/flexsearch.compact.js
vendored
@@ -1,28 +1,28 @@
|
||||
/**!
|
||||
* FlexSearch.js v0.7.0-beta (Compact)
|
||||
* FlexSearch.js v0.7.0 (Compact)
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Licence: Apache-2.0
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
(function(self){'use strict';var u;function v(a){return"undefined"!==typeof a?a:!0}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=y();return b}function y(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a};const ba=/[\u0300-\u036f]/g;function E(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function F(a,b){const c=Object.keys(a),e=c.length,d=[];let f="",g=0;for(let h=0,k,m;h<e;h++)k=c[h],(m=a[k])?(d[g++]=G(b?"(?!\\b)"+k+"(\\b|_)":k),d[g++]=m):f+=(f?"|":"")+k;f&&(d[g++]=G(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),d[g]="");return d}function H(a,b){for(let c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function G(a){return new RegExp(a,"g")}
|
||||
function I(a){let b="",c="";for(let e=0,d=a.length,f;e<d;e++)(f=a[e])!==c&&(b+=c=f);return b};var ca={encode:J,A:!1,B:""};const da=/[\W_]+/;function J(a){return K(this,E(a).toLowerCase(),!1,da)};const ea={},L={};function fa(a){N(a,"add");N(a,"append");N(a,"search");N(a,"update");N(a,"remove")}function N(a,b){a[b+"Async"]=function(){const c=this,e=arguments;var d=e[e.length-1];let f;"function"===typeof d&&(f=d,delete e[e.length-1]);d=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,e);c.async=!1;g(h)})});return f?(d.then(f),this):d}};function ha(a,b,c,e){var d=a.length;let f=[],g,h,k=0;e&&(e=[]);for(--d;0<=d;d--){const m=a[d],n=m.length,r=y();let t=!g;for(let q=0;q<n;q++){const l=m[q],p=l.length;if(p)for(let x=0,z,A;x<p;x++)if(A=l[x],g){if(g[A]){if(!d)if(c)c--;else if(f[k++]=A,k===b)return f;if(d||e)r[A]=1;t=!0}if(e&&(h[A]=(z=h[A])?z++:z=1,z<n)){const B=e[z-1]||(e[z-1]=[]);B[B.length]=A}}else r[A]=1}if(e)g||(h=r);else if(!t)return[];g=r}if(e)for(let m=e.length-1,n,r;0<=m;m--){n=e[m];r=n.length;for(let t=0,q;t<r;t++)if(q=n[t],
|
||||
!g[q]){if(c)c--;else if(f[k++]=q,k===b)return f;g[q]=1}}return f}function ka(a,b){const c=y(),e=y(),d=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!e[k]&&(e[k]=1,d[d.length]=k)}return d};const la={memory:{charset:"latin:extra",D:3,o:3,C:!1,s:"memory"},performance:{threshold:8,o:3,context:{depth:1,F:!0}},match:{charset:"latin:extra",B:"full",D:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,F:!0}},"default":{D:3,threshold:0,depth:3}};function O(a,b){if(!(this instanceof O))return new O(a);var c;let e;a?(C(a)?a=la[a]:(c=a.preset)&&(a=Object.assign({},c[c],a)),c=a.charset,e=a.lang,C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=L[c]),C(e)&&(e=ea[e])):a={};let d,f,g=a.context||{};this.encode=a.encode||c&&c.encode||J;this.register=b||y();this.D=d=a.resolution||9;this.B=b=c&&c.B||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.F=v(g.bidirectional);this.s=f=v(a.optimize);this.C=v(a.fastupdate);this.o=a.minlength||1;this.h=
|
||||
f?w(d):y();this.m=d=g.resolution||1;this.l=f?w(d):y();this.A=c&&c.A||a.rtl;this.G=(b=a.matcher||e&&e.G)&&F(b,!1);this.H=(b=a.stemmer||e&&e.H)&&F(b,!0);if(a=b=a.filter||e&&e.filter){a=b;c=y();for(let h=0,k=a.length;h<k;h++)c[a[h]]=1;a=c}this.filter=a}function K(a,b,c,e){if(b&&(c&&(b=H(b,c)),a.G&&(b=H(b,a.G)),a.H&&1<b.length&&(b=H(b,a.H)),e||""===e)){b=b.split(e);if(a.filter){a=a.filter;c=b.length;e=[];for(let d=0,f=0;d<c;d++){const g=b[d];g&&!a[g]&&(e[f++]=g)}a=e}else a=b;return a}return b}u=O.prototype;
|
||||
u.append=function(a,b){return this.add(a,b,!0)};
|
||||
u.add=function(a,b,c,e){if(!e&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),e=b.length)){const m=this.depth,n=this.D,r=y(),t=y();for(let q=0;q<e;q++){let l=b[this.A?e-1-q:q];var d=l.length;if(l&&d>=this.o&&(m||!r[l])){var f=P(n,e,q),g="";switch(this.B){case "full":if(3<d){for(f=0;f<d;f++)for(var h=d;h>f;h--)if(h-f>=this.o){var k=P(n,e,q,d,f);g=l.substring(f,h);Q(this,r,g,k,a,c)}break}case "reverse":if(2<d){for(h=d-1;0<h;h--)g=l[h]+g,g.length>=this.o&&Q(this,r,g,
|
||||
P(n,e,q,d,h),a,c);g=""}case "forward":if(1<d)for(h=0;h<d;h++)g+=l[h],g.length>=this.o&&Q(this,r,g,f,a,c);break;default:if(Q(this,r,l,f,a,c),m&&1<e&&q<e-1)for(d=this.m,g=y(),f=l,h=Math.min(m+1,e-q),g[f]=1,k=1;k<h;k++)if((l=b[this.A?e-1-q-k:q+k])&&l.length>=this.o&&!g[l]){g[l]=1;const p=this.F&&l>f;Q(this,t,p?f:l,P(d+(e/2>d?0:1),e,q,h-1,k-1),a,c,p?l:f)}}}}this.C||(this.register[a]=1)}return this};function P(a,b,c,e,d){return c&&1<a?b+(e||0)<=a?c+(d||0):(a-1)/(b+(e||0))*(c+(d||0))+1|0:0}
|
||||
function Q(a,b,c,e,d,f,g){let h=g?a.l:a.h;if(!b[c]||g&&!b[c][g])a.s&&(h=h[e]),g?(b=b[c]||(b[c]=y()),b[g]=1,h=h[g]||(h[g]=y())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[e]||(h[e]=[])),f&&-1!==h.indexOf(d)||(h[h.length]=d,a.C&&(a=a.register[d]||(a.register[d]=[]),a[a.length]=h))}
|
||||
u.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);let e=[],d;let f,g=0;if(c){b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(a),d=a.length,1<d)){c=y();var k=[];for(let n=0,r=0,t;n<d;n++)if((t=a[n])&&t.length>=this.o&&!c[t])if(this.s||f||this.h[t])k[r++]=t,c[t]=1;else return e;a=k;d=a.length}if(!d)return e;b||(b=100);h=this.depth&&1<d&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<d&&a.sort(aa);for(let n,r;c<d;c++){r=a[c];h?(n=ma(this,e,f,b,g,2===d,r,m),f&&!1===n&&e.length||(m=
|
||||
r)):n=ma(this,e,f,b,g,1===d,r);if(n)return n;if(f&&c===d-1){k=e.length;if(!k){if(h){h=0;c=-1;continue}return e}if(1===k)return na(e[0],b,g)}}return ha(e,b,g,f)};
|
||||
function ma(a,b,c,e,d,f,g,h){let k=[],m=h?a.l:a.h;a.s||(m=oa(m,g,h,a.F));if(m){let n=0;const r=Math.min(m.length,h?a.m:a.D);for(let t=0,q=0,l,p;t<r;t++)if(l=m[t])if(a.s&&(l=oa(l,g,h,a.F)),d&&l&&f&&(p=l.length,p<=d?(d-=p,l=null):(l=l.slice(d),d=0)),l&&(k[n++]=l,f&&(q+=l.length,q>=e)))break;if(n){if(f)return na(k,e,0);b[b.length]=k;return}}return!c&&k}function na(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
|
||||
function oa(a,b,c,e){c?(e=e&&b>c,a=(a=a[e?b:c])&&a[e?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};u.remove=function(a,b){const c=this.register[a];if(c){if(this.C)for(let e=0,d;e<c.length;e++)d=c[e],d.splice(d.indexOf(a),1);else S(this.h,a,this.D,this.s),this.depth&&S(this.l,a,this.m,this.s);b||delete this.register[a]}return this};
|
||||
function S(a,b,c,e,d){let f=0;if(a.constructor===Array)if(d)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{d=Math.min(a.length,c);for(let g=0,h;g<d;g++)if(h=a[g])f=S(h,b,c,e,d),e||f||delete a[g]}else for(let g in a)(f=S(a[g],b,c,e,d))||delete a[g];return f}fa(O.prototype);function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.I=[];this.h=[];this.m=[];this.register=y();this.key=(c=b.key||b.id)&&U(c,this.m)||"id";this.C=v(a.fastupdate);this.l=(c=b.store)&&!0!==c&&[];this.store=c&&y();this.async=!1;c=y();let e=b.index||b.field||b;C(e)&&(e=[e]);for(let d=0,f,g;d<e.length;d++)f=e[d],C(f)||(g=f,f=f.field),g=D(g)?Object.assign({},a,g):a,this.J||(c[f]=new O(g,this.register)),this.I[d]=U(f,this.m),this.h[d]=f;if(this.l)for(a=b.store,C(a)&&(a=
|
||||
(function(self){'use strict';var t;function v(a){return"undefined"!==typeof a?a:!0}function w(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=z();return b}function z(){return Object.create(null)}function aa(a,b){return b.length-a.length}function C(a){return"string"===typeof a}function D(a){return"object"===typeof a};const ba=/[\u0300-\u036f]/g;function E(a){a.normalize&&(a=a.normalize("NFD").replace(ba,""));return a}function F(a,b){const c=Object.keys(a),e=c.length,d=[];let f="",g=0;for(let h=0,k,m;h<e;h++)k=c[h],(m=a[k])?(d[g++]=H(b?"(?!\\b)"+k+"(\\b|_)":k),d[g++]=m):f+=(f?"|":"")+k;f&&(d[g++]=H(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),d[g]="");return d}function I(a,b){for(let c=0,e=b.length;c<e&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function H(a){return new RegExp(a,"g")}
|
||||
function J(a){let b="",c="";for(let e=0,d=a.length,f;e<d;e++)(f=a[e])!==c&&(b+=c=f);return b};var ca={encode:K,A:!1,B:""};const da=/[\W_]+/;function K(a){return ea(this,E(a).toLowerCase(),!1,da)};const fa={},L={};function ha(a){M(a,"add");M(a,"append");M(a,"search");M(a,"update");M(a,"remove")}function M(a,b){a[b+"Async"]=function(){const c=this,e=arguments;var d=e[e.length-1];let f;"function"===typeof d&&(f=d,delete e[e.length-1]);d=new Promise(function(g){setTimeout(function(){c.async=!0;const h=c[b].apply(c,e);c.async=!1;g(h)})});return f?(d.then(f),this):d}};function ia(a,b,c,e){const d=a.length;let f=[],g,h,k=0;e&&(e=[]);for(let m=d-1;0<=m;m--){const n=a[m],u=n.length,q=z();let r=!g;for(let l=0;l<u;l++){const p=n[l],y=p.length;if(y)for(let B=0,A,x;B<y;B++)if(x=p[B],g){if(g[x]){if(!m)if(c)c--;else if(f[k++]=x,k===b)return f;if(m||e)q[x]=1;r=!0}if(e&&(h[x]=(A=h[x])?++A:A=1,A<d)){const G=e[A-2]||(e[A-2]=[]);G[G.length]=x}}else q[x]=1}if(e)g||(h=q);else if(!r)return[];g=q}if(e)for(let m=e.length-1,n,u;0<=m;m--){n=e[m];u=n.length;for(let q=0,r;q<u;q++)if(r=
|
||||
n[q],!g[r]){if(c)c--;else if(f[k++]=r,k===b)return f;g[r]=1}}return f}function ka(a,b){const c=z(),e=z(),d=[];for(let f=0;f<a.length;f++)c[a[f]]=1;for(let f=0,g;f<b.length;f++){g=b[f];for(let h=0,k;h<g.length;h++)k=g[h],c[k]&&!e[k]&&(e[k]=1,d[d.length]=k)}return d};const la={memory:{charset:"latin:extra",D:3,o:3,C:!1,s:"memory"},performance:{threshold:8,o:3,context:{depth:1,F:!0}},match:{charset:"latin:extra",B:"full",D:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,F:!0}},"default":{D:3,threshold:0,depth:3}};function O(a,b){if(!(this instanceof O))return new O(a);var c;let e;a?(C(a)?a=la[a]:(c=a.preset)&&(a=Object.assign({},c[c],a)),c=a.charset,e=a.lang,C(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=L[c]),C(e)&&(e=fa[e])):a={};let d,f,g=a.context||{};this.encode=a.encode||c&&c.encode||K;this.register=b||z();this.D=d=a.resolution||9;this.B=b=c&&c.B||a.tokenize||"strict";this.depth="strict"===b&&g.depth;this.F=v(g.bidirectional);this.s=f=v(a.optimize);this.C=v(a.fastupdate);this.o=a.minlength||1;this.h=
|
||||
f?w(d):z();this.m=d=g.resolution||1;this.l=f?w(d):z();this.A=c&&c.A||a.rtl;this.G=(b=a.matcher||e&&e.G)&&F(b,!1);this.H=(b=a.stemmer||e&&e.H)&&F(b,!0);if(a=b=a.filter||e&&e.filter){a=b;c=z();for(let h=0,k=a.length;h<k;h++)c[a[h]]=1;a=c}this.filter=a}function ea(a,b,c,e){if(b&&(c&&(b=I(b,c)),a.G&&(b=I(b,a.G)),a.H&&1<b.length&&(b=I(b,a.H)),e||""===e)){b=b.split(e);if(a.filter){a=a.filter;c=b.length;e=[];for(let d=0,f=0;d<c;d++){const g=b[d];g&&!a[g]&&(e[f++]=g)}a=e}else a=b;return a}return b}t=O.prototype;
|
||||
t.append=function(a,b){return this.add(a,b,!0)};
|
||||
t.add=function(a,b,c,e){if(b&&(a||0===a)){if(!e&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(e=b.length){const m=z(),n=z(),u=this.depth,q=this.D;for(let r=0;r<e;r++){let l=b[this.A?e-1-r:r];var d=l.length;if(l&&d>=this.o&&(u||!n[l])){var f=P(q,e,r),g="";switch(this.B){case "full":if(3<d){for(f=0;f<d;f++)for(var h=d;h>f;h--)if(h-f>=this.o){var k=P(q,e,r,d,f);g=l.substring(f,h);Q(this,n,g,k,a,c)}break}case "reverse":if(2<d){for(h=d-1;0<h;h--)g=l[h]+g,g.length>=this.o&&Q(this,n,
|
||||
g,P(q,e,r,d,h),a,c);g=""}case "forward":if(1<d){for(h=0;h<d;h++)g+=l[h],g.length>=this.o&&Q(this,n,g,f,a,c);break}default:if(Q(this,n,l,f,a,c),u&&1<e&&r<e-1)for(d=z(),g=this.m,f=l,h=Math.min(u+1,e-r),d[f]=1,k=1;k<h;k++)if((l=b[this.A?e-1-r-k:r+k])&&l.length>=this.o&&!d[l]){d[l]=1;const p=this.F&&l>f;Q(this,m,p?f:l,P(g+(e/2>g?0:1),e,r,h-1,k-1),a,c,p?l:f)}}}}this.C||(this.register[a]=1)}}return this};function P(a,b,c,e,d){return c&&1<a?b+(e||0)<=a?c+(d||0):(a-1)/(b+(e||0))*(c+(d||0))+1|0:0}
|
||||
function Q(a,b,c,e,d,f,g){let h=g?a.l:a.h;if(!b[c]||g&&!b[c][g])a.s&&(h=h[e]),g?(b=b[c]||(b[c]=z()),b[g]=1,h=h[g]||(h[g]=z())):b[c]=1,h=h[c]||(h[c]=[]),a.s||(h=h[e]||(h[e]=[])),f&&-1!==h.indexOf(d)||(h[h.length]=d,a.C&&(a=a.register[d]||(a.register[d]=[]),a[a.length]=h))}
|
||||
t.search=function(a,b,c){D(a)?(c=a,a=c.query):D(b)&&(c=b);let e=[],d;let f,g=0;if(c){b=c.limit;g=c.offset||0;var h=c.context;f=c.suggest}if(a&&(a=this.encode(a),d=a.length,1<d)){c=z();var k=[];for(let n=0,u=0,q;n<d;n++)if((q=a[n])&&q.length>=this.o&&!c[q])if(this.s||f||this.h[q])k[u++]=q,c[q]=1;else return e;a=k;d=a.length}if(!d)return e;b||(b=100);h=this.depth&&1<d&&!1!==h;c=0;let m;h?(m=a[0],c=1):1<d&&a.sort(aa);for(let n,u;c<d;c++){u=a[c];h?(n=ma(this,e,f,b,g,2===d,u,m),f&&!1===n&&e.length||(m=
|
||||
u)):n=ma(this,e,f,b,g,1===d,u);if(n)return n;if(f&&c===d-1){k=e.length;if(!k){if(h){h=0;c=-1;continue}return e}if(1===k)return na(e[0],b,g)}}return ia(e,b,g,f)};
|
||||
function ma(a,b,c,e,d,f,g,h){let k=[],m=h?a.l:a.h;a.s||(m=oa(m,g,h,a.F));if(m){let n=0;const u=Math.min(m.length,h?a.m:a.D);for(let q=0,r=0,l,p;q<u;q++)if(l=m[q])if(a.s&&(l=oa(l,g,h,a.F)),d&&l&&f&&(p=l.length,p<=d?(d-=p,l=null):(l=l.slice(d),d=0)),l&&(k[n++]=l,f&&(r+=l.length,r>=e)))break;if(n){if(f)return na(k,e,0);b[b.length]=k;return}}return!c&&k}function na(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
|
||||
function oa(a,b,c,e){c?(e=e&&b>c,a=(a=a[e?b:c])&&a[e?c:b]):a=a[b];return a}t.contain=function(a){return!!this.register[a]};t.update=function(a,b){return this.remove(a).add(a,b)};t.remove=function(a,b){const c=this.register[a];if(c){if(this.C)for(let e=0,d;e<c.length;e++)d=c[e],d.splice(d.indexOf(a),1);else R(this.h,a,this.D,this.s),this.depth&&R(this.l,a,this.m,this.s);b||delete this.register[a]}return this};
|
||||
function R(a,b,c,e,d){let f=0;if(a.constructor===Array)if(d)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),f++):f++;else{d=Math.min(a.length,c);for(let g=0,h;g<d;g++)if(h=a[g])f=R(h,b,c,e,d),e||f||delete a[g]}else for(let g in a)(f=R(a[g],b,c,e,d))||delete a[g];return f}ha(O.prototype);function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.I=[];this.h=[];this.m=[];this.register=z();this.key=(c=b.key||b.id)&&U(c,this.m)||"id";this.C=v(a.fastupdate);this.l=(c=b.store)&&!0!==c&&[];this.store=c&&z();this.async=!1;c=z();let e=b.index||b.field||b;C(e)&&(e=[e]);for(let d=0,f,g;d<e.length;d++)f=e[d],C(f)||(g=f,f=f.field),g=D(g)?Object.assign({},a,g):a,this.J||(c[f]=new O(g,this.register)),this.I[d]=U(f,this.m),this.h[d]=f;if(this.l)for(a=b.store,C(a)&&(a=
|
||||
[a]),b=0;b<a.length;b++)this.l[b]=U(a[b],this.m);this.index=c}function U(a,b){const c=a.split(":");let e=0;for(let d=0;d<c.length;d++)a=c[d],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[e]=!0),a&&(c[e++]=a);e<c.length&&(c.length=e);return 1<e?c:c[0]}function pa(a,b){if(C(b))a=a[b];else for(let c=0;a&&c<b.length;c++)a=a[b[c]];return a}
|
||||
function V(a,b,c,e,d){a=a[d];if(e===c.length-1)b[d]=a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;d<a.length;d++)V(a,b,c,e,d);else b=b[d]||(b[d]=y()),d=c[++e],V(a,b,c,e,d)}function W(a,b,c,e,d,f,g,h){a=a[g];if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;b<a.length;b++)d.add(f,a[b],!0,!0);return}a=a.join(" ")}d.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)W(a,b,c,e,d,f,g,h);else g=b[++e],W(a,b,c,e,d,f,g,h)}u=T.prototype;
|
||||
u.add=function(a,b,c){D(a)&&(b=a,a=pa(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(let e=0,d,f;e<this.h.length;e++)f=this.h[e],d=this.I[e],C(d)&&(d=[d]),W(b,d,this.m,0,this.index[f],a,d[0],c);if(this.store){let e;if(this.l){e=y();for(let d=0,f;d<this.l.length;d++)f=this.l[d],C(f)?e[f]=b[f]:V(b,e,f,0,f[0])}this.store[a]=e||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
u.remove=function(a){D(a)&&(a=pa(a,this.key));if(this.register[a]){const b=this.C&&!this.J;for(let c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);this.store&&delete this.store[a];delete this.register[a]}return this};
|
||||
u.search=function(a,b,c,e){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);let d=[],f=[],g,h,k,m,n,r,t=0;if(c)if(c.constructor===Array)k=c,c=null;else{k=(g=c.pluck)||c.index||c.field||c;m=!1;h=this.store&&c.enrich;n="and"===c.bool;b=c.limit||100;r=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=qa.call(this,m[l],b,r,h))d[d.length]=p,t++;return t?d:[]}C(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const q=!e&&(this.J||this.async)&&[];for(let l=
|
||||
0,p,x,z;l<k.length;l++){let A;x=k[l];C(x)||(A=x,x=x.field);if(q)q[l]=this.index[x].searchAsync(a,b,A||c);else{e?p=e[l]:p=this.index[x].search(a,b,A||c);z=p&&p.length;if(m&&z){const B=[];let ia=0;n&&(B[0]=[p]);for(let R=0,ja,M;R<m.length;R++)if(ja=m[R],z=(M=this.K[ja])&&M.length)ia++,B[B.length]=n?[M]:M;ia&&(p=n?ha(B,b||100,r||0):ka(p,B),z=p.length)}if(z)f[t]=x,d[t++]=p;else if(n)return[]}}if(q){const l=this;return new Promise(function(p){Promise.all(q).then(function(x){p(l.search(a,b,c,x))})})}if(!t)return[];
|
||||
if(g&&(!h||!this.store))return d[0];for(let l=0,p;l<f.length;l++){p=d[l];p.length&&h&&(p=ra.call(this,p));if(g)return p;d[l]={field:f[l],result:p}}return d};function qa(a,b,c,e){let d=this.K[a],f=d&&d.length-c;if(f&&0<f){if(f>b||c)d=d.slice(c,c+b);e&&(d=ra.call(this,d));return{tag:a,result:d}}}function ra(a){const b=Array(a.length);for(let c=0,e;c<a.length;c++)e=a[c],b[c]={key:e,doc:this.store[e]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
|
||||
u.set=function(a,b){this.store[a]=b;return this};fa(T.prototype);var ta={encode:sa,A:!1,B:""};const ua=/[\W_]+/,va=[G("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",G("[\u00e8\u00e9\u00ea\u00eb]"),"e",G("[\u00ec\u00ed\u00ee\u00ef]"),"i",G("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",G("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",G("[\u00fd\u0177\u00ff]"),"y",G("\u00f1"),"n",G("[\u00e7c]"),"k",G("\u00df"),"s",G(" & ")," and "];function sa(a){return K(this,E(a).toLowerCase(),!a.normalize&&va,ua)};var xa={encode:wa,A:!1,B:"strict"};const ya=/[^a-z0-9]+/,za={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function wa(a){a=sa.call(this,a).join(" ");const b=[];if(a){const c=a.split(ya),e=c.length;for(let d=0,f,g=0;d<e;d++)if((a=c[d])&&(!this.filter||!this.filter[a])){f=a[0];let h=za[f]||f,k=h;for(let m=1;m<a.length;m++){f=a[m];const n=za[f]||f;n&&n!==k&&(h+=n,k=n)}b[g++]=h}}return b};var Ba={encode:Aa,A:!1,B:""};const Ca=[G("ae"),"a",G("oe"),"o",G("sh"),"s",G("th"),"t",G("ph"),"f",G("pf"),"f"];function Aa(a,b){a&&(a=wa.call(this,a).join(" "),2<a.length&&(a=H(a,Ca)),b||(1<a.length&&(a=I(a)),a&&(a=a.split(" "))));return a};var Ea={encode:Da,A:!1,B:""};const Fa=G("(?!\\b)[aeiouy]");function Da(a){a&&(a=Aa.call(this,a,!0),1<a.length&&(a=a.replace(Fa,"")),1<a.length&&(a=I(a)),a&&(a=a.split(" ")));return a};L["latin:default"]=ca;L["latin:simple"]=ta;L["latin:balance"]=xa;L["latin:advanced"]=Ba;L["latin:extra"]=Ea;const X=self;let Y;const Z={Index:O,Document:T,Worker:null,registerCharset:function(a,b){L[a]=b},registerLanguage:function(a,b){ea[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));
|
||||
function V(a,b,c,e,d){a=a[d];if(e===c.length-1)b[d]=a;else if(a)if(a.constructor===Array)for(b=b[d]=Array(a.length),d=0;d<a.length;d++)V(a,b,c,e,d);else b=b[d]||(b[d]=z()),d=c[++e],V(a,b,c,e,d)}function W(a,b,c,e,d,f,g,h){a=a[g];if(e===b.length-1){if(a.constructor===Array){if(c[e]){for(b=0;b<a.length;b++)d.add(f,a[b],!0,!0);return}a=a.join(" ")}d.add(f,a,h,!0)}else if(a)if(a.constructor===Array)for(g=0;g<a.length;g++)W(a,b,c,e,d,f,g,h);else g=b[++e],W(a,b,c,e,d,f,g,h)}t=T.prototype;
|
||||
t.add=function(a,b,c){D(a)&&(b=a,a=pa(b,this.key));if(b&&(a||0===a)){if(!c&&this.register[a])return this.update(a,b);for(let e=0,d,f;e<this.h.length;e++)f=this.h[e],d=this.I[e],C(d)&&(d=[d]),W(b,d,this.m,0,this.index[f],a,d[0],c);if(this.store&&(!c||!this.store[a])){let e;if(this.l){e=z();for(let d=0,f;d<this.l.length;d++)f=this.l[d],C(f)?e[f]=b[f]:V(b,e,f,0,f[0])}this.store[a]=e||b}}return this};t.append=function(a,b){return this.add(a,b,!0)};t.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
t.remove=function(a){D(a)&&(a=pa(a,this.key));if(this.register[a]){for(let b=0;b<this.h.length&&(this.index[this.h[b]].remove(a,!this.J),!this.C);b++);this.store&&delete this.store[a];delete this.register[a]}return this};
|
||||
t.search=function(a,b,c,e){D(a)?(c=a,a=c.query):D(b)&&(c=b,b=0);let d=[],f=[],g,h,k,m,n,u,q=0;if(c)if(c.constructor===Array)k=c,c=null;else{k=(g=c.pluck)||c.index||c.field||c;m=!1;h=this.store&&c.enrich;n="and"===c.bool;b=c.limit||100;u=c.offset||0;if(m&&(C(m)&&(m=[m]),!a)){for(let l=0,p;l<m.length;l++)if(p=qa.call(this,m[l],b,u,h))d[d.length]=p,q++;return q?d:[]}C(k)&&(k=[k])}k||(k=this.h);n=n&&(1<k.length||m&&1<m.length);const r=!e&&(this.J||this.async)&&[];for(let l=0,p,y,B;l<k.length;l++){let A;
|
||||
y=k[l];C(y)||(A=y,y=y.field);if(r)r[l]=this.index[y].searchAsync(a,b,A||c);else{e?p=e[l]:p=this.index[y].search(a,b,A||c);B=p&&p.length;if(m&&B){const x=[];let G=0;n&&(x[0]=[p]);for(let S=0,ja,N;S<m.length;S++)if(ja=m[S],B=(N=this.K[ja])&&N.length)G++,x[x.length]=n?[N]:N;G&&(p=n?ia(x,b||100,u||0):ka(p,x),B=p.length)}if(B)f[q]=y,d[q++]=p;else if(n)return[]}}if(r){const l=this;return new Promise(function(p){Promise.all(r).then(function(y){p(l.search(a,b,c,y))})})}if(!q)return[];if(g&&(!h||!this.store))return d[0];
|
||||
for(let l=0,p;l<f.length;l++){p=d[l];p.length&&h&&(p=ra.call(this,p));if(g)return p;d[l]={field:f[l],result:p}}return d};function qa(a,b,c,e){let d=this.K[a],f=d&&d.length-c;if(f&&0<f){if(f>b||c)d=d.slice(c,c+b);e&&(d=ra.call(this,d));return{tag:a,result:d}}}function ra(a){const b=Array(a.length);for(let c=0,e;c<a.length;c++)e=a[c],b[c]={key:e,doc:this.store[e]};return b}t.contain=function(a){return!!this.register[a]};t.get=function(a){return this.store[a]};t.set=function(a,b){this.store[a]=b;return this};
|
||||
ha(T.prototype);var ta={encode:sa,A:!1,B:""};const ua=/[\W_]+/,va=[H("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",H("[\u00e8\u00e9\u00ea\u00eb]"),"e",H("[\u00ec\u00ed\u00ee\u00ef]"),"i",H("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",H("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",H("[\u00fd\u0177\u00ff]"),"y",H("\u00f1"),"n",H("[\u00e7c]"),"k",H("\u00df"),"s",H(" & ")," and "];function sa(a){return ea(this,E(a).toLowerCase(),!a.normalize&&va,ua)};var xa={encode:wa,A:!1,B:"strict"};const ya=/[^a-z0-9]+/,za={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function wa(a){a=sa.call(this,a).join(" ");const b=[];if(a){const c=a.split(ya),e=c.length;for(let d=0,f,g=0;d<e;d++)if((a=c[d])&&(!this.filter||!this.filter[a])){f=a[0];let h=za[f]||f,k=h;for(let m=1;m<a.length;m++){f=a[m];const n=za[f]||f;n&&n!==k&&(h+=n,k=n)}b[g++]=h}}return b};var Ba={encode:Aa,A:!1,B:""};const Ca=[H("ae"),"a",H("oe"),"o",H("sh"),"s",H("th"),"t",H("ph"),"f",H("pf"),"f",H("(?![aeo])h(?![aeo])"),"",H("(?!^[aeo])h(?!^[aeo])"),""];function Aa(a,b){a&&(a=wa.call(this,a).join(" "),2<a.length&&(a=I(a,Ca)),b||(1<a.length&&(a=J(a)),a&&(a=a.split(" "))));return a};var Ea={encode:Da,A:!1,B:""};const Fa=H("(?!\\b)[aeo]");function Da(a){a&&(a=Aa.call(this,a,!0),1<a.length&&(a=a.replace(Fa,"")),1<a.length&&(a=J(a)),a&&(a=a.split(" ")));return a};L["latin:default"]=ca;L["latin:simple"]=ta;L["latin:balance"]=xa;L["latin:advanced"]=Ba;L["latin:extra"]=Ea;const X=self;let Y;const Z={Index:O,Document:T,Worker:null,registerCharset:function(a,b){L[a]=b},registerLanguage:function(a,b){fa[a]=b}};(Y=X.define)&&Y.amd?Y([],function(){return Z}):X.exports?X.exports=Z:X.FlexSearch=Z;}(this));
|
||||
|
398
dist/flexsearch.debug.js
vendored
@@ -1,5 +1,5 @@
|
||||
/**!
|
||||
* FlexSearch.js v0.7.0-beta (Debug)
|
||||
* FlexSearch.js v0.7.0 (Debug)
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Licence: Apache-2.0
|
||||
@@ -22,35 +22,35 @@ function w() {
|
||||
function aa(a, b) {
|
||||
return b.length - a.length;
|
||||
}
|
||||
function y(a) {
|
||||
function x(a) {
|
||||
return "string" === typeof a;
|
||||
}
|
||||
function z(a) {
|
||||
return "object" === typeof a;
|
||||
}
|
||||
function C(a) {
|
||||
function D(a) {
|
||||
return "function" === typeof a;
|
||||
}
|
||||
;const ba = /[\u0300-\u036f]/g;
|
||||
function E(a) {
|
||||
function ca(a) {
|
||||
a.normalize && (a = a.normalize("NFD").replace(ba, ""));
|
||||
return a;
|
||||
}
|
||||
function ca(a, b) {
|
||||
function da(a, b) {
|
||||
const c = Object.keys(a), d = c.length, e = [];
|
||||
let f = "", g = 0;
|
||||
for (let h = 0, k, n; h < d; h++) {
|
||||
k = c[h], (n = a[k]) ? (e[g++] = F(b ? "(?!\\b)" + k + "(\\b|_)" : k), e[g++] = n) : f += (f ? "|" : "") + k;
|
||||
for (let h = 0, k, m; h < d; h++) {
|
||||
k = c[h], (m = a[k]) ? (e[g++] = E(b ? "(?!\\b)" + k + "(\\b|_)" : k), e[g++] = m) : f += (f ? "|" : "") + k;
|
||||
}
|
||||
f && (e[g++] = F(b ? "(?!\\b)(" + f + ")(\\b|_)" : "(" + f + ")"), e[g] = "");
|
||||
f && (e[g++] = E(b ? "(?!\\b)(" + f + ")(\\b|_)" : "(" + f + ")"), e[g] = "");
|
||||
return e;
|
||||
}
|
||||
function G(a, b) {
|
||||
function F(a, b) {
|
||||
for (let c = 0, d = b.length; c < d && (a = a.replace(b[c], b[c + 1]), a); c += 2) {
|
||||
}
|
||||
return a;
|
||||
}
|
||||
function F(a) {
|
||||
function E(a) {
|
||||
return new RegExp(a, "g");
|
||||
}
|
||||
function H(a) {
|
||||
@@ -60,13 +60,13 @@ function H(a) {
|
||||
}
|
||||
return b;
|
||||
}
|
||||
;var ea = {encode:da, rtl:!1, tokenize:""};
|
||||
const fa = /[\W_]+/;
|
||||
function da(a) {
|
||||
return this.pipeline(E(a).toLowerCase(), !1, fa, !1);
|
||||
;var fa = {encode:ea, rtl:!1, tokenize:""};
|
||||
const ha = /[\W_]+/;
|
||||
function ea(a) {
|
||||
return this.pipeline(ca(a).toLowerCase(), !1, ha, !1);
|
||||
}
|
||||
;const ha = {}, I = {};
|
||||
function ia(a) {
|
||||
;const ia = {}, I = {};
|
||||
function ja(a) {
|
||||
J(a, "add");
|
||||
J(a, "append");
|
||||
J(a, "search");
|
||||
@@ -78,7 +78,7 @@ function J(a, b) {
|
||||
const c = this, d = arguments;
|
||||
var e = d[d.length - 1];
|
||||
let f;
|
||||
C(e) && (f = e, delete d[d.length - 1]);
|
||||
D(e) && (f = e, delete d[d.length - 1]);
|
||||
e = new Promise(function(g) {
|
||||
setTimeout(function() {
|
||||
c.async = !0;
|
||||
@@ -90,39 +90,39 @@ function J(a, b) {
|
||||
return f ? (e.then(f), this) : e;
|
||||
};
|
||||
}
|
||||
;function ja(a, b, c, d) {
|
||||
var e = a.length;
|
||||
;function ka(a, b, c, d) {
|
||||
const e = a.length;
|
||||
let f = [], g, h, k = 0;
|
||||
d && (d = []);
|
||||
for (--e; 0 <= e; e--) {
|
||||
const n = a[e], p = n.length, q = w();
|
||||
let t = !g;
|
||||
for (let m = 0; m < p; m++) {
|
||||
const l = n[m], u = l.length;
|
||||
if (u) {
|
||||
for (let x = 0, A, B; x < u; x++) {
|
||||
if (B = l[x], g) {
|
||||
if (g[B]) {
|
||||
if (!e) {
|
||||
for (let m = e - 1; 0 <= m; m--) {
|
||||
const n = a[m], u = n.length, q = w();
|
||||
let p = !g;
|
||||
for (let l = 0; l < u; l++) {
|
||||
const t = n[l], y = t.length;
|
||||
if (y) {
|
||||
for (let C = 0, B, A; C < y; C++) {
|
||||
if (A = t[C], g) {
|
||||
if (g[A]) {
|
||||
if (!m) {
|
||||
if (c) {
|
||||
c--;
|
||||
} else {
|
||||
if (f[k++] = B, k === b) {
|
||||
if (f[k++] = A, k === b) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e || d) {
|
||||
q[B] = 1;
|
||||
if (m || d) {
|
||||
q[A] = 1;
|
||||
}
|
||||
t = !0;
|
||||
p = !0;
|
||||
}
|
||||
if (d && (h[B] = (A = h[B]) ? A++ : A = 1, A < p)) {
|
||||
const D = d[A - 1] || (d[A - 1] = []);
|
||||
D[D.length] = B;
|
||||
if (d && (h[A] = (B = h[A]) ? ++B : B = 1, B < e)) {
|
||||
const G = d[B - 2] || (d[B - 2] = []);
|
||||
G[G.length] = A;
|
||||
}
|
||||
} else {
|
||||
q[B] = 1;
|
||||
q[A] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,33 +130,33 @@ function J(a, b) {
|
||||
if (d) {
|
||||
g || (h = q);
|
||||
} else {
|
||||
if (!t) {
|
||||
if (!p) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
g = q;
|
||||
}
|
||||
if (d) {
|
||||
for (let n = d.length - 1, p, q; 0 <= n; n--) {
|
||||
p = d[n];
|
||||
q = p.length;
|
||||
for (let t = 0, m; t < q; t++) {
|
||||
if (m = p[t], !g[m]) {
|
||||
for (let m = d.length - 1, n, u; 0 <= m; m--) {
|
||||
n = d[m];
|
||||
u = n.length;
|
||||
for (let q = 0, p; q < u; q++) {
|
||||
if (p = n[q], !g[p]) {
|
||||
if (c) {
|
||||
c--;
|
||||
} else {
|
||||
if (f[k++] = m, k === b) {
|
||||
if (f[k++] = p, k === b) {
|
||||
return f;
|
||||
}
|
||||
}
|
||||
g[m] = 1;
|
||||
g[p] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return f;
|
||||
}
|
||||
function ka(a, b) {
|
||||
function la(a, b) {
|
||||
const c = w(), d = w(), e = [];
|
||||
for (let f = 0; f < a.length; f++) {
|
||||
c[a[f]] = 1;
|
||||
@@ -174,7 +174,7 @@ function ka(a, b) {
|
||||
this.cache = w();
|
||||
this.queue = [];
|
||||
}
|
||||
function la(a, b, c) {
|
||||
function ma(a, b, c) {
|
||||
z(a) && (a = a.query);
|
||||
let d = this.cache.get(a);
|
||||
d || (d = this.search(a, b, c), this.cache.set(a, d));
|
||||
@@ -220,7 +220,7 @@ function pa(a, b, c, d, e, f) {
|
||||
}
|
||||
var c;
|
||||
if (a) {
|
||||
if (y(a)) {
|
||||
if (x(a)) {
|
||||
oa[a] || console.warn("Preset not found: " + a), a = oa[a];
|
||||
} else {
|
||||
if (c = a.preset) {
|
||||
@@ -229,13 +229,13 @@ function pa(a, b, c, d, e, f) {
|
||||
}
|
||||
c = a.charset;
|
||||
var d = a.lang;
|
||||
y(c) && (-1 === c.indexOf(":") && (c += ":default"), c = I[c]);
|
||||
y(d) && (d = ha[d]);
|
||||
x(c) && (-1 === c.indexOf(":") && (c += ":default"), c = I[c]);
|
||||
x(d) && (d = ia[d]);
|
||||
} else {
|
||||
a = {};
|
||||
}
|
||||
let e, f, g = a.context || {};
|
||||
this.encode = a.encode || c && c.encode || da;
|
||||
this.encode = a.encode || c && c.encode || ea;
|
||||
this.register = b || w();
|
||||
this.resolution = e = a.resolution || 9;
|
||||
this.tokenize = b = c && c.tokenize || a.tokenize || "strict";
|
||||
@@ -248,8 +248,8 @@ function pa(a, b, c, d, e, f) {
|
||||
this.resolution_ctx = e = g.resolution || 1;
|
||||
this.ctx = f ? v(e) : w();
|
||||
this.rtl = c && c.rtl || a.rtl;
|
||||
this.matcher = (b = a.matcher || d && d.matcher) && ca(b, !1);
|
||||
this.stemmer = (b = a.stemmer || d && d.stemmer) && ca(b, !0);
|
||||
this.matcher = (b = a.matcher || d && d.matcher) && da(b, !1);
|
||||
this.stemmer = (b = a.stemmer || d && d.stemmer) && da(b, !0);
|
||||
if (c = b = a.filter || d && d.filter) {
|
||||
c = b;
|
||||
d = w();
|
||||
@@ -262,7 +262,7 @@ function pa(a, b, c, d, e, f) {
|
||||
this.cache = (b = a.cache) && new K(b);
|
||||
}
|
||||
L.prototype.pipeline = function(a, b, c, d) {
|
||||
if (a && (b && (a = G(a, b)), this.matcher && (a = G(a, this.matcher)), this.stemmer && 1 < a.length && (a = G(a, this.stemmer)), d && 1 < a.length && (a = H(a)), c || "" === c)) {
|
||||
if (a && (b && (a = F(a, b)), this.matcher && (a = F(a, this.matcher)), this.stemmer && 1 < a.length && (a = F(a, this.stemmer)), d && 1 < a.length && (a = H(a)), c || "" === c)) {
|
||||
a = a.split(c);
|
||||
if (this.filter) {
|
||||
b = this.filter;
|
||||
@@ -282,58 +282,61 @@ L.prototype.append = function(a, b) {
|
||||
return this.add(a, b, !0);
|
||||
};
|
||||
L.prototype.add = function(a, b, c, d) {
|
||||
if (!d && !c && this.register[a]) {
|
||||
return this.update(a, b);
|
||||
}
|
||||
if (b && (a || 0 === a) && (b = this.encode(b), d = b.length)) {
|
||||
const n = this.depth, p = this.resolution, q = w(), t = w();
|
||||
for (let m = 0; m < d; m++) {
|
||||
let l = b[this.rtl ? d - 1 - m : m];
|
||||
var e = l.length;
|
||||
if (l && e >= this.minlength && (n || !q[l])) {
|
||||
var f = M(p, d, m), g = "";
|
||||
switch(this.tokenize) {
|
||||
case "full":
|
||||
if (3 < e) {
|
||||
for (f = 0; f < e; f++) {
|
||||
for (var h = e; h > f; h--) {
|
||||
if (h - f >= this.minlength) {
|
||||
var k = M(p, d, m, e, f);
|
||||
g = l.substring(f, h);
|
||||
this.push_index(q, g, k, a, c);
|
||||
if (b && (a || 0 === a)) {
|
||||
if (!d && !c && this.register[a]) {
|
||||
return this.update(a, b);
|
||||
}
|
||||
b = this.encode(b);
|
||||
if (d = b.length) {
|
||||
const m = w(), n = w(), u = this.depth, q = this.resolution;
|
||||
for (let p = 0; p < d; p++) {
|
||||
let l = b[this.rtl ? d - 1 - p : p];
|
||||
var e = l.length;
|
||||
if (l && e >= this.minlength && (u || !n[l])) {
|
||||
var f = M(q, d, p), g = "";
|
||||
switch(this.tokenize) {
|
||||
case "full":
|
||||
if (3 < e) {
|
||||
for (f = 0; f < e; f++) {
|
||||
for (var h = e; h > f; h--) {
|
||||
if (h - f >= this.minlength) {
|
||||
var k = M(q, d, p, e, f);
|
||||
g = l.substring(f, h);
|
||||
this.push_index(n, g, k, a, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "reverse":
|
||||
if (2 < e) {
|
||||
for (h = e - 1; 0 < h; h--) {
|
||||
g = l[h] + g, g.length >= this.minlength && (k = M(q, d, p, e, h), this.push_index(n, g, k, a, c));
|
||||
}
|
||||
g = "";
|
||||
}
|
||||
case "forward":
|
||||
if (1 < e) {
|
||||
for (h = 0; h < e; h++) {
|
||||
g += l[h], g.length >= this.minlength && this.push_index(n, g, f, a, c);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
if (this.push_index(n, l, f, a, c), u && 1 < d && p < d - 1) {
|
||||
for (e = w(), g = this.resolution_ctx, f = l, h = Math.min(u + 1, d - p), e[f] = 1, k = 1; k < h; k++) {
|
||||
if ((l = b[this.rtl ? d - 1 - p - k : p + k]) && l.length >= this.minlength && !e[l]) {
|
||||
e[l] = 1;
|
||||
const t = M(g + (d / 2 > g ? 0 : 1), d, p, h - 1, k - 1), y = this.bidirectional && l > f;
|
||||
this.push_index(m, y ? f : l, t, a, c, y ? l : f);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "reverse":
|
||||
if (2 < e) {
|
||||
for (h = e - 1; 0 < h; h--) {
|
||||
g = l[h] + g, g.length >= this.minlength && (k = M(p, d, m, e, h), this.push_index(q, g, k, a, c));
|
||||
}
|
||||
g = "";
|
||||
}
|
||||
case "forward":
|
||||
if (1 < e) {
|
||||
for (h = 0; h < e; h++) {
|
||||
g += l[h], g.length >= this.minlength && this.push_index(q, g, f, a, c);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (this.push_index(q, l, f, a, c), n && 1 < d && m < d - 1) {
|
||||
for (e = this.resolution_ctx, g = w(), f = l, h = Math.min(n + 1, d - m), g[f] = 1, k = 1; k < h; k++) {
|
||||
if ((l = b[this.rtl ? d - 1 - m - k : m + k]) && l.length >= this.minlength && !g[l]) {
|
||||
g[l] = 1;
|
||||
const u = M(e + (d / 2 > e ? 0 : 1), d, m, h - 1, k - 1), x = this.bidirectional && l > f;
|
||||
this.push_index(t, x ? f : l, u, a, c, x ? l : f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.fastupdate || (this.register[a] = 1);
|
||||
}
|
||||
this.fastupdate || (this.register[a] = 1);
|
||||
}
|
||||
return this;
|
||||
};
|
||||
@@ -359,10 +362,10 @@ L.prototype.search = function(a, b, c) {
|
||||
if (a && (a = this.encode(a), e = a.length, 1 < e)) {
|
||||
c = w();
|
||||
var k = [];
|
||||
for (let p = 0, q = 0, t; p < e; p++) {
|
||||
if ((t = a[p]) && t.length >= this.minlength && !c[t]) {
|
||||
if (this.optimize || f || this.map[t]) {
|
||||
k[q++] = t, c[t] = 1;
|
||||
for (let n = 0, u = 0, q; n < e; n++) {
|
||||
if ((q = a[n]) && q.length >= this.minlength && !c[q]) {
|
||||
if (this.optimize || f || this.map[q]) {
|
||||
k[u++] = q, c[q] = 1;
|
||||
} else {
|
||||
return d;
|
||||
}
|
||||
@@ -377,13 +380,13 @@ L.prototype.search = function(a, b, c) {
|
||||
b || (b = 100);
|
||||
h = this.depth && 1 < e && !1 !== h;
|
||||
c = 0;
|
||||
let n;
|
||||
h ? (n = a[0], c = 1) : 1 < e && a.sort(aa);
|
||||
for (let p, q; c < e; c++) {
|
||||
q = a[c];
|
||||
h ? (p = this.add_result(d, f, b, g, 2 === e, q, n), f && !1 === p && d.length || (n = q)) : p = this.add_result(d, f, b, g, 1 === e, q);
|
||||
if (p) {
|
||||
return p;
|
||||
let m;
|
||||
h ? (m = a[0], c = 1) : 1 < e && a.sort(aa);
|
||||
for (let n, u; c < e; c++) {
|
||||
u = a[c];
|
||||
h ? (n = this.add_result(d, f, b, g, 2 === e, u, m), f && !1 === n && d.length || (m = u)) : n = this.add_result(d, f, b, g, 1 === e, u);
|
||||
if (n) {
|
||||
return n;
|
||||
}
|
||||
if (f && c === e - 1) {
|
||||
k = d.length;
|
||||
@@ -400,22 +403,22 @@ L.prototype.search = function(a, b, c) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return ja(d, b, g, f);
|
||||
return ka(d, b, g, f);
|
||||
};
|
||||
L.prototype.add_result = function(a, b, c, d, e, f, g) {
|
||||
let h = [], k = g ? this.ctx : this.map;
|
||||
this.optimize || (k = ra(k, f, g, this.bidirectional));
|
||||
if (k) {
|
||||
let n = 0;
|
||||
const p = Math.min(k.length, g ? this.resolution_ctx : this.resolution);
|
||||
for (let q = 0, t = 0, m, l; q < p; q++) {
|
||||
if (m = k[q]) {
|
||||
if (this.optimize && (m = ra(m, f, g, this.bidirectional)), d && m && e && (l = m.length, l <= d ? (d -= l, m = null) : (m = m.slice(d), d = 0)), m && (h[n++] = m, e && (t += m.length, t >= c))) {
|
||||
let m = 0;
|
||||
const n = Math.min(k.length, g ? this.resolution_ctx : this.resolution);
|
||||
for (let u = 0, q = 0, p, l; u < n; u++) {
|
||||
if (p = k[u]) {
|
||||
if (this.optimize && (p = ra(p, f, g, this.bidirectional)), d && p && e && (l = p.length, l <= d ? (d -= l, p = null) : (p = p.slice(d), d = 0)), p && (h[m++] = p, e && (q += p.length, q >= c))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (n) {
|
||||
if (m) {
|
||||
if (e) {
|
||||
return qa(h, c, 0);
|
||||
}
|
||||
@@ -474,7 +477,7 @@ function N(a, b, c, d, e) {
|
||||
}
|
||||
return f;
|
||||
}
|
||||
L.prototype.searchCache = la;
|
||||
L.prototype.searchCache = ma;
|
||||
L.prototype.export = function(a, b, c, d, e) {
|
||||
let f, g;
|
||||
switch(e || (e = 0)) {
|
||||
@@ -509,7 +512,7 @@ L.prototype.export = function(a, b, c, d, e) {
|
||||
};
|
||||
L.prototype.import = function(a, b) {
|
||||
if (b) {
|
||||
switch(y(b) && (b = JSON.parse(b)), a) {
|
||||
switch(x(b) && (b = JSON.parse(b)), a) {
|
||||
case "cfg":
|
||||
this.optimize = !!b.opt;
|
||||
break;
|
||||
@@ -525,7 +528,7 @@ L.prototype.import = function(a, b) {
|
||||
}
|
||||
}
|
||||
};
|
||||
ia(L.prototype);
|
||||
ja(L.prototype);
|
||||
function sa(a) {
|
||||
a = a.data;
|
||||
var b = self._index;
|
||||
@@ -545,9 +548,9 @@ function sa(a) {
|
||||
}
|
||||
}
|
||||
;let ta = 0;
|
||||
function P(a) {
|
||||
function O(a) {
|
||||
var b;
|
||||
a ? C(b = a.encode) && (a.encode = b.toString()) : a = {};
|
||||
a ? D(b = a.encode) && (a.encode = b.toString()) : a = {};
|
||||
(b = (self || window)._factory) && (b = b.toString());
|
||||
const c = self.exports, d = this;
|
||||
this.worker = ua(b, c, a.worker);
|
||||
@@ -574,11 +577,11 @@ Q("search");
|
||||
Q("update");
|
||||
Q("remove");
|
||||
function Q(a) {
|
||||
P.prototype[a] = P.prototype[a + "Async"] = function() {
|
||||
O.prototype[a] = O.prototype[a + "Async"] = function() {
|
||||
const b = this, c = [].slice.call(arguments);
|
||||
var d = c[c.length - 1];
|
||||
let e;
|
||||
C(d) && (e = d, c.splice(c.length - 1, 1));
|
||||
D(d) && (e = d, c.splice(c.length - 1, 1));
|
||||
d = new Promise(function(f) {
|
||||
setTimeout(function() {
|
||||
b.resolver[++ta] = f;
|
||||
@@ -591,7 +594,7 @@ function Q(a) {
|
||||
function ua(a, b, c) {
|
||||
let d;
|
||||
try {
|
||||
d = b ? eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")') : a ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + sa.toString()], {type:"text/javascript"}))) : new Worker(y(c) ? c : "worker/worker.js", {type:"module"});
|
||||
d = b ? eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")') : a ? new Worker(URL.createObjectURL(new Blob(["onmessage=" + sa.toString()], {type:"text/javascript"}))) : new Worker(x(c) ? c : "worker/worker.js", {type:"module"});
|
||||
} catch (e) {
|
||||
}
|
||||
return d;
|
||||
@@ -617,12 +620,12 @@ function ua(a, b, c) {
|
||||
this.async = !1;
|
||||
c = w();
|
||||
let d = b.index || b.field || b;
|
||||
y(d) && (d = [d]);
|
||||
x(d) && (d = [d]);
|
||||
for (let e = 0, f, g; e < d.length; e++) {
|
||||
f = d[e], y(f) || (g = f, f = f.field), g = z(g) ? Object.assign({}, a, g) : a, this.worker && (c[f] = new P(g), c[f].worker || (this.worker = !1)), this.worker || (c[f] = new L(g, this.register)), this.tree[e] = S(f, this.marker), this.field[e] = f;
|
||||
f = d[e], x(f) || (g = f, f = f.field), g = z(g) ? Object.assign({}, a, g) : a, this.worker && (c[f] = new O(g), c[f].worker || (this.worker = !1)), this.worker || (c[f] = new L(g, this.register)), this.tree[e] = S(f, this.marker), this.field[e] = f;
|
||||
}
|
||||
if (this.storetree) {
|
||||
for (a = b.store, y(a) && (a = [a]), b = 0; b < a.length; b++) {
|
||||
for (a = b.store, x(a) && (a = [a]), b = 0; b < a.length; b++) {
|
||||
this.storetree[b] = S(a[b], this.marker);
|
||||
}
|
||||
}
|
||||
@@ -638,7 +641,7 @@ function S(a, b) {
|
||||
return 1 < d ? c : c[0];
|
||||
}
|
||||
function T(a, b) {
|
||||
if (y(b)) {
|
||||
if (x(b)) {
|
||||
a = a[b];
|
||||
} else {
|
||||
for (let c = 0; a && c < b.length; c++) {
|
||||
@@ -663,7 +666,7 @@ function U(a, b, c, d, e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
function W(a, b, c, d, e, f, g, h) {
|
||||
function V(a, b, c, d, e, f, g, h) {
|
||||
a = a[g];
|
||||
if (d === b.length - 1) {
|
||||
if (a.constructor === Array) {
|
||||
@@ -680,10 +683,10 @@ function W(a, b, c, d, e, f, g, h) {
|
||||
if (a) {
|
||||
if (a.constructor === Array) {
|
||||
for (g = 0; g < a.length; g++) {
|
||||
W(a, b, c, d, e, f, g, h);
|
||||
V(a, b, c, d, e, f, g, h);
|
||||
}
|
||||
} else {
|
||||
g = b[++d], W(a, b, c, d, e, f, g, h);
|
||||
g = b[++d], V(a, b, c, d, e, f, g, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -691,15 +694,15 @@ function W(a, b, c, d, e, f, g, h) {
|
||||
R.prototype.add = function(a, b, c) {
|
||||
z(a) && (b = a, a = T(b, this.key));
|
||||
if (b && (a || 0 === a)) {
|
||||
if (this.register[a]) {
|
||||
if (!c && this.register[a]) {
|
||||
return this.update(a, b);
|
||||
}
|
||||
for (let d = 0, e, f; d < this.field.length; d++) {
|
||||
f = this.field[d], e = this.tree[d], y(e) && (e = [e]), W(b, e, this.marker, 0, this.index[f], a, e[0], c);
|
||||
f = this.field[d], e = this.tree[d], x(e) && (e = [e]), V(b, e, this.marker, 0, this.index[f], a, e[0], c);
|
||||
}
|
||||
if (this.tag) {
|
||||
let d = T(b, this.tag), e = w();
|
||||
y(d) && (d = [d]);
|
||||
x(d) && (d = [d]);
|
||||
for (let f = 0, g, h; f < d.length; f++) {
|
||||
if (g = d[f], !e[g] && (e[g] = 1, h = this.tagindex[g] || (this.tagindex[g] = []), !c || -1 === h.indexOf(a))) {
|
||||
if (h[h.length] = a, this.fastupdate) {
|
||||
@@ -709,12 +712,12 @@ R.prototype.add = function(a, b, c) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.store) {
|
||||
if (this.store && (!c || !this.store[a])) {
|
||||
let d;
|
||||
if (this.storetree) {
|
||||
d = w();
|
||||
for (let e = 0, f; e < this.storetree.length; e++) {
|
||||
f = this.storetree[e], y(f) ? d[f] = b[f] : U(b, d, f, 0, f[0]);
|
||||
f = this.storetree[e], x(f) ? d[f] = b[f] : U(b, d, f, 0, f[0]);
|
||||
}
|
||||
}
|
||||
this.store[a] = d || b;
|
||||
@@ -731,12 +734,13 @@ R.prototype.update = function(a, b) {
|
||||
R.prototype.remove = function(a) {
|
||||
z(a) && (a = T(a, this.key));
|
||||
if (this.register[a]) {
|
||||
var b = this.fastupdate && !this.worker;
|
||||
for (var c = 0; c < this.field.length && (this.index[this.field[c]].remove(a, b), !b); c++) {
|
||||
for (var b = 0; b < this.field.length && (this.index[this.field[b]].remove(a, !this.worker), !this.fastupdate); b++) {
|
||||
}
|
||||
if (this.tag && !b) {
|
||||
for (let d in this.tagindex) {
|
||||
b = this.tagindex[d], c = b.indexOf(a), -1 !== c && (1 < b.length ? b.splice(c, 1) : delete this.tagindex[d]);
|
||||
if (this.tag && !this.fastupdate) {
|
||||
for (let c in this.tagindex) {
|
||||
b = this.tagindex[c];
|
||||
const d = b.indexOf(a);
|
||||
-1 !== d && (1 < b.length ? b.splice(d, 1) : delete this.tagindex[c]);
|
||||
}
|
||||
}
|
||||
this.store && delete this.store[a];
|
||||
@@ -746,80 +750,80 @@ R.prototype.remove = function(a) {
|
||||
};
|
||||
R.prototype.search = function(a, b, c, d) {
|
||||
z(a) ? (c = a, a = c.query) : z(b) && (c = b, b = 0);
|
||||
let e = [], f = [], g, h, k, n, p, q, t = 0;
|
||||
let e = [], f = [], g, h, k, m, n, u, q = 0;
|
||||
if (c) {
|
||||
if (c.constructor === Array) {
|
||||
k = c, c = null;
|
||||
} else {
|
||||
k = (g = c.pluck) || c.index || c.field || c;
|
||||
n = c.tag;
|
||||
m = c.tag;
|
||||
h = this.store && c.enrich;
|
||||
p = "and" === c.bool;
|
||||
n = "and" === c.bool;
|
||||
b = c.limit || 100;
|
||||
q = c.offset || 0;
|
||||
if (n && (y(n) && (n = [n]), !a)) {
|
||||
for (let l = 0, u; l < n.length; l++) {
|
||||
if (u = va.call(this, n[l], b, q, h)) {
|
||||
e[e.length] = u, t++;
|
||||
u = c.offset || 0;
|
||||
if (m && (x(m) && (m = [m]), !a)) {
|
||||
for (let l = 0, t; l < m.length; l++) {
|
||||
if (t = va.call(this, m[l], b, u, h)) {
|
||||
e[e.length] = t, q++;
|
||||
}
|
||||
}
|
||||
return t ? e : [];
|
||||
return q ? e : [];
|
||||
}
|
||||
y(k) ? k = [k] : k.constructor === Array || (k = null);
|
||||
x(k) && (k = [k]);
|
||||
}
|
||||
}
|
||||
k || (k = this.field);
|
||||
p = p && (1 < k.length || n && 1 < n.length);
|
||||
const m = !d && (this.worker || this.async) && [];
|
||||
for (let l = 0, u, x, A; l < k.length; l++) {
|
||||
n = n && (1 < k.length || m && 1 < m.length);
|
||||
const p = !d && (this.worker || this.async) && [];
|
||||
for (let l = 0, t, y, C; l < k.length; l++) {
|
||||
let B;
|
||||
x = k[l];
|
||||
y(x) || (B = x, x = x.field);
|
||||
if (m) {
|
||||
m[l] = this.index[x].searchAsync(a, b, B || c);
|
||||
y = k[l];
|
||||
x(y) || (B = y, y = y.field);
|
||||
if (p) {
|
||||
p[l] = this.index[y].searchAsync(a, b, B || c);
|
||||
} else {
|
||||
A = (u = d ? d[l] : this.index[x].search(a, b, B || c)) && u.length;
|
||||
if (n && A) {
|
||||
const D = [];
|
||||
let ma = 0;
|
||||
p && (D[0] = [u]);
|
||||
for (let V = 0, na, O; V < n.length; V++) {
|
||||
if (na = n[V], A = (O = this.tagindex[na]) && O.length) {
|
||||
ma++, D[D.length] = p ? [O] : O;
|
||||
C = (t = d ? d[l] : this.index[y].search(a, b, B || c)) && t.length;
|
||||
if (m && C) {
|
||||
const A = [];
|
||||
let G = 0;
|
||||
n && (A[0] = [t]);
|
||||
for (let W = 0, na, P; W < m.length; W++) {
|
||||
if (na = m[W], C = (P = this.tagindex[na]) && P.length) {
|
||||
G++, A[A.length] = n ? [P] : P;
|
||||
}
|
||||
}
|
||||
ma && (u = p ? ja(D, b || 100, q || 0) : ka(u, D), A = u.length);
|
||||
G && (t = n ? ka(A, b || 100, u || 0) : la(t, A), C = t.length);
|
||||
}
|
||||
if (A) {
|
||||
f[t] = x, e[t++] = u;
|
||||
if (C) {
|
||||
f[q] = y, e[q++] = t;
|
||||
} else {
|
||||
if (p) {
|
||||
if (n) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m) {
|
||||
if (p) {
|
||||
const l = this;
|
||||
return new Promise(function(u) {
|
||||
Promise.all(m).then(function(x) {
|
||||
u(l.search(a, b, c, x));
|
||||
return new Promise(function(t) {
|
||||
Promise.all(p).then(function(y) {
|
||||
t(l.search(a, b, c, y));
|
||||
});
|
||||
});
|
||||
}
|
||||
if (!t) {
|
||||
if (!q) {
|
||||
return [];
|
||||
}
|
||||
if (g && (!h || !this.store)) {
|
||||
return e[0];
|
||||
}
|
||||
for (let l = 0, u; l < f.length; l++) {
|
||||
u = e[l];
|
||||
u.length && h && (u = wa.call(this, u));
|
||||
for (let l = 0, t; l < f.length; l++) {
|
||||
t = e[l];
|
||||
t.length && h && (t = wa.call(this, t));
|
||||
if (g) {
|
||||
return u;
|
||||
return t;
|
||||
}
|
||||
e[l] = {field:f[l], result:u};
|
||||
e[l] = {field:f[l], result:t};
|
||||
}
|
||||
return e;
|
||||
};
|
||||
@@ -850,7 +854,7 @@ R.prototype.set = function(a, b) {
|
||||
this.store[a] = b;
|
||||
return this;
|
||||
};
|
||||
R.prototype.searchCache = la;
|
||||
R.prototype.searchCache = ma;
|
||||
R.prototype.export = function(a, b, c, d, e) {
|
||||
e || (e = 0);
|
||||
d || (d = 0);
|
||||
@@ -879,7 +883,7 @@ R.prototype.export = function(a, b, c, d, e) {
|
||||
};
|
||||
R.prototype.import = function(a, b) {
|
||||
if (b) {
|
||||
switch(y(b) && (b = JSON.parse(b)), a) {
|
||||
switch(x(b) && (b = JSON.parse(b)), a) {
|
||||
case "tag":
|
||||
this.tagindex = b;
|
||||
break;
|
||||
@@ -901,11 +905,11 @@ R.prototype.import = function(a, b) {
|
||||
}
|
||||
}
|
||||
};
|
||||
ia(R.prototype);
|
||||
ja(R.prototype);
|
||||
var ya = {encode:xa, rtl:!1, tokenize:""};
|
||||
const za = /[\W_]+/, Aa = F("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"), Ba = F("[\u00e8\u00e9\u00ea\u00eb]"), Ca = F("[\u00ec\u00ed\u00ee\u00ef]"), Da = F("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), Ea = F("[\u00f9\u00fa\u00fb\u00fc\u0171]"), Fa = F("[\u00fd\u0177\u00ff]"), Ga = F("\u00f1"), Ha = F("[\u00e7c]"), Ia = F("\u00df"), Ja = F(" & "), Ka = [Aa, "a", Ba, "e", Ca, "i", Da, "o", Ea, "u", Fa, "y", Ga, "n", Ha, "k", Ia, "s", Ja, " and "];
|
||||
const za = /[\W_]+/, Aa = E("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"), Ba = E("[\u00e8\u00e9\u00ea\u00eb]"), Ca = E("[\u00ec\u00ed\u00ee\u00ef]"), Da = E("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"), Ea = E("[\u00f9\u00fa\u00fb\u00fc\u0171]"), Fa = E("[\u00fd\u0177\u00ff]"), Ga = E("\u00f1"), Ha = E("[\u00e7c]"), Ia = E("\u00df"), Ja = E(" & "), Ka = [Aa, "a", Ba, "e", Ca, "i", Da, "o", Ea, "u", Fa, "y", Ga, "n", Ha, "k", Ia, "s", Ja, " and "];
|
||||
function xa(a) {
|
||||
return this.pipeline(E(a).toLowerCase(), !a.normalize && Ka, za, !1);
|
||||
return this.pipeline(ca(a).toLowerCase(), !a.normalize && Ka, za, !1);
|
||||
}
|
||||
;var Ma = {encode:La, rtl:!1, tokenize:"strict"};
|
||||
const Na = /[^a-z0-9]+/, Oa = {b:"p", v:"f", w:"f", z:"s", x:"s", "\u00df":"s", d:"t", n:"m", c:"k", g:"k", j:"k", q:"k", i:"e", y:"e", u:"o"};
|
||||
@@ -918,10 +922,10 @@ function La(a) {
|
||||
if ((a = c[e]) && (!this.filter || !this.filter[a])) {
|
||||
f = a[0];
|
||||
let h = Oa[f] || f, k = h;
|
||||
for (let n = 1; n < a.length; n++) {
|
||||
f = a[n];
|
||||
const p = Oa[f] || f;
|
||||
p && p !== k && (h += p, k = p);
|
||||
for (let m = 1; m < a.length; m++) {
|
||||
f = a[m];
|
||||
const n = Oa[f] || f;
|
||||
n && n !== k && (h += n, k = n);
|
||||
}
|
||||
b[g++] = h;
|
||||
}
|
||||
@@ -930,28 +934,28 @@ function La(a) {
|
||||
return b;
|
||||
}
|
||||
;var Qa = {encode:Pa, rtl:!1, tokenize:""};
|
||||
const Ra = F("ae"), Sa = F("oe"), Ta = F("sh"), Ua = F("th"), Va = F("ph"), Wa = F("pf"), Xa = [Ra, "a", Sa, "o", Ta, "s", Ua, "t", Va, "f", Wa, "f", ];
|
||||
const Ra = E("ae"), Sa = E("oe"), Ta = E("sh"), Ua = E("th"), Va = E("ph"), Wa = E("pf"), Xa = [Ra, "a", Sa, "o", Ta, "s", Ua, "t", Va, "f", Wa, "f", E("(?![aeo])h(?![aeo])"), "", E("(?!^[aeo])h(?!^[aeo])"), ""];
|
||||
function Pa(a, b) {
|
||||
a && (a = La.call(this, a).join(" "), 2 < a.length && (a = G(a, Xa)), b || (1 < a.length && (a = H(a)), a && (a = a.split(" "))));
|
||||
a && (a = La.call(this, a).join(" "), 2 < a.length && (a = F(a, Xa)), b || (1 < a.length && (a = H(a)), a && (a = a.split(" "))));
|
||||
return a;
|
||||
}
|
||||
;var Za = {encode:Ya, rtl:!1, tokenize:""};
|
||||
const $a = F("(?!\\b)[aeiouy]");
|
||||
const $a = E("(?!\\b)[aeo]");
|
||||
function Ya(a) {
|
||||
a && (a = Pa.call(this, a, !0), 1 < a.length && (a = a.replace($a, "")), 1 < a.length && (a = H(a)), a && (a = a.split(" ")));
|
||||
return a;
|
||||
}
|
||||
;I["latin:default"] = ea;
|
||||
;I["latin:default"] = fa;
|
||||
I["latin:simple"] = ya;
|
||||
I["latin:balance"] = Ma;
|
||||
I["latin:advanced"] = Qa;
|
||||
I["latin:extra"] = Za;
|
||||
const X = self;
|
||||
let Y;
|
||||
const Z = {Index:L, Document:R, Worker:P, registerCharset:function(a, b) {
|
||||
const Z = {Index:L, Document:R, Worker:O, registerCharset:function(a, b) {
|
||||
I[a] = b;
|
||||
}, registerLanguage:function(a, b) {
|
||||
ha[a] = b;
|
||||
ia[a] = b;
|
||||
}};
|
||||
(Y = X.define) && Y.amd ? Y([], function() {
|
||||
return Z;
|
||||
|
72
dist/flexsearch.es5.js
vendored
@@ -1,45 +1,45 @@
|
||||
/**!
|
||||
* FlexSearch.js v0.7.0-beta (ES5)
|
||||
* FlexSearch.js v0.7.0 (ES5)
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Licence: Apache-2.0
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
(function(self){'use strict';var u;function aa(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}var v="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
|
||||
function ba(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var w=ba(this);function y(a,b){if(b)a:{var c=w;a=a.split(".");for(var d=0;d<a.length-1;d++){var f=a[d];if(!(f in c))break a;c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&v(c,a,{configurable:!0,writable:!0,value:b})}}
|
||||
y("Symbol",function(a){function b(g){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(g||"")+"_"+f++,g)}function c(g,e){this.h=g;v(this,"description",{configurable:!0,writable:!0,value:e})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",f=0;return b});
|
||||
y("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c<b.length;c++){var d=w[b[c]];"function"===typeof d&&"function"!=typeof d.prototype[a]&&v(d.prototype,a,{configurable:!0,writable:!0,value:function(){return ca(aa(this))}})}return a});function ca(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
|
||||
function da(a,b){a instanceof String&&(a+="");var c=0,d=!1,f={next:function(){if(!d&&c<a.length){var g=c++;return{value:b(g,a[g]),done:!1}}d=!0;return{done:!0,value:void 0}}};f[Symbol.iterator]=function(){return f};return f}y("Array.prototype.keys",function(a){return a?a:function(){return da(this,function(b){return b})}});function ea(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):{next:aa(a)}}
|
||||
y("Promise",function(a){function b(e){this.l=0;this.m=void 0;this.h=[];this.N=!1;var h=this.A();try{e(h.resolve,h.reject)}catch(k){h.reject(k)}}function c(){this.h=null}function d(e){return e instanceof b?e:new b(function(h){h(e)})}if(a)return a;c.prototype.l=function(e){if(null==this.h){this.h=[];var h=this;this.m(function(){h.C()})}this.h.push(e)};var f=w.setTimeout;c.prototype.m=function(e){f(e,0)};c.prototype.C=function(){for(;this.h&&this.h.length;){var e=this.h;this.h=[];for(var h=0;h<e.length;++h){var k=
|
||||
e[h];e[h]=null;try{k()}catch(l){this.A(l)}}}this.h=null};c.prototype.A=function(e){this.m(function(){throw e;})};b.prototype.A=function(){function e(l){return function(n){k||(k=!0,l.call(h,n))}}var h=this,k=!1;return{resolve:e(this.T),reject:e(this.C)}};b.prototype.T=function(e){if(e===this)this.C(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof b)this.V(e);else{a:switch(typeof e){case "object":var h=null!=e;break a;case "function":h=!0;break a;default:h=!1}h?this.S(e):this.I(e)}};
|
||||
(function(self){'use strict';var t;function aa(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}}var v="function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
|
||||
function ba(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");}var w=ba(this);function x(a,b){if(b)a:{var c=w;a=a.split(".");for(var d=0;d<a.length-1;d++){var f=a[d];if(!(f in c))break a;c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&v(c,a,{configurable:!0,writable:!0,value:b})}}
|
||||
x("Symbol",function(a){function b(g){if(this instanceof b)throw new TypeError("Symbol is not a constructor");return new c(d+(g||"")+"_"+f++,g)}function c(g,e){this.h=g;v(this,"description",{configurable:!0,writable:!0,value:e})}if(a)return a;c.prototype.toString=function(){return this.h};var d="jscomp_symbol_"+(1E9*Math.random()>>>0)+"_",f=0;return b});
|
||||
x("Symbol.iterator",function(a){if(a)return a;a=Symbol("Symbol.iterator");for(var b="Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "),c=0;c<b.length;c++){var d=w[b[c]];"function"===typeof d&&"function"!=typeof d.prototype[a]&&v(d.prototype,a,{configurable:!0,writable:!0,value:function(){return ca(aa(this))}})}return a});function ca(a){a={next:a};a[Symbol.iterator]=function(){return this};return a}
|
||||
function da(a,b){a instanceof String&&(a+="");var c=0,d=!1,f={next:function(){if(!d&&c<a.length){var g=c++;return{value:b(g,a[g]),done:!1}}d=!0;return{done:!0,value:void 0}}};f[Symbol.iterator]=function(){return f};return f}x("Array.prototype.keys",function(a){return a?a:function(){return da(this,function(b){return b})}});function ea(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):{next:aa(a)}}
|
||||
x("Promise",function(a){function b(e){this.l=0;this.m=void 0;this.h=[];this.N=!1;var h=this.A();try{e(h.resolve,h.reject)}catch(k){h.reject(k)}}function c(){this.h=null}function d(e){return e instanceof b?e:new b(function(h){h(e)})}if(a)return a;c.prototype.l=function(e){if(null==this.h){this.h=[];var h=this;this.m(function(){h.C()})}this.h.push(e)};var f=w.setTimeout;c.prototype.m=function(e){f(e,0)};c.prototype.C=function(){for(;this.h&&this.h.length;){var e=this.h;this.h=[];for(var h=0;h<e.length;++h){var k=
|
||||
e[h];e[h]=null;try{k()}catch(l){this.A(l)}}}this.h=null};c.prototype.A=function(e){this.m(function(){throw e;})};b.prototype.A=function(){function e(l){return function(p){k||(k=!0,l.call(h,p))}}var h=this,k=!1;return{resolve:e(this.T),reject:e(this.C)}};b.prototype.T=function(e){if(e===this)this.C(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof b)this.V(e);else{a:switch(typeof e){case "object":var h=null!=e;break a;case "function":h=!0;break a;default:h=!1}h?this.S(e):this.I(e)}};
|
||||
b.prototype.S=function(e){var h=void 0;try{h=e.then}catch(k){this.C(k);return}"function"==typeof h?this.W(h,e):this.I(e)};b.prototype.C=function(e){this.O(2,e)};b.prototype.I=function(e){this.O(1,e)};b.prototype.O=function(e,h){if(0!=this.l)throw Error("Cannot settle("+e+", "+h+"): Promise already settled in state"+this.l);this.l=e;this.m=h;2===this.l&&this.U();this.P()};b.prototype.U=function(){var e=this;f(function(){if(e.R()){var h=w.console;"undefined"!==typeof h&&h.error(e.m)}},1)};b.prototype.R=
|
||||
function(){if(this.N)return!1;var e=w.CustomEvent,h=w.Event,k=w.dispatchEvent;if("undefined"===typeof k)return!0;"function"===typeof e?e=new e("unhandledrejection",{cancelable:!0}):"function"===typeof h?e=new h("unhandledrejection",{cancelable:!0}):(e=w.document.createEvent("CustomEvent"),e.initCustomEvent("unhandledrejection",!1,!0,e));e.promise=this;e.reason=this.m;return k(e)};b.prototype.P=function(){if(null!=this.h){for(var e=0;e<this.h.length;++e)g.l(this.h[e]);this.h=null}};var g=new c;b.prototype.V=
|
||||
function(e){var h=this.A();e.K(h.resolve,h.reject)};b.prototype.W=function(e,h){var k=this.A();try{e.call(h,k.resolve,k.reject)}catch(l){k.reject(l)}};b.prototype.then=function(e,h){function k(m,q){return"function"==typeof m?function(r){try{l(m(r))}catch(t){n(t)}}:q}var l,n,p=new b(function(m,q){l=m;n=q});this.K(k(e,l),k(h,n));return p};b.prototype.catch=function(e){return this.then(void 0,e)};b.prototype.K=function(e,h){function k(){switch(l.l){case 1:e(l.m);break;case 2:h(l.m);break;default:throw Error("Unexpected state: "+
|
||||
l.l);}}var l=this;null==this.h?g.l(k):this.h.push(k);this.N=!0};b.resolve=d;b.reject=function(e){return new b(function(h,k){k(e)})};b.race=function(e){return new b(function(h,k){for(var l=ea(e),n=l.next();!n.done;n=l.next())d(n.value).K(h,k)})};b.all=function(e){var h=ea(e),k=h.next();return k.done?d([]):new b(function(l,n){function p(r){return function(t){m[r]=t;q--;0==q&&l(m)}}var m=[],q=0;do m.push(void 0),q++,d(k.value).K(p(m.length-1),n),k=h.next();while(!k.done)})};return b});
|
||||
var fa="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&(a[f]=d[f])}return a};y("Object.assign",function(a){return a||fa});function B(a){return"undefined"!==typeof a?a:!0}function ha(a){for(var b=Array(a),c=0;c<a;c++)b[c]=C();return b}function C(){return Object.create(null)}function ia(a,b){return b.length-a.length}function E(a){return"string"===typeof a}function F(a){return"object"===typeof a}function H(a){return"function"===typeof a};var ja=/[\u0300-\u036f]/g;function ka(a){a.normalize&&(a=a.normalize("NFD").replace(ja,""));return a}function la(a,b){for(var c=Object.keys(a),d=c.length,f=[],g="",e=0,h=0,k,l;h<d;h++)k=c[h],(l=a[k])?(f[e++]=I(b?"(?!\\b)"+k+"(\\b|_)":k),f[e++]=l):g+=(g?"|":"")+k;g&&(f[e++]=I(b?"(?!\\b)("+g+")(\\b|_)":"("+g+")"),f[e]="");return f}function J(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function I(a){return new RegExp(a,"g")}
|
||||
function ma(a){for(var b="",c="",d=0,f=a.length,g=void 0;d<f;d++)(g=a[d])!==c&&(b+=c=g);return b};var oa={encode:na,F:!1,G:""},pa=/[\W_]+/;function na(a){return qa(this,ka(a).toLowerCase(),!1,pa)};var ra={},K={};function sa(a){L(a,"add");L(a,"append");L(a,"search");L(a,"update");L(a,"remove")}function L(a,b){a[b+"Async"]=function(){var c=this,d=arguments,f=d[d.length-1];if(H(f)){var g=f;delete d[d.length-1]}f=new Promise(function(e){setTimeout(function(){c.async=!0;var h=c[b].apply(c,d);c.async=!1;e(h)})});return g?(f.then(g),this):f}};function ta(a,b,c,d){var f=a.length,g=[],e,h=0;d&&(d=[]);for(--f;0<=f;f--){for(var k=a[f],l=k.length,n=C(),p=!A,m=0;m<l;m++){var q=k[m],r=q.length;if(r)for(var t=0,z=void 0,x;t<r;t++)if(x=q[t],A){if(A[x]){if(!f)if(c)c--;else if(g[h++]=x,h===b)return g;if(f||d)n[x]=1;p=!0}if(d&&(e[x]=(z=e[x])?z++:z=1,z<l)){var D=d[z-1]||(d[z-1]=[]);D[D.length]=x}}else n[x]=1}if(d)A||(e=n);else if(!p)return[];var A=n}if(d)for(a=d.length-1;0<=a;a--)for(e=d[a],f=e.length,k=0;k<f;k++)if(l=e[k],!A[l]){if(c)c--;else if(g[h++]=
|
||||
l,h===b)return g;A[l]=1}return g}function ua(a,b){for(var c=C(),d=C(),f=[],g=0;g<a.length;g++)c[a[g]]=1;for(a=0;a<b.length;a++){g=b[a];for(var e=0,h;e<g.length;e++)h=g[e],c[h]&&!d[h]&&(d[h]=1,f[f.length]=h)}return f};function M(a){this.l=!0!==a&&a;this.cache=C();this.h=[]}function va(a,b,c){F(a)&&(a=a.query);var d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}M.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};M.prototype.get=function(a){var b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){var c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};var wa={memory:{charset:"latin:extra",H:3,D:3,s:!1,B:"memory"},performance:{threshold:8,D:3,context:{depth:1,J:!0}},match:{charset:"latin:extra",G:"full",H:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,J:!0}},"default":{H:3,threshold:0,depth:3}};function xa(a,b,c,d,f,g){setTimeout(function(){var e=a(c,JSON.stringify(g));e&&e.then?e.then(function(){b.export(a,b,c,d,f+1)}):b.export(a,b,c,d,f+1)})};function N(a,b){if(!(this instanceof N))return new N(a);var c;if(a){E(a)?a=wa[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;E(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=K[c]);E(d)&&(d=ra[d])}else a={};var f,g,e=a.context||{};this.encode=a.encode||c&&c.encode||na;this.register=b||C();this.H=f=a.resolution||9;this.G=b=c&&c.G||a.tokenize||"strict";this.depth="strict"===b&&e.depth;this.J=B(e.bidirectional);this.B=g=B(a.optimize);this.s=B(a.fastupdate);this.D=a.minlength||1;this.map=
|
||||
g?ha(f):C();this.l=f=e.resolution||1;this.h=g?ha(f):C();this.F=c&&c.F||a.rtl;this.L=(b=a.matcher||d&&d.L)&&la(b,!1);this.M=(b=a.stemmer||d&&d.M)&&la(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=C();e=0;for(f=c.length;e<f;e++)d[c[e]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new M(b)}
|
||||
function qa(a,b,c,d){if(b&&(c&&(b=J(b,c)),a.L&&(b=J(b,a.L)),a.M&&1<b.length&&(b=J(b,a.M)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(var f=0,g=0;f<c;f++){var e=b[f];e&&!a[e]&&(d[g++]=e)}b=d}return b}return b}u=N.prototype;u.append=function(a,b){return this.add(a,b,!0)};
|
||||
u.add=function(a,b,c,d){if(!d&&!c&&this.register[a])return this.update(a,b);if(b&&(a||0===a)&&(b=this.encode(b),d=b.length)){for(var f=this.depth,g=this.H,e=C(),h=C(),k=0;k<d;k++){var l=b[this.F?d-1-k:k],n=l.length;if(l&&n>=this.D&&(f||!e[l])){var p=O(g,d,k),m="";switch(this.G){case "full":if(3<n){for(p=0;p<n;p++)for(var q=n;q>p;q--)if(q-p>=this.D){var r=O(g,d,k,n,p);m=l.substring(p,q);P(this,e,m,r,a,c)}break}case "reverse":if(2<n){for(q=n-1;0<q;q--)m=l[q]+m,m.length>=this.D&&P(this,e,m,O(g,d,k,n,
|
||||
q),a,c);m=""}case "forward":if(1<n)for(q=0;q<n;q++)m+=l[q],m.length>=this.D&&P(this,e,m,p,a,c);break;default:if(P(this,e,l,p,a,c),f&&1<d&&k<d-1)for(n=this.l,m=C(),p=l,q=Math.min(f+1,d-k),r=m[p]=1;r<q;r++)if((l=b[this.F?d-1-k-r:k+r])&&l.length>=this.D&&!m[l]){m[l]=1;var t=this.J&&l>p;P(this,h,t?p:l,O(n+(d/2>n?0:1),d,k,q-1,r-1),a,c,t?l:p)}}}}this.s||(this.register[a]=1)}return this};function O(a,b,c,d,f){return c&&1<a?b+(d||0)<=a?c+(f||0):(a-1)/(b+(d||0))*(c+(f||0))+1|0:0}
|
||||
function P(a,b,c,d,f,g,e){var h=e?a.h:a.map;if(!b[c]||e&&!b[c][e])a.B&&(h=h[d]),e?(b=b[c]||(b[c]=C()),b[e]=1,h=h[e]||(h[e]=C())):b[c]=1,h=h[c]||(h[c]=[]),a.B||(h=h[d]||(h[d]=[])),g&&-1!==h.indexOf(f)||(h[h.length]=f,a.s&&(a=a.register[f]||(a.register[f]=[]),a[a.length]=h))}
|
||||
u.search=function(a,b,c){F(a)?(c=a,a=c.query):F(b)&&(c=b);var d=[],f=0;if(c){b=c.limit;f=c.offset||0;var g=c.context;var e=c.suggest}if(a){a=this.encode(a);var h=a.length;if(1<h){c=C();for(var k=[],l=0,n=0,p;l<h;l++)if((p=a[l])&&p.length>=this.D&&!c[p])if(this.B||e||this.map[p])k[n++]=p,c[p]=1;else return d;a=k;h=a.length}}if(!h)return d;b||(b=100);g=this.depth&&1<h&&!1!==g;c=0;if(g){var m=a[0];c=1}else 1<h&&a.sort(ia);for(;c<h;c++){l=a[c];g?(k=ya(this,d,e,b,f,2===h,l,m),e&&!1===k&&d.length||(m=l)):
|
||||
function(e){var h=this.A();e.K(h.resolve,h.reject)};b.prototype.W=function(e,h){var k=this.A();try{e.call(h,k.resolve,k.reject)}catch(l){k.reject(l)}};b.prototype.then=function(e,h){function k(m,q){return"function"==typeof m?function(r){try{l(m(r))}catch(u){p(u)}}:q}var l,p,n=new b(function(m,q){l=m;p=q});this.K(k(e,l),k(h,p));return n};b.prototype.catch=function(e){return this.then(void 0,e)};b.prototype.K=function(e,h){function k(){switch(l.l){case 1:e(l.m);break;case 2:h(l.m);break;default:throw Error("Unexpected state: "+
|
||||
l.l);}}var l=this;null==this.h?g.l(k):this.h.push(k);this.N=!0};b.resolve=d;b.reject=function(e){return new b(function(h,k){k(e)})};b.race=function(e){return new b(function(h,k){for(var l=ea(e),p=l.next();!p.done;p=l.next())d(p.value).K(h,k)})};b.all=function(e){var h=ea(e),k=h.next();return k.done?d([]):new b(function(l,p){function n(r){return function(u){m[r]=u;q--;0==q&&l(m)}}var m=[],q=0;do m.push(void 0),q++,d(k.value).K(n(m.length-1),p),k=h.next();while(!k.done)})};return b});
|
||||
var fa="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var f in d)Object.prototype.hasOwnProperty.call(d,f)&&(a[f]=d[f])}return a};x("Object.assign",function(a){return a||fa});function C(a){return"undefined"!==typeof a?a:!0}function ha(a){for(var b=Array(a),c=0;c<a;c++)b[c]=D();return b}function D(){return Object.create(null)}function ia(a,b){return b.length-a.length}function E(a){return"string"===typeof a}function F(a){return"object"===typeof a}function H(a){return"function"===typeof a};var ja=/[\u0300-\u036f]/g;function ka(a){a.normalize&&(a=a.normalize("NFD").replace(ja,""));return a}function la(a,b){for(var c=Object.keys(a),d=c.length,f=[],g="",e=0,h=0,k,l;h<d;h++)k=c[h],(l=a[k])?(f[e++]=I(b?"(?!\\b)"+k+"(\\b|_)":k),f[e++]=l):g+=(g?"|":"")+k;g&&(f[e++]=I(b?"(?!\\b)("+g+")(\\b|_)":"("+g+")"),f[e]="");return f}function K(a,b){for(var c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),a);c+=2);return a}function I(a){return new RegExp(a,"g")}
|
||||
function ma(a){for(var b="",c="",d=0,f=a.length,g=void 0;d<f;d++)(g=a[d])!==c&&(b+=c=g);return b};var oa={encode:na,F:!1,G:""},pa=/[\W_]+/;function na(a){return qa(this,ka(a).toLowerCase(),!1,pa)};var ra={},L={};function sa(a){M(a,"add");M(a,"append");M(a,"search");M(a,"update");M(a,"remove")}function M(a,b){a[b+"Async"]=function(){var c=this,d=arguments,f=d[d.length-1];if(H(f)){var g=f;delete d[d.length-1]}f=new Promise(function(e){setTimeout(function(){c.async=!0;var h=c[b].apply(c,d);c.async=!1;e(h)})});return g?(f.then(g),this):f}};function ta(a,b,c,d){var f=a.length,g=[],e,h=0;d&&(d=[]);for(var k=f-1;0<=k;k--){for(var l=a[k],p=l.length,n=D(),m=!B,q=0;q<p;q++){var r=l[q],u=r.length;if(u)for(var A=0,y=void 0,z;A<u;A++)if(z=r[A],B){if(B[z]){if(!k)if(c)c--;else if(g[h++]=z,h===b)return g;if(k||d)n[z]=1;m=!0}if(d&&(e[z]=(y=e[z])?++y:y=1,y<f)){var J=d[y-2]||(d[y-2]=[]);J[J.length]=z}}else n[z]=1}if(d)B||(e=n);else if(!m)return[];var B=n}if(d)for(a=d.length-1;0<=a;a--)for(f=d[a],e=f.length,k=0;k<e;k++)if(l=f[k],!B[l]){if(c)c--;else if(g[h++]=
|
||||
l,h===b)return g;B[l]=1}return g}function ua(a,b){for(var c=D(),d=D(),f=[],g=0;g<a.length;g++)c[a[g]]=1;for(a=0;a<b.length;a++){g=b[a];for(var e=0,h;e<g.length;e++)h=g[e],c[h]&&!d[h]&&(d[h]=1,f[f.length]=h)}return f};function N(a){this.l=!0!==a&&a;this.cache=D();this.h=[]}function va(a,b,c){F(a)&&(a=a.query);var d=this.cache.get(a);d||(d=this.search(a,b,c),this.cache.set(a,d));return d}N.prototype.set=function(a,b){if(!this.cache[a]){var c=this.h.length;c===this.l?delete this.cache[this.h[c-1]]:c++;for(--c;0<c;c--)this.h[c]=this.h[c-1];this.h[0]=a}this.cache[a]=b};N.prototype.get=function(a){var b=this.cache[a];if(this.l&&b&&(a=this.h.indexOf(a))){var c=this.h[a-1];this.h[a-1]=this.h[a];this.h[a]=c}return b};var wa={memory:{charset:"latin:extra",H:3,D:3,o:!1,B:"memory"},performance:{threshold:8,D:3,context:{depth:1,J:!0}},match:{charset:"latin:extra",G:"full",H:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,J:!0}},"default":{H:3,threshold:0,depth:3}};function xa(a,b,c,d,f,g){setTimeout(function(){var e=a(c,JSON.stringify(g));e&&e.then?e.then(function(){b.export(a,b,c,d,f+1)}):b.export(a,b,c,d,f+1)})};function O(a,b){if(!(this instanceof O))return new O(a);var c;if(a){E(a)?a=wa[a]:(c=a.preset)&&(a=Object.assign({},c[c],a));c=a.charset;var d=a.lang;E(c)&&(-1===c.indexOf(":")&&(c+=":default"),c=L[c]);E(d)&&(d=ra[d])}else a={};var f,g,e=a.context||{};this.encode=a.encode||c&&c.encode||na;this.register=b||D();this.H=f=a.resolution||9;this.G=b=c&&c.G||a.tokenize||"strict";this.depth="strict"===b&&e.depth;this.J=C(e.bidirectional);this.B=g=C(a.optimize);this.o=C(a.fastupdate);this.D=a.minlength||1;this.map=
|
||||
g?ha(f):D();this.l=f=e.resolution||1;this.h=g?ha(f):D();this.F=c&&c.F||a.rtl;this.L=(b=a.matcher||d&&d.L)&&la(b,!1);this.M=(b=a.stemmer||d&&d.M)&&la(b,!0);if(c=b=a.filter||d&&d.filter){c=b;d=D();e=0;for(f=c.length;e<f;e++)d[c[e]]=1;c=d}this.filter=c;this.cache=(b=a.cache)&&new N(b)}
|
||||
function qa(a,b,c,d){if(b&&(c&&(b=K(b,c)),a.L&&(b=K(b,a.L)),a.M&&1<b.length&&(b=K(b,a.M)),d||""===d)){b=b.split(d);if(a.filter){a=a.filter;c=b.length;d=[];for(var f=0,g=0;f<c;f++){var e=b[f];e&&!a[e]&&(d[g++]=e)}b=d}return b}return b}t=O.prototype;t.append=function(a,b){return this.add(a,b,!0)};
|
||||
t.add=function(a,b,c,d){if(b&&(a||0===a)){if(!d&&!c&&this.register[a])return this.update(a,b);b=this.encode(b);if(d=b.length){for(var f=D(),g=D(),e=this.depth,h=this.H,k=0;k<d;k++){var l=b[this.F?d-1-k:k],p=l.length;if(l&&p>=this.D&&(e||!g[l])){var n=P(h,d,k),m="";switch(this.G){case "full":if(3<p){for(n=0;n<p;n++)for(var q=p;q>n;q--)if(q-n>=this.D){var r=P(h,d,k,p,n);m=l.substring(n,q);Q(this,g,m,r,a,c)}break}case "reverse":if(2<p){for(q=p-1;0<q;q--)m=l[q]+m,m.length>=this.D&&Q(this,g,m,P(h,d,k,
|
||||
p,q),a,c);m=""}case "forward":if(1<p){for(q=0;q<p;q++)m+=l[q],m.length>=this.D&&Q(this,g,m,n,a,c);break}default:if(Q(this,g,l,n,a,c),e&&1<d&&k<d-1)for(p=D(),m=this.l,n=l,q=Math.min(e+1,d-k),r=p[n]=1;r<q;r++)if((l=b[this.F?d-1-k-r:k+r])&&l.length>=this.D&&!p[l]){p[l]=1;var u=this.J&&l>n;Q(this,f,u?n:l,P(m+(d/2>m?0:1),d,k,q-1,r-1),a,c,u?l:n)}}}}this.o||(this.register[a]=1)}}return this};function P(a,b,c,d,f){return c&&1<a?b+(d||0)<=a?c+(f||0):(a-1)/(b+(d||0))*(c+(f||0))+1|0:0}
|
||||
function Q(a,b,c,d,f,g,e){var h=e?a.h:a.map;if(!b[c]||e&&!b[c][e])a.B&&(h=h[d]),e?(b=b[c]||(b[c]=D()),b[e]=1,h=h[e]||(h[e]=D())):b[c]=1,h=h[c]||(h[c]=[]),a.B||(h=h[d]||(h[d]=[])),g&&-1!==h.indexOf(f)||(h[h.length]=f,a.o&&(a=a.register[f]||(a.register[f]=[]),a[a.length]=h))}
|
||||
t.search=function(a,b,c){F(a)?(c=a,a=c.query):F(b)&&(c=b);var d=[],f=0;if(c){b=c.limit;f=c.offset||0;var g=c.context;var e=c.suggest}if(a){a=this.encode(a);var h=a.length;if(1<h){c=D();for(var k=[],l=0,p=0,n;l<h;l++)if((n=a[l])&&n.length>=this.D&&!c[n])if(this.B||e||this.map[n])k[p++]=n,c[n]=1;else return d;a=k;h=a.length}}if(!h)return d;b||(b=100);g=this.depth&&1<h&&!1!==g;c=0;if(g){var m=a[0];c=1}else 1<h&&a.sort(ia);for(;c<h;c++){l=a[c];g?(k=ya(this,d,e,b,f,2===h,l,m),e&&!1===k&&d.length||(m=l)):
|
||||
k=ya(this,d,e,b,f,1===h,l);if(k)return k;if(e&&c===h-1){k=d.length;if(!k){if(g){g=0;c=-1;continue}return d}if(1===k)return za(d[0],b,f)}}return ta(d,b,f,e)};
|
||||
function ya(a,b,c,d,f,g,e,h){var k=[],l=h?a.h:a.map;a.B||(l=Aa(l,e,h,a.J));if(l){for(var n=0,p=Math.min(l.length,h?a.l:a.H),m=0,q=0,r,t;m<p;m++)if(r=l[m])if(a.B&&(r=Aa(r,e,h,a.J)),f&&r&&g&&(t=r.length,t<=f?(f-=t,r=null):(r=r.slice(f),f=0)),r&&(k[n++]=r,g&&(q+=r.length,q>=d)))break;if(n){if(g)return za(k,d,0);b[b.length]=k;return}}return!c&&k}function za(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
|
||||
function Aa(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}u.contain=function(a){return!!this.register[a]};u.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
u.remove=function(a,b){var c=this.register[a];if(c){if(this.s)for(var d=0,f;d<c.length;d++)f=c[d],f.splice(f.indexOf(a),1);else Q(this.map,a,this.H,this.B),this.depth&&Q(this.h,a,this.l,this.B);b||delete this.register[a];if(this.cache)for(b=this.cache,c=0;c<b.h.length;c++)f=b.h[c],d=b.cache[f],-1!==d.indexOf(a)&&(b.h.splice(c--,1),delete b.cache[f])}return this};
|
||||
function Q(a,b,c,d,f){var g=0;if(a.constructor===Array)if(f)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),g++):g++;else{f=Math.min(a.length,c);for(var e=0,h;e<f;e++)if(h=a[e])g=Q(h,b,c,d,f),d||g||delete a[e]}else for(e in a)(g=Q(a[e],b,c,d,f))||delete a[e];return g}u.searchCache=va;
|
||||
u.export=function(a,b,c,d,f){switch(f||(f=0)){case 0:var g="reg";if(this.s){var e=C();for(var h in this.register)e[h]=1}else e=this.register;break;case 1:g="cfg";e={doc:0,opt:this.B?1:0};break;case 2:g="map";e=this.map;break;case 3:g="ctx";e=this.h;break;default:return}xa(a,b||this,c?c+"."+g:g,d,f,e);return!0};u.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "cfg":this.B=!!b.opt;break;case "reg":this.s=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};sa(N.prototype);function Ba(a){a=a.data;var b=self._index,c=a.args,d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new N(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};var Ca=0;function R(a){var b;a?H(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());var c=self.exports,d=this;this.o=Da(b,c,a.worker);this.h=C();if(this.o){if(c)this.o.on("message",function(f){d.h[f.id](f.msg);delete d.h[f.id]});else this.o.onmessage=function(f){f=f.data;d.h[f.id](f.msg);delete d.h[f.id]};this.o.postMessage({task:"init",factory:b,options:a})}}S("add");S("append");S("search");S("update");S("remove");
|
||||
function S(a){R.prototype[a]=R.prototype[a+"Async"]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if(H(d)){var f=d;c.splice(c.length-1,1)}d=new Promise(function(g){setTimeout(function(){b.h[++Ca]=g;b.o.postMessage({task:a,id:Ca,args:c})})});return f?(d.then(f),this):d}}
|
||||
function Da(a,b,c){try{var d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+Ba.toString()],{type:"text/javascript"}))):new Worker(E(c)?c:"worker/worker.js",{type:"module"})}catch(f){}return d};function T(a){if(!(this instanceof T))return new T(a);var b=a.document||a.doc||a,c;this.I=[];this.h=[];this.m=[];this.register=C();this.key=(c=b.key||b.id)&&U(c,this.m)||"id";this.s=B(a.fastupdate);this.A=(c=b.store)&&!0!==c&&[];this.store=c&&C();this.C=(c=b.tag)&&U(c,this.m);this.l=c&&C();this.cache=(c=a.cache)&&new M(c);a.cache=!1;this.o=a.worker;this.async=!1;c=C();var d=b.index||b.field||b;E(d)&&(d=[d]);for(var f=0,g,e=void 0;f<d.length;f++)g=d[f],E(g)||(e=g,g=g.field),e=F(e)?Object.assign({},
|
||||
a,e):a,this.o&&(c[g]=new R(e),c[g].o||(this.o=!1)),this.o||(c[g]=new N(e,this.register)),this.I[f]=U(g,this.m),this.h[f]=g;if(this.A)for(a=b.store,E(a)&&(a=[a]),b=0;b<a.length;b++)this.A[b]=U(a[b],this.m);this.index=c}function U(a,b){for(var c=a.split(":"),d=0,f=0;f<c.length;f++)a=c[f],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function V(a,b){if(E(b))a=a[b];else for(var c=0;a&&c<b.length;c++)a=a[b[c]];return a}
|
||||
function W(a,b,c,d,f){a=a[f];if(d===c.length-1)b[f]=a;else if(a)if(a.constructor===Array)for(b=b[f]=Array(a.length),f=0;f<a.length;f++)W(a,b,c,d,f);else b=b[f]||(b[f]=C()),f=c[++d],W(a,b,c,d,f)}function X(a,b,c,d,f,g,e,h){a=a[e];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)f.add(g,a[b],!0,!0);return}a=a.join(" ")}f.add(g,a,h,!0)}else if(a)if(a.constructor===Array)for(e=0;e<a.length;e++)X(a,b,c,d,f,g,e,h);else e=b[++d],X(a,b,c,d,f,g,e,h)}u=T.prototype;
|
||||
u.add=function(a,b,c){F(a)&&(b=a,a=V(b,this.key));if(b&&(a||0===a)){if(this.register[a])return this.update(a,b);for(var d=0,f,g;d<this.h.length;d++)g=this.h[d],f=this.I[d],E(f)&&(f=[f]),X(b,f,this.m,0,this.index[g],a,f[0],c);if(this.C){d=V(b,this.C);f=C();E(d)&&(d=[d]);g=0;for(var e;g<d.length;g++)if(e=d[g],!f[e]&&(f[e]=1,e=this.l[e]||(this.l[e]=[]),!c||-1===e.indexOf(a)))if(e[e.length]=a,this.s){var h=this.register[a]||(this.register[a]=[]);h[h.length]=e}}if(this.store){if(this.A){var k=C();for(c=
|
||||
0;c<this.A.length;c++)d=this.A[c],E(d)?k[d]=b[d]:W(b,k,d,0,d[0])}this.store[a]=k||b}}return this};u.append=function(a,b){return this.add(a,b,!0)};u.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
u.remove=function(a){F(a)&&(a=V(a,this.key));if(this.register[a]){for(var b=this.s&&!this.o,c=0;c<this.h.length&&(this.index[this.h[c]].remove(a,b),!b);c++);if(this.C&&!b)for(var d in this.l)b=this.l[d],c=b.indexOf(a),-1!==c&&(1<b.length?b.splice(c,1):delete this.l[d]);this.store&&delete this.store[a];delete this.register[a]}return this};
|
||||
u.search=function(a,b,c,d){F(a)?(c=a,a=c.query):F(b)&&(c=b,b=0);var f=[],g=[],e,h=0;if(c)if(c.constructor===Array){var k=c;c=null}else{k=(e=c.pluck)||c.index||c.field||c;var l=c.tag;var n=this.store&&c.enrich;var p="and"===c.bool;b=c.limit||100;var m=c.offset||0;if(l&&(E(l)&&(l=[l]),!a)){g=0;for(e=void 0;g<l.length;g++)if(e=Ea.call(this,l[g],b,m,n))f[f.length]=e,h++;return h?f:[]}E(k)?k=[k]:k.constructor===Array||(k=null)}k||(k=this.h);p=p&&(1<k.length||l&&1<l.length);for(var q=!d&&(this.o||this.async)&&
|
||||
[],r=0,t=void 0,z=void 0,x=void 0;r<k.length;r++)if(x=void 0,z=k[r],E(z)||(x=z,z=z.field),q)q[r]=this.index[z].searchAsync(a,b,x||c);else{d?t=d[r]:t=this.index[z].search(a,b,x||c);x=t&&t.length;if(l&&x){var D=[],A=0;p&&(D[0]=[t]);var Z=0,G=void 0;for(G=void 0;Z<l.length;Z++)if(G=l[Z],x=(G=this.l[G])&&G.length)A++,D[D.length]=p?[G]:G;A&&(t=p?ta(D,b||100,m||0):ua(t,D),x=t.length)}if(x)g[h]=z,f[h++]=t;else if(p)return[]}if(q){var Ma=this;return new Promise(function(Na){Promise.all(q).then(function(Oa){Na(Ma.search(a,
|
||||
b,c,Oa))})})}if(!h)return[];if(e&&(!n||!this.store))return f[0];l=0;for(m=void 0;l<g.length;l++){m=f[l];m.length&&n&&(m=Fa.call(this,m));if(e)return m;f[l]={field:g[l],result:m}}return f};function Ea(a,b,c,d){var f=this.l[a],g=f&&f.length-c;if(g&&0<g){if(g>b||c)f=f.slice(c,c+b);d&&(f=Fa.call(this,f));return{tag:a,result:f}}}function Fa(a){for(var b=Array(a.length),c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}u.contain=function(a){return!!this.register[a]};u.get=function(a){return this.store[a]};
|
||||
u.set=function(a,b){this.store[a]=b;return this};u.searchCache=va;u.export=function(a,b,c,d,f){f||(f=0);d||(d=0);if(d<this.h.length){var g=this.h[d],e=this.index[g];b=this;setTimeout(function(){e.export(a,b,f?g.replace(":","-"):"",d,f++)||(d++,f=1,b.export(a,b,g,d,f))})}else{switch(f){case 1:c="tag";var h=this.l;break;case 2:c="store";h=this.store;break;default:return}xa(a,this,c,d,f,h)}};
|
||||
u.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.s=!1;this.register=b;a=0;for(var c;a<this.h.length;a++)c=this.index[this.h[a]],c.register=b,c.s=!1;break;case "store":this.store=b;break;default:a=a.split("."),c=a[0],a=a[1],c&&a&&this.index[c].import(a,b)}};sa(T.prototype);var Ha={encode:Ga,F:!1,G:""},Ia=/[\W_]+/,Ja=[I("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",I("[\u00e8\u00e9\u00ea\u00eb]"),"e",I("[\u00ec\u00ed\u00ee\u00ef]"),"i",I("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",I("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",I("[\u00fd\u0177\u00ff]"),"y",I("\u00f1"),"n",I("[\u00e7c]"),"k",I("\u00df"),"s",I(" & ")," and "];function Ga(a){return qa(this,ka(a).toLowerCase(),!a.normalize&&Ja,Ia)};var La={encode:Ka,F:!1,G:"strict"},Pa=/[^a-z0-9]+/,Qa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ka(a){a=Ga.call(this,a).join(" ");var b=[];if(a)for(var c=a.split(Pa),d=c.length,f=0,g,e=0;f<d;f++)if((a=c[f])&&(!this.filter||!this.filter[a])){g=a[0];for(var h=Qa[g]||g,k=h,l=1;l<a.length;l++)g=a[l],(g=Qa[g]||g)&&g!==k&&(h+=g,k=g);b[e++]=h}return b};var Sa={encode:Ra,F:!1,G:""},Ta=[I("ae"),"a",I("oe"),"o",I("sh"),"s",I("th"),"t",I("ph"),"f",I("pf"),"f"];function Ra(a,b){a&&(a=Ka.call(this,a).join(" "),2<a.length&&(a=J(a,Ta)),b||(1<a.length&&(a=ma(a)),a&&(a=a.split(" "))));return a};var Va={encode:Ua,F:!1,G:""},Wa=I("(?!\\b)[aeiouy]");function Ua(a){a&&(a=Ra.call(this,a,!0),1<a.length&&(a=a.replace(Wa,"")),1<a.length&&(a=ma(a)),a&&(a=a.split(" ")));return a};K["latin:default"]=oa;K["latin:simple"]=Ha;K["latin:balance"]=La;K["latin:advanced"]=Sa;K["latin:extra"]=Va;var Y=self,Xa,Ya={Index:N,Document:T,Worker:R,registerCharset:function(a,b){K[a]=b},registerLanguage:function(a,b){ra[a]=b}};(Xa=Y.define)&&Xa.amd?Xa([],function(){return Ya}):Y.exports?Y.exports=Ya:Y.FlexSearch=Ya;}(this));
|
||||
function ya(a,b,c,d,f,g,e,h){var k=[],l=h?a.h:a.map;a.B||(l=Aa(l,e,h,a.J));if(l){for(var p=0,n=Math.min(l.length,h?a.l:a.H),m=0,q=0,r,u;m<n;m++)if(r=l[m])if(a.B&&(r=Aa(r,e,h,a.J)),f&&r&&g&&(u=r.length,u<=f?(f-=u,r=null):(r=r.slice(f),f=0)),r&&(k[p++]=r,g&&(q+=r.length,q>=d)))break;if(p){if(g)return za(k,d,0);b[b.length]=k;return}}return!c&&k}function za(a,b,c){a=1===a.length?a[0]:[].concat.apply([],a);return c||a.length>b?a.slice(c,c+b):a}
|
||||
function Aa(a,b,c,d){c?(d=d&&b>c,a=(a=a[d?b:c])&&a[d?c:b]):a=a[b];return a}t.contain=function(a){return!!this.register[a]};t.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
t.remove=function(a,b){var c=this.register[a];if(c){if(this.o)for(var d=0,f;d<c.length;d++)f=c[d],f.splice(f.indexOf(a),1);else R(this.map,a,this.H,this.B),this.depth&&R(this.h,a,this.l,this.B);b||delete this.register[a];if(this.cache)for(b=this.cache,c=0;c<b.h.length;c++)f=b.h[c],d=b.cache[f],-1!==d.indexOf(a)&&(b.h.splice(c--,1),delete b.cache[f])}return this};
|
||||
function R(a,b,c,d,f){var g=0;if(a.constructor===Array)if(f)b=a.indexOf(b),-1!==b?1<a.length&&(a.splice(b,1),g++):g++;else{f=Math.min(a.length,c);for(var e=0,h;e<f;e++)if(h=a[e])g=R(h,b,c,d,f),d||g||delete a[e]}else for(e in a)(g=R(a[e],b,c,d,f))||delete a[e];return g}t.searchCache=va;
|
||||
t.export=function(a,b,c,d,f){switch(f||(f=0)){case 0:var g="reg";if(this.o){var e=D();for(var h in this.register)e[h]=1}else e=this.register;break;case 1:g="cfg";e={doc:0,opt:this.B?1:0};break;case 2:g="map";e=this.map;break;case 3:g="ctx";e=this.h;break;default:return}xa(a,b||this,c?c+"."+g:g,d,f,e);return!0};t.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "cfg":this.B=!!b.opt;break;case "reg":this.o=!1;this.register=b;break;case "map":this.map=b;break;case "ctx":this.h=b}};sa(O.prototype);function Ba(a){a=a.data;var b=self._index,c=a.args,d=a.task;switch(d){case "init":d=a.options||{};a=a.factory;b=d.encode;d.cache=!1;b&&0===b.indexOf("function")&&(d.encode=Function("return "+b)());a?(Function("return "+a)()(self),self._index=new self.FlexSearch.Index(d),delete self.FlexSearch):self._index=new O(d);break;default:a=a.id,b=b[d].apply(b,c),postMessage("search"===d?{id:a,msg:b}:{id:a})}};var Ca=0;function S(a){var b;a?H(b=a.encode)&&(a.encode=b.toString()):a={};(b=(self||window)._factory)&&(b=b.toString());var c=self.exports,d=this;this.s=Da(b,c,a.worker);this.h=D();if(this.s){if(c)this.s.on("message",function(f){d.h[f.id](f.msg);delete d.h[f.id]});else this.s.onmessage=function(f){f=f.data;d.h[f.id](f.msg);delete d.h[f.id]};this.s.postMessage({task:"init",factory:b,options:a})}}T("add");T("append");T("search");T("update");T("remove");
|
||||
function T(a){S.prototype[a]=S.prototype[a+"Async"]=function(){var b=this,c=[].slice.call(arguments),d=c[c.length-1];if(H(d)){var f=d;c.splice(c.length-1,1)}d=new Promise(function(g){setTimeout(function(){b.h[++Ca]=g;b.s.postMessage({task:a,id:Ca,args:c})})});return f?(d.then(f),this):d}}
|
||||
function Da(a,b,c){try{var d=b?eval('new (require("worker_threads")["Worker"])("../dist/node/node.js")'):a?new Worker(URL.createObjectURL(new Blob(["onmessage="+Ba.toString()],{type:"text/javascript"}))):new Worker(E(c)?c:"worker/worker.js",{type:"module"})}catch(f){}return d};function U(a){if(!(this instanceof U))return new U(a);var b=a.document||a.doc||a,c;this.I=[];this.h=[];this.m=[];this.register=D();this.key=(c=b.key||b.id)&&V(c,this.m)||"id";this.o=C(a.fastupdate);this.A=(c=b.store)&&!0!==c&&[];this.store=c&&D();this.C=(c=b.tag)&&V(c,this.m);this.l=c&&D();this.cache=(c=a.cache)&&new N(c);a.cache=!1;this.s=a.worker;this.async=!1;c=D();var d=b.index||b.field||b;E(d)&&(d=[d]);for(var f=0,g,e=void 0;f<d.length;f++)g=d[f],E(g)||(e=g,g=g.field),e=F(e)?Object.assign({},
|
||||
a,e):a,this.s&&(c[g]=new S(e),c[g].s||(this.s=!1)),this.s||(c[g]=new O(e,this.register)),this.I[f]=V(g,this.m),this.h[f]=g;if(this.A)for(a=b.store,E(a)&&(a=[a]),b=0;b<a.length;b++)this.A[b]=V(a[b],this.m);this.index=c}function V(a,b){for(var c=a.split(":"),d=0,f=0;f<c.length;f++)a=c[f],0<=a.indexOf("[]")&&(a=a.substring(0,a.length-2))&&(b[d]=!0),a&&(c[d++]=a);d<c.length&&(c.length=d);return 1<d?c:c[0]}function W(a,b){if(E(b))a=a[b];else for(var c=0;a&&c<b.length;c++)a=a[b[c]];return a}
|
||||
function X(a,b,c,d,f){a=a[f];if(d===c.length-1)b[f]=a;else if(a)if(a.constructor===Array)for(b=b[f]=Array(a.length),f=0;f<a.length;f++)X(a,b,c,d,f);else b=b[f]||(b[f]=D()),f=c[++d],X(a,b,c,d,f)}function Y(a,b,c,d,f,g,e,h){a=a[e];if(d===b.length-1){if(a.constructor===Array){if(c[d]){for(b=0;b<a.length;b++)f.add(g,a[b],!0,!0);return}a=a.join(" ")}f.add(g,a,h,!0)}else if(a)if(a.constructor===Array)for(e=0;e<a.length;e++)Y(a,b,c,d,f,g,e,h);else e=b[++d],Y(a,b,c,d,f,g,e,h)}t=U.prototype;
|
||||
t.add=function(a,b,c){F(a)&&(b=a,a=W(b,this.key));if(b&&(a||0===a)){if(!c&&this.register[a])return this.update(a,b);for(var d=0,f,g;d<this.h.length;d++)g=this.h[d],f=this.I[d],E(f)&&(f=[f]),Y(b,f,this.m,0,this.index[g],a,f[0],c);if(this.C){d=W(b,this.C);f=D();E(d)&&(d=[d]);g=0;for(var e;g<d.length;g++)if(e=d[g],!f[e]&&(f[e]=1,e=this.l[e]||(this.l[e]=[]),!c||-1===e.indexOf(a)))if(e[e.length]=a,this.o){var h=this.register[a]||(this.register[a]=[]);h[h.length]=e}}if(this.store&&(!c||!this.store[a])){if(this.A){var k=
|
||||
D();for(c=0;c<this.A.length;c++)d=this.A[c],E(d)?k[d]=b[d]:X(b,k,d,0,d[0])}this.store[a]=k||b}}return this};t.append=function(a,b){return this.add(a,b,!0)};t.update=function(a,b){return this.remove(a).add(a,b)};
|
||||
t.remove=function(a){F(a)&&(a=W(a,this.key));if(this.register[a]){for(var b=0;b<this.h.length&&(this.index[this.h[b]].remove(a,!this.s),!this.o);b++);if(this.C&&!this.o)for(var c in this.l){b=this.l[c];var d=b.indexOf(a);-1!==d&&(1<b.length?b.splice(d,1):delete this.l[c])}this.store&&delete this.store[a];delete this.register[a]}return this};
|
||||
t.search=function(a,b,c,d){F(a)?(c=a,a=c.query):F(b)&&(c=b,b=0);var f=[],g=[],e,h=0;if(c)if(c.constructor===Array){var k=c;c=null}else{k=(e=c.pluck)||c.index||c.field||c;var l=c.tag;var p=this.store&&c.enrich;var n="and"===c.bool;b=c.limit||100;var m=c.offset||0;if(l&&(E(l)&&(l=[l]),!a)){g=0;for(e=void 0;g<l.length;g++)if(e=Ea.call(this,l[g],b,m,p))f[f.length]=e,h++;return h?f:[]}E(k)&&(k=[k])}k||(k=this.h);n=n&&(1<k.length||l&&1<l.length);for(var q=!d&&(this.s||this.async)&&[],r=0,u=void 0,A=void 0,
|
||||
y=void 0;r<k.length;r++)if(y=void 0,A=k[r],E(A)||(y=A,A=A.field),q)q[r]=this.index[A].searchAsync(a,b,y||c);else{d?u=d[r]:u=this.index[A].search(a,b,y||c);y=u&&u.length;if(l&&y){var z=[],J=0;n&&(z[0]=[u]);var B=0,G=void 0;for(G=void 0;B<l.length;B++)if(G=l[B],y=(G=this.l[G])&&G.length)J++,z[z.length]=n?[G]:G;J&&(u=n?ta(z,b||100,m||0):ua(u,z),y=u.length)}if(y)g[h]=A,f[h++]=u;else if(n)return[]}if(q){var Ma=this;return new Promise(function(Na){Promise.all(q).then(function(Oa){Na(Ma.search(a,b,c,Oa))})})}if(!h)return[];
|
||||
if(e&&(!p||!this.store))return f[0];l=0;for(m=void 0;l<g.length;l++){m=f[l];m.length&&p&&(m=Fa.call(this,m));if(e)return m;f[l]={field:g[l],result:m}}return f};function Ea(a,b,c,d){var f=this.l[a],g=f&&f.length-c;if(g&&0<g){if(g>b||c)f=f.slice(c,c+b);d&&(f=Fa.call(this,f));return{tag:a,result:f}}}function Fa(a){for(var b=Array(a.length),c=0,d;c<a.length;c++)d=a[c],b[c]={key:d,doc:this.store[d]};return b}t.contain=function(a){return!!this.register[a]};t.get=function(a){return this.store[a]};
|
||||
t.set=function(a,b){this.store[a]=b;return this};t.searchCache=va;t.export=function(a,b,c,d,f){f||(f=0);d||(d=0);if(d<this.h.length){var g=this.h[d],e=this.index[g];b=this;setTimeout(function(){e.export(a,b,f?g.replace(":","-"):"",d,f++)||(d++,f=1,b.export(a,b,g,d,f))})}else{switch(f){case 1:c="tag";var h=this.l;break;case 2:c="store";h=this.store;break;default:return}xa(a,this,c,d,f,h)}};
|
||||
t.import=function(a,b){if(b)switch(E(b)&&(b=JSON.parse(b)),a){case "tag":this.l=b;break;case "reg":this.o=!1;this.register=b;a=0;for(var c;a<this.h.length;a++)c=this.index[this.h[a]],c.register=b,c.o=!1;break;case "store":this.store=b;break;default:a=a.split("."),c=a[0],a=a[1],c&&a&&this.index[c].import(a,b)}};sa(U.prototype);var Ha={encode:Ga,F:!1,G:""},Ia=/[\W_]+/,Ja=[I("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",I("[\u00e8\u00e9\u00ea\u00eb]"),"e",I("[\u00ec\u00ed\u00ee\u00ef]"),"i",I("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",I("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",I("[\u00fd\u0177\u00ff]"),"y",I("\u00f1"),"n",I("[\u00e7c]"),"k",I("\u00df"),"s",I(" & ")," and "];function Ga(a){return qa(this,ka(a).toLowerCase(),!a.normalize&&Ja,Ia)};var La={encode:Ka,F:!1,G:"strict"},Pa=/[^a-z0-9]+/,Qa={b:"p",v:"f",w:"f",z:"s",x:"s","\u00df":"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};function Ka(a){a=Ga.call(this,a).join(" ");var b=[];if(a)for(var c=a.split(Pa),d=c.length,f=0,g,e=0;f<d;f++)if((a=c[f])&&(!this.filter||!this.filter[a])){g=a[0];for(var h=Qa[g]||g,k=h,l=1;l<a.length;l++)g=a[l],(g=Qa[g]||g)&&g!==k&&(h+=g,k=g);b[e++]=h}return b};var Sa={encode:Ra,F:!1,G:""},Ta=[I("ae"),"a",I("oe"),"o",I("sh"),"s",I("th"),"t",I("ph"),"f",I("pf"),"f",I("(?![aeo])h(?![aeo])"),"",I("(?!^[aeo])h(?!^[aeo])"),""];function Ra(a,b){a&&(a=Ka.call(this,a).join(" "),2<a.length&&(a=K(a,Ta)),b||(1<a.length&&(a=ma(a)),a&&(a=a.split(" "))));return a};var Va={encode:Ua,F:!1,G:""},Wa=I("(?!\\b)[aeo]");function Ua(a){a&&(a=Ra.call(this,a,!0),1<a.length&&(a=a.replace(Wa,"")),1<a.length&&(a=ma(a)),a&&(a=a.split(" ")));return a};L["latin:default"]=oa;L["latin:simple"]=Ha;L["latin:balance"]=La;L["latin:advanced"]=Sa;L["latin:extra"]=Va;var Z=self,Xa,Ya={Index:O,Document:U,Worker:S,registerCharset:function(a,b){L[a]=b},registerLanguage:function(a,b){ra[a]=b}};(Xa=Z.define)&&Xa.amd?Xa([],function(){return Ya}):Z.exports?Z.exports=Ya:Z.FlexSearch=Ya;}(this));
|
||||
|
20
dist/flexsearch.light.js
vendored
@@ -1,18 +1,18 @@
|
||||
/**!
|
||||
* FlexSearch.js v0.7.0-beta (Light)
|
||||
* FlexSearch.js v0.7.0 (Light)
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Licence: Apache-2.0
|
||||
* https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
(function(self){'use strict';function t(a){return"undefined"!==typeof a?a:!0}function v(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=y();return c}function y(){return Object.create(null)}function z(a,c){return c.length-a.length};const A=/[\u0300-\u036f]/g;function B(a,c){const b=Object.keys(a),d=b.length,e=[];let h="",f=0;for(let g=0,k,n;g<d;g++)k=b[g],(n=a[k])?(e[f++]=new RegExp(c?"(?!\\b)"+k+"(\\b|_)":k,"g"),e[f++]=n):h+=(h?"|":"")+k;h&&(e[f++]=new RegExp(c?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),e[f]="");return e}function C(a,c){for(let b=0,d=c.length;b<d&&(a=a.replace(c[b],c[b+1]),a);b+=2);return a};const D=/[\W_]+/;function F(a){a.normalize&&(a=a.normalize("NFD").replace(A,""));if(a=a.toLowerCase())if(this.o&&(a=C(a,this.o)),this.A&&1<a.length&&(a=C(a,this.A)),D||""===D)if(a=a.split(D),this.filter){var c=this.filter;const b=a.length,d=[];for(let e=0,h=0;e<b;e++){const f=a[e];f&&!c[f]&&(d[h++]=f)}a=d}return a};const G={},H={};function I(a,c,b,d){var e=a.length;let h=[],f,g,k=0;d&&(d=[]);for(--e;0<=e;e--){const n=a[e],p=n.length,q=y();let r=!f;for(let m=0;m<p;m++){const l=n[m],u=l.length;if(u)for(let E=0,x,w;E<u;E++)if(w=l[E],f){if(f[w]){if(!e)if(b)b--;else if(h[k++]=w,k===c)return h;if(e||d)q[w]=1;r=!0}if(d&&(g[w]=(x=g[w])?x++:x=1,x<p)){const M=d[x-1]||(d[x-1]=[]);M[M.length]=w}}else q[w]=1}if(d)f||(g=q);else if(!r)return[];f=q}if(d)for(let n=d.length-1,p,q;0<=n;n--){p=d[n];q=p.length;for(let r=0,m;r<q;r++)if(m=p[r],!f[m]){if(b)b--;
|
||||
else if(h[k++]=m,k===c)return h;f[m]=1}}return h};function J(a,c){if(!(this instanceof J))return new J(a);let b;if(a){var d=a.charset;b=a.lang;"string"===typeof d&&(-1===d.indexOf(":")&&(d+=":default"),d=H[d]);"string"===typeof b&&(b=G[b])}else a={};let e,h,f=a.context||{};this.encode=a.encode||d&&d.encode||F;this.register=c||y();this.v=e=a.resolution||9;this.C=c=d&&d.C||a.tokenize||"strict";this.j="strict"===c&&f.depth;this.l=t(f.bidirectional);this.g=h=t(a.optimize);this.s=t(a.fastupdate);this.h=a.minlength||1;this.i=h?v(e):y();this.B=e=f.resolution||
|
||||
(function(self){'use strict';function t(a){return"undefined"!==typeof a?a:!0}function v(a){const c=Array(a);for(let b=0;b<a;b++)c[b]=y();return c}function y(){return Object.create(null)}function z(a,c){return c.length-a.length};const A=/[\u0300-\u036f]/g;function B(a,c){const b=Object.keys(a),d=b.length,e=[];let h="",f=0;for(let g=0,k,n;g<d;g++)k=b[g],(n=a[k])?(e[f++]=new RegExp(c?"(?!\\b)"+k+"(\\b|_)":k,"g"),e[f++]=n):h+=(h?"|":"")+k;h&&(e[f++]=new RegExp(c?"(?!\\b)("+h+")(\\b|_)":"("+h+")","g"),e[f]="");return e}function C(a,c){for(let b=0,d=c.length;b<d&&(a=a.replace(c[b],c[b+1]),a);b+=2);return a};const D=/[\W_]+/;function F(a){a.normalize&&(a=a.normalize("NFD").replace(A,""));if(a=a.toLowerCase())if(this.o&&(a=C(a,this.o)),this.A&&1<a.length&&(a=C(a,this.A)),D||""===D)if(a=a.split(D),this.filter){var c=this.filter;const b=a.length,d=[];for(let e=0,h=0;e<b;e++){const f=a[e];f&&!c[f]&&(d[h++]=f)}a=d}return a};const G={},H={};function I(a,c,b,d){const e=a.length;let h=[],f,g,k=0;d&&(d=[]);for(let n=e-1;0<=n;n--){const m=a[n],r=m.length,p=y();let q=!f;for(let l=0;l<r;l++){const u=m[l],M=u.length;if(M)for(let E=0,x,w;E<M;E++)if(w=u[E],f){if(f[w]){if(!n)if(b)b--;else if(h[k++]=w,k===c)return h;if(n||d)p[w]=1;q=!0}if(d&&(g[w]=(x=g[w])?++x:x=1,x<e)){const N=d[x-2]||(d[x-2]=[]);N[N.length]=w}}else p[w]=1}if(d)f||(g=p);else if(!q)return[];f=p}if(d)for(let n=d.length-1,m,r;0<=n;n--){m=d[n];r=m.length;for(let p=0,q;p<r;p++)if(q=
|
||||
m[p],!f[q]){if(b)b--;else if(h[k++]=q,k===c)return h;f[q]=1}}return h};function J(a,c){if(!(this instanceof J))return new J(a);let b;if(a){var d=a.charset;b=a.lang;"string"===typeof d&&(-1===d.indexOf(":")&&(d+=":default"),d=H[d]);"string"===typeof b&&(b=G[b])}else a={};let e,h,f=a.context||{};this.encode=a.encode||d&&d.encode||F;this.register=c||y();this.v=e=a.resolution||9;this.C=c=d&&d.C||a.tokenize||"strict";this.j="strict"===c&&f.depth;this.l=t(f.bidirectional);this.g=h=t(a.optimize);this.s=t(a.fastupdate);this.h=a.minlength||1;this.i=h?v(e):y();this.B=e=f.resolution||
|
||||
1;this.m=h?v(e):y();this.u=d&&d.u||a.rtl;this.o=(c=a.matcher||b&&b.o)&&B(c,!1);this.A=(c=a.stemmer||b&&b.A)&&B(c,!0);if(a=c=a.filter||b&&b.filter){a=c;d=y();for(let g=0,k=a.length;g<k;g++)d[a[g]]=1;a=d}this.filter=a}J.prototype.append=function(a,c){return this.add(a,c,!0)};
|
||||
J.prototype.add=function(a,c,b,d){if(!d&&!b&&this.register[a])return this.update(a,c);if(c&&(a||0===a)&&(c=this.encode(c),d=c.length)){const n=this.j,p=this.v,q=y(),r=y();for(let m=0;m<d;m++){let l=c[this.u?d-1-m:m];var e=l.length;if(l&&e>=this.h&&(n||!q[l])){var h=K(p,d,m),f="";switch(this.C){case "full":if(3<e){for(h=0;h<e;h++)for(var g=e;g>h;g--)if(g-h>=this.h){var k=K(p,d,m,e,h);f=l.substring(h,g);L(this,q,f,k,a,b)}break}case "reverse":if(2<e){for(g=e-1;0<g;g--)f=l[g]+f,f.length>=this.h&&L(this,
|
||||
q,f,K(p,d,m,e,g),a,b);f=""}case "forward":if(1<e)for(g=0;g<e;g++)f+=l[g],f.length>=this.h&&L(this,q,f,h,a,b);break;default:if(L(this,q,l,h,a,b),n&&1<d&&m<d-1)for(e=this.B,f=y(),h=l,g=Math.min(n+1,d-m),f[h]=1,k=1;k<g;k++)if((l=c[this.u?d-1-m-k:m+k])&&l.length>=this.h&&!f[l]){f[l]=1;const u=this.l&&l>h;L(this,r,u?h:l,K(e+(d/2>e?0:1),d,m,g-1,k-1),a,b,u?l:h)}}}}this.s||(this.register[a]=1)}return this};function K(a,c,b,d,e){return b&&1<a?c+(d||0)<=a?b+(e||0):(a-1)/(c+(d||0))*(b+(e||0))+1|0:0}
|
||||
J.prototype.add=function(a,c,b,d){if(c&&(a||0===a)){if(!d&&!b&&this.register[a])return this.update(a,c);c=this.encode(c);if(d=c.length){const n=y(),m=y(),r=this.j,p=this.v;for(let q=0;q<d;q++){let l=c[this.u?d-1-q:q];var e=l.length;if(l&&e>=this.h&&(r||!m[l])){var h=K(p,d,q),f="";switch(this.C){case "full":if(3<e){for(h=0;h<e;h++)for(var g=e;g>h;g--)if(g-h>=this.h){var k=K(p,d,q,e,h);f=l.substring(h,g);L(this,m,f,k,a,b)}break}case "reverse":if(2<e){for(g=e-1;0<g;g--)f=l[g]+f,f.length>=this.h&&L(this,
|
||||
m,f,K(p,d,q,e,g),a,b);f=""}case "forward":if(1<e){for(g=0;g<e;g++)f+=l[g],f.length>=this.h&&L(this,m,f,h,a,b);break}default:if(L(this,m,l,h,a,b),r&&1<d&&q<d-1)for(e=y(),f=this.B,h=l,g=Math.min(r+1,d-q),e[h]=1,k=1;k<g;k++)if((l=c[this.u?d-1-q-k:q+k])&&l.length>=this.h&&!e[l]){e[l]=1;const u=this.l&&l>h;L(this,n,u?h:l,K(f+(d/2>f?0:1),d,q,g-1,k-1),a,b,u?l:h)}}}}this.s||(this.register[a]=1)}}return this};function K(a,c,b,d,e){return b&&1<a?c+(d||0)<=a?b+(e||0):(a-1)/(c+(d||0))*(b+(e||0))+1|0:0}
|
||||
function L(a,c,b,d,e,h,f){let g=f?a.m:a.i;if(!c[b]||f&&!c[b][f])a.g&&(g=g[d]),f?(c=c[b]||(c[b]=y()),c[f]=1,g=g[f]||(g[f]=y())):c[b]=1,g=g[b]||(g[b]=[]),a.g||(g=g[d]||(g[d]=[])),h&&-1!==g.indexOf(e)||(g[g.length]=e,a.s&&(a=a.register[e]||(a.register[e]=[]),a[a.length]=g))}
|
||||
J.prototype.search=function(a,c,b){"object"===typeof a?(b=a,a=b.query):"object"===typeof c&&(b=c);let d=[],e;let h,f=0;if(b){c=b.limit;f=b.offset||0;var g=b.context;h=!1}if(a&&(a=this.encode(a),e=a.length,1<e)){b=y();var k=[];for(let p=0,q=0,r;p<e;p++)if((r=a[p])&&r.length>=this.h&&!b[r])if(this.g||h||this.i[r])k[q++]=r,b[r]=1;else return d;a=k;e=a.length}if(!e)return d;c||(c=100);g=this.j&&1<e&&!1!==g;b=0;let n;g?(n=a[0],b=1):1<e&&a.sort(z);for(let p,q;b<e;b++){q=a[b];g?(p=N(this,d,h,c,f,2===e,q,
|
||||
n),h&&!1===p&&d.length||(n=q)):p=N(this,d,h,c,f,1===e,q);if(p)return p;if(h&&b===e-1){k=d.length;if(!k){if(g){g=0;b=-1;continue}return d}if(1===k)return O(d[0],c,f)}}return I(d,c,f,h)};
|
||||
function N(a,c,b,d,e,h,f,g){let k=[],n=g?a.m:a.i;a.g||(n=P(n,f,g,a.l));if(n){let p=0;const q=Math.min(n.length,g?a.B:a.v);for(let r=0,m=0,l,u;r<q;r++)if(l=n[r])if(a.g&&(l=P(l,f,g,a.l)),e&&l&&h&&(u=l.length,u<=e?(e-=u,l=null):(l=l.slice(e),e=0)),l&&(k[p++]=l,h&&(m+=l.length,m>=d)))break;if(p){if(h)return O(k,d,0);c[c.length]=k;return}}return!b&&k}function O(a,c,b){a=1===a.length?a[0]:[].concat.apply([],a);return b||a.length>c?a.slice(b,b+c):a}
|
||||
function P(a,c,b,d){b?(d=d&&c>b,a=(a=a[d?c:b])&&a[d?b:c]):a=a[c];return a}J.prototype.contain=function(a){return!!this.register[a]};J.prototype.update=function(a,c){return this.remove(a).add(a,c)};J.prototype.remove=function(a,c){const b=this.register[a];if(b){if(this.s)for(let d=0,e;d<b.length;d++)e=b[d],e.splice(e.indexOf(a),1);else Q(this.i,a,this.v,this.g),this.j&&Q(this.m,a,this.B,this.g);c||delete this.register[a]}return this};
|
||||
function Q(a,c,b,d,e){let h=0;if(a.constructor===Array)if(e)c=a.indexOf(c),-1!==c?1<a.length&&(a.splice(c,1),h++):h++;else{e=Math.min(a.length,b);for(let f=0,g;f<e;f++)if(g=a[f])h=Q(g,c,b,d,e),d||h||delete a[f]}else for(let f in a)(h=Q(a[f],c,b,d,e))||delete a[f];return h};const R=self;let S;const T={Index:J,Document:null,Worker:null,registerCharset:function(a,c){H[a]=c},registerLanguage:function(a,c){G[a]=c}};(S=R.define)&&S.amd?S([],function(){return T}):R.exports?R.exports=T:R.FlexSearch=T;}(this));
|
||||
J.prototype.search=function(a,c,b){"object"===typeof a?(b=a,a=b.query):"object"===typeof c&&(b=c);let d=[],e;let h,f=0;if(b){c=b.limit;f=b.offset||0;var g=b.context;h=!1}if(a&&(a=this.encode(a),e=a.length,1<e)){b=y();var k=[];for(let m=0,r=0,p;m<e;m++)if((p=a[m])&&p.length>=this.h&&!b[p])if(this.g||h||this.i[p])k[r++]=p,b[p]=1;else return d;a=k;e=a.length}if(!e)return d;c||(c=100);g=this.j&&1<e&&!1!==g;b=0;let n;g?(n=a[0],b=1):1<e&&a.sort(z);for(let m,r;b<e;b++){r=a[b];g?(m=O(this,d,h,c,f,2===e,r,
|
||||
n),h&&!1===m&&d.length||(n=r)):m=O(this,d,h,c,f,1===e,r);if(m)return m;if(h&&b===e-1){k=d.length;if(!k){if(g){g=0;b=-1;continue}return d}if(1===k)return P(d[0],c,f)}}return I(d,c,f,h)};
|
||||
function O(a,c,b,d,e,h,f,g){let k=[],n=g?a.m:a.i;a.g||(n=Q(n,f,g,a.l));if(n){let m=0;const r=Math.min(n.length,g?a.B:a.v);for(let p=0,q=0,l,u;p<r;p++)if(l=n[p])if(a.g&&(l=Q(l,f,g,a.l)),e&&l&&h&&(u=l.length,u<=e?(e-=u,l=null):(l=l.slice(e),e=0)),l&&(k[m++]=l,h&&(q+=l.length,q>=d)))break;if(m){if(h)return P(k,d,0);c[c.length]=k;return}}return!b&&k}function P(a,c,b){a=1===a.length?a[0]:[].concat.apply([],a);return b||a.length>c?a.slice(b,b+c):a}
|
||||
function Q(a,c,b,d){b?(d=d&&c>b,a=(a=a[d?c:b])&&a[d?b:c]):a=a[c];return a}J.prototype.contain=function(a){return!!this.register[a]};J.prototype.update=function(a,c){return this.remove(a).add(a,c)};J.prototype.remove=function(a,c){const b=this.register[a];if(b){if(this.s)for(let d=0,e;d<b.length;d++)e=b[d],e.splice(e.indexOf(a),1);else R(this.i,a,this.v,this.g),this.j&&R(this.m,a,this.B,this.g);c||delete this.register[a]}return this};
|
||||
function R(a,c,b,d,e){let h=0;if(a.constructor===Array)if(e)c=a.indexOf(c),-1!==c?1<a.length&&(a.splice(c,1),h++):h++;else{e=Math.min(a.length,b);for(let f=0,g;f<e;f++)if(g=a[f])h=R(g,c,b,d,e),d||h||delete a[f]}else for(let f in a)(h=R(a[f],c,b,d,e))||delete a[f];return h};const S=self;let T;const U={Index:J,Document:null,Worker:null,registerCharset:function(a,c){H[a]=c},registerLanguage:function(a,c){G[a]=c}};(T=S.define)&&T.amd?T([],function(){return U}):S.exports?S.exports=U:S.FlexSearch=U;}(this));
|
||||
|
1
dist/module/async.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface,DocumentInterface}from"./type.js";import{is_function,is_object,is_string}from"./common.js";export default function(a){register(a,"add"),register(a,"append"),register(a,"search"),register(a,"update"),register(a,"remove")}function register(a,b){a[b+"Async"]=function(){const a=this,c=arguments,d=c[c.length-1];let e;is_function(d)&&(e=d,delete c[c.length-1]);const f=new Promise(function(d){setTimeout(function(){a.async=!0;const e=a[b].apply(a,c);a.async=!1,d(e)})});return e?(f.then(e),this):f}}
|
1
dist/module/cache.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface,DocumentInterface}from"./type.js";import{create_object,is_object}from"./common.js";function CacheClass(a){this.limit=!0!==a&&a,this.cache=create_object(),this.queue=[]}export default CacheClass;export function searchCache(a,b,c){is_object(a)&&(a=a.query);let d=this.cache.get(a);return d||(d=this.search(a,b,c),this.cache.set(a,d)),d}CacheClass.prototype.set=function(a,b){if(!this.cache[a]){let b=this.queue.length;b===this.limit?delete this.cache[this.queue[b-1]]:b++;for(let a=b-1;0<a;a--)this.queue[a]=this.queue[a-1];this.queue[0]=a}this.cache[a]=b},CacheClass.prototype.get=function(a){const b=this.cache[a];if(this.limit&&b){const b=this.queue.indexOf(a);if(b){const a=this.queue[b-1];this.queue[b-1]=this.queue[b],this.queue[b]=a}}return b},CacheClass.prototype.del=function(a){for(let b,c,d=0;d<this.queue.length;d++)c=this.queue[d],b=this.cache[c],-1!==b.indexOf(a)&&(this.queue.splice(d--,1),delete this.cache[c])};
|
1
dist/module/common.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export function parse_option(a,b){return"undefined"==typeof a?b:a}export function create_object_array(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=create_object();return b}export function create_arrays(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=[];return b}export function get_keys(a){return Object.keys(a)}export function create_object(){return Object.create(null)}export function concat(a){return[].concat.apply([],a)}export function sort_by_length_down(c,a){return a.length-c.length}export function is_array(a){return a.constructor===Array}export function is_string(a){return"string"==typeof a}export function is_object(a){return"object"==typeof a}export function is_function(a){return"function"==typeof a}
|
1
dist/module/config.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const DEBUG=!1;export const POLYFILL=!0;export const SUPPORT_WORKER=!0;export const SUPPORT_ENCODER=!0;export const SUPPORT_CACHE=!0;export const SUPPORT_ASYNC=!0;export const SUPPORT_PRESET=!0;export const SUPPORT_STORE=!0;export const SUPPORT_TAGS=!0;export const SUPPORT_SUGGESTION=!0;export const SUPPORT_SERIALIZE=!0;export const SUPPORT_DOCUMENT=!0;
|
1
dist/module/document.js
vendored
Normal file
1
dist/module/engine.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{DEBUG,SUPPORT_ASYNC,SUPPORT_CACHE}from"./config";import{searchCache}from"./cache";function Engine(a){if(DEBUG&&this instanceof Engine)throw new Error("Can't instantiate abstract class!");SUPPORT_CACHE&&(a.prototype.searchCache=searchCache),SUPPORT_ASYNC&&(a.prototype.addAsync=addAsync,a.prototype.appendAsync=appendAsync,a.prototype.searchAsync=searchAsync,a.prototype.updateAsync=updateAsync,a.prototype.removeAsync=removeAsync)}SUPPORT_CACHE&&(Engine.prototype.searchCache=searchCache),SUPPORT_ASYNC&&(Engine.prototype.addAsync=addAsync,Engine.prototype.appendAsync=appendAsync,Engine.prototype.searchAsync=searchAsync,Engine.prototype.updateAsync=updateAsync,Engine.prototype.removeAsync=removeAsync);
|
1
dist/module/global.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const global_lang={};export const global_charset={};export function registerCharset(a,b){global_charset[a]=b}export function registerLanguage(a,b){global_lang[a]=b}
|
1
dist/module/index.js
vendored
Normal file
1
dist/module/intersect.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{create_object,concat}from"./common.js";export function intersect(a,b,c,d){const e=a.length;let f,g,h=[],i=0;d&&(d=[]);for(let j=e-1;0<=j;j--){const k=a[j],l=k.length,m=create_object();let n=!f;for(let a=0;a<l;a++){const l=k[a],o=l.length;if(o)for(let a,k,p=0;p<o;p++)if(k=l[p],f){if(f[k]){if(!j)if(c)c--;else if(h[i++]=k,i===b)return h;(j||d)&&(m[k]=1),n=!0}if(d&&(g[k]=(a=g[k])?++a:a=1,a<e)){const b=d[a-2]||(d[a-2]=[]);b[b.length]=k}}else m[k]=1}if(d)f||(g=m);else if(!n)return[];f=m}if(d)for(let a,e,g=d.length-1;0<=g;g--){a=d[g],e=a.length;for(let d,g=0;g<e;g++)if(d=a[g],!f[d]){if(c)c--;else if(h[i++]=d,i===b)return h;f[d]=1}}return h}export function intersect_union(a,b){const c=create_object(),d=create_object(),e=[];for(let d=0;d<a.length;d++)c[a[d]]=1;for(let f,g=0;g<b.length;g++){f=b[g];for(let a,b=0;b<f.length;b++)a=f[b],c[a]&&!d[a]&&(d[a]=1,e[e.length]=a)}return e}
|
1
dist/module/lang.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface}from"./type.js";import{create_object,get_keys}from"./common.js";export function pipeline(a,b,c,d){if(a&&(b&&(a=replace(a,b)),this.matcher&&(a=replace(a,this.matcher)),this.stemmer&&1<a.length&&(a=replace(a,this.stemmer)),d&&1<a.length&&(a=collapse(a)),c||""===c)){const b=a.split(c);return this.filter?filter(b,this.filter):b}return a}const regex_normalize=/[\u0300-\u036f]/g;export function normalize(a){return a.normalize&&(a=a.normalize("NFD").replace(regex_normalize,"")),a}export function init_filter(a){const b=create_object();for(let c=0,d=a.length;c<d;c++)b[a[c]]=1;return b}export function init_stemmer_or_matcher(a,b){const c=get_keys(a),d=c.length,e=[];let f="",g=0;for(let h,j,k=0;k<d;k++)h=c[k],j=a[h],j?(e[g++]=regex(b?"(?!\\b)"+h+"(\\b|_)":h),e[g++]=j):f+=(f?"|":"")+h;return f&&(e[g++]=regex(b?"(?!\\b)("+f+")(\\b|_)":"("+f+")"),e[g]=""),e}export function replace(a,b){for(let c=0,d=b.length;c<d&&(a=a.replace(b[c],b[c+1]),!!a);c+=2);return a}export function regex(a){return new RegExp(a,"g")}export function collapse(a){let b="",c="";for(let d,e=0,f=a.length;e<f;e++)(d=a[e])!==c&&(b+=c=d);return b}export function filter(a,b){const c=a.length,d=[];for(let e=0,f=0;e<c;e++){const c=a[e];c&&!b[c]&&(d[f++]=c)}return d}
|
1
dist/module/lang/arabic/default.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface}from"../../type.js";export const rtl=!0;export const tokenize="";export default{encode:encode,rtl:!0};const regex=/[\x00-\x7F]+/g;export function encode(a){return this.pipeline(a.replace(regex," "),!1," ",!1)}
|
1
dist/module/lang/at.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const filter=["aber","als","am","an","auch","auf","aus","bei","bin","bis","bist","da","dadurch","daher","darum","das","da\xDF","dass","dein","deine","dem","den","der","des","dessen","deshalb","die","dies","dieser","dieses","doch","dort","du","durch","ein","eine","einem","einen","einer","eines","er","es","euer","eure","f\xFCr","hatte","hatten","hattest","hattet","hier","hinter","ich","ihr","ihre","im","in","ist","ja","jede","jedem","jeden","jeder","jedes","jener","jenes","jetzt","kann","kannst","k\xF6nnen","k\xF6nnt","machen","mein","meine","mit","mu\xDF","mu\xDFt","musst","m\xFCssen","m\xFC\xDFt","nach","nachdem","nein","nicht","nun","oder","seid","sein","seine","sich","sie","sind","soll","sollen","sollst","sollt","sonst","soweit","sowie","und","unser","unsere","unter","vom","von","vor","wann","warum","was","weiter","weitere","wenn","wer","werde","werden","werdet","weshalb","wie","wieder","wieso","wir","wird","wirst","wo","woher","wohin","zu","zum","zur","\xFCber"];export const stemmer={niss:"",isch:"",lich:"",heit:"",keit:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};
|
1
dist/module/lang/cjk/default.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface}from"../../type.js";export const rtl=!1;export const tokenize="strict";export default{encode:encode,rtl:!1,tokenize:"strict"};const regex=/[\x00-\x7F]+/g;export function encode(a){return this.pipeline(a.replace(regex,""),!1,"",!1)}
|
1
dist/module/lang/cyrillic/default.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface}from"../../type.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1};const regex=/[\x00-\x7F]+/g;export function encode(a){return this.pipeline(a.replace(regex," "),!1," ",!1)}
|
1
dist/module/lang/de.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const filter=["aber","als","am","an","auch","auf","aus","bei","bin","bis","bist","da","dadurch","daher","darum","das","da\xDF","dass","dein","deine","dem","den","der","des","dessen","deshalb","die","dies","dieser","dieses","doch","dort","du","durch","ein","eine","einem","einen","einer","eines","er","es","euer","eure","f\xFCr","hatte","hatten","hattest","hattet","hier","hinter","ich","ihr","ihre","im","in","ist","ja","jede","jedem","jeden","jeder","jedes","jener","jenes","jetzt","kann","kannst","k\xF6nnen","k\xF6nnt","machen","mein","meine","mit","mu\xDF","mu\xDFt","musst","m\xFCssen","m\xFC\xDFt","nach","nachdem","nein","nicht","nun","oder","seid","sein","seine","sich","sie","sind","soll","sollen","sollst","sollt","sonst","soweit","sowie","und","unser","unsere","unter","vom","von","vor","wann","warum","was","weiter","weitere","wenn","wer","werde","werden","werdet","weshalb","wie","wieder","wieso","wir","wird","wirst","wo","woher","wohin","zu","zum","zur","\xFCber"];export const stemmer={niss:"",isch:"",lich:"",heit:"",keit:"",ell:"",bar:"",end:"",ung:"",est:"",ern:"",em:"",er:"",en:"",es:"",st:"",ig:"",ik:"",e:"",s:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};
|
1
dist/module/lang/en.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const filter=["a","about","above","after","again","against","all","also","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","both","but","by","can","cannot","can't","come","could","couldn't","did","didn't","do","does","doesn't","doing","dont","down","during","each","even","few","first","for","from","further","get","go","had","hadn't","has","hasn't","have","haven't","having","he","hed","her","here","here's","hers","herself","hes","him","himself","his","how","how's","i","id","if","ill","im","in","into","is","isn't","it","it's","itself","i've","just","know","let's","like","make","me","more","most","mustn't","my","myself","new","no","nor","not","now","of","off","on","once","only","or","other","ought","our","our's","ourselves","out","over","own","same","say","see","shan't","she","she'd","shell","shes","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","time","to","too","until","up","us","very","want","was","wasn't","way","we","wed","well","were","weren't","we've","what","what's","when","when's","where","where's","which","while","who","whom","who's","why","why's","will","with","won't","would","wouldn't","you","you'd","you'll","your","you're","your's","yourself","yourselves","you've"];export const stemmer={ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};
|
1
dist/module/lang/latin/advanced.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface}from"../../type.js";import{regex,replace,collapse}from"../../lang.js";import{encode as encode_balance}from"./balance.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1,tokenize:""};const regex_ae=regex("ae"),regex_oe=regex("oe"),regex_sh=regex("sh"),regex_th=regex("th"),regex_ph=regex("ph"),regex_pf=regex("pf"),pairs=[regex_ae,"a",regex_oe,"o",regex_sh,"s",regex_th,"t",regex_ph,"f",regex_pf,"f",regex("(?![aeo])h(?![aeo])"),"",regex("(?!^[aeo])h(?!^[aeo])"),""];export function encode(a,b){return a&&(a=encode_balance.call(this,a).join(" "),2<a.length&&(a=replace(a,pairs)),!b&&(1<a.length&&(a=collapse(a)),a&&(a=a.split(" ")))),a}
|
1
dist/module/lang/latin/balance.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface}from"../../type.js";import{encode as encode_simple}from"./simple.js";export const rtl=!1;export const tokenize="strict";export default{encode:encode,rtl:!1,tokenize:"strict"};const regex_strip=/[^a-z0-9]+/,soundex={b:"p",v:"f",w:"f",z:"s",x:"s",ß:"s",d:"t",n:"m",c:"k",g:"k",j:"k",q:"k",i:"e",y:"e",u:"o"};export function encode(a){a=encode_simple.call(this,a).join(" ");const b=[];if(a){const c=a.split(regex_strip),d=c.length;for(let e,f=0,g=0;f<d;f++)if((a=c[f])&&(!this.filter||!this.filter[a])){e=a[0];let c=soundex[e]||e,d=c;for(let b=1;b<a.length;b++){e=a[b];const f=soundex[e]||e;f&&f!==d&&(c+=f,d=f)}b[g++]=c}}return b}
|
1
dist/module/lang/latin/default.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface}from"../../type.js";import{normalize}from"../../lang.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1,tokenize:""};const regex_whitespace=/[\W_]+/;export function encode(a){return this.pipeline(normalize(a).toLowerCase(),!1,regex_whitespace,!1)}
|
1
dist/module/lang/latin/extra.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface}from"../../type.js";import{regex,replace,collapse}from"../../lang.js";import{encode as encode_advanced}from"./advanced.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1,tokenize:""};const prefix="(?!\\b)",regex_vowel=regex("(?!\\b)[aeo]"),pairs=[regex_vowel,""];export function encode(a){return a&&(a=encode_advanced.call(this,a,!0),1<a.length&&(a=a.replace(regex_vowel,"")),1<a.length&&(a=collapse(a)),a&&(a=a.split(" "))),a}
|
1
dist/module/lang/latin/simple.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface}from"../../type.js";import{normalize,regex}from"../../lang.js";export const rtl=!1;export const tokenize="";export default{encode:encode,rtl:!1,tokenize:""};const regex_whitespace=/[\W_]+/,regex_a=regex("[\xE0\xE1\xE2\xE3\xE4\xE5]"),regex_e=regex("[\xE8\xE9\xEA\xEB]"),regex_i=regex("[\xEC\xED\xEE\xEF]"),regex_o=regex("[\xF2\xF3\xF4\xF5\xF6\u0151]"),regex_u=regex("[\xF9\xFA\xFB\xFC\u0171]"),regex_y=regex("[\xFD\u0177\xFF]"),regex_n=regex("\xF1"),regex_c=regex("[\xE7c]"),regex_s=regex("\xDF"),regex_and=regex(" & "),pairs=[regex_a,"a",regex_e,"e",regex_i,"i",regex_o,"o",regex_u,"u",regex_y,"y",regex_n,"n",regex_c,"k",regex_s,"s",regex_and," and "];export function encode(a){return this.pipeline(normalize(a).toLowerCase(),!a.normalize&&pairs,regex_whitespace,!1)}
|
1
dist/module/lang/us.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export const filter=["a","about","above","after","again","against","all","also","am","an","and","any","are","aren't","as","at","be","because","been","before","being","below","both","but","by","can","cannot","can't","come","could","couldn't","did","didn't","do","does","doesn't","doing","dont","down","during","each","even","few","first","for","from","further","get","go","had","hadn't","has","hasn't","have","haven't","having","he","hed","her","here","here's","hers","herself","hes","him","himself","his","how","how's","i","id","if","ill","im","in","into","is","isn't","it","it's","itself","i've","just","know","let's","like","make","me","more","most","mustn't","my","myself","new","no","nor","not","now","of","off","on","once","only","or","other","ought","our","our's","ourselves","out","over","own","same","say","see","shan't","she","she'd","shell","shes","should","shouldn't","so","some","such","than","that","that's","the","their","theirs","them","themselves","then","there","there's","these","they","they'd","they'll","they're","they've","this","those","through","time","to","too","until","up","us","very","want","was","wasn't","way","we","wed","well","were","weren't","we've","what","what's","when","when's","where","where's","which","while","who","whom","who's","why","why's","will","with","won't","would","wouldn't","you","you'd","you'll","your","you're","your's","yourself","yourselves","you've"];export const stemmer={ational:"ate",iveness:"ive",fulness:"ful",ousness:"ous",ization:"ize",tional:"tion",biliti:"ble",icate:"ic",ative:"",alize:"al",iciti:"ic",entli:"ent",ousli:"ous",alism:"al",ation:"ate",aliti:"al",iviti:"ive",ement:"",enci:"ence",anci:"ance",izer:"ize",alli:"al",ator:"ate",logi:"log",ical:"ic",ance:"",ence:"",ness:"",able:"",ible:"",ment:"",eli:"e",bli:"ble",ful:"",ant:"",ent:"",ism:"",ate:"",iti:"",ous:"",ive:"",ize:"",al:"",ou:"",er:"",ic:""};export const matcher={};export default{filter:filter,stemmer:stemmer,matcher:matcher};
|
1
dist/module/polyfill.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{POLYFILL,SUPPORT_ASYNC}from"./config.js";export let promise=Promise;if(POLYFILL&&(Object.assign||(Object.assign=function(){const a=arguments,b=a.length,c=a[0];for(let d,e,f,g=1;g<b;g++){d=a[g],e=Object.keys(d),f=e.length;for(let a,b=0;b<f;b++)a=e[b],c[a]=d[a]}return c}),SUPPORT_ASYNC&&!promise)){function a(a){this.callback=null;const b=this;a(function(a){b.callback&&b.callback(a)})}a.prototype.then=function(a){this.callback=a},promise=a}
|
1
dist/module/preset.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{DEBUG}from"./config.js";import{is_string}from"./common.js";const preset={memory:{charset:"latin:extra",resolution:3,minlength:3,fastupdate:!1,optimize:"memory"},performance:{threshold:8,minlength:3,context:{depth:1,bidirectional:!0}},match:{charset:"latin:extra",tokenize:"full",resolution:3},score:{charset:"latin:advanced",threshold:1,context:{depth:3,bidirectional:!0}},default:{resolution:3,threshold:0,depth:3}};export default function apply_preset(a){if(is_string(a))DEBUG&&!preset[a]&&console.warn("Preset not found: "+a),a=preset[a];else{const b=a.preset;b&&(DEBUG&&!b[b]&&console.warn("Preset not found: "+b),a=Object.assign({},b[b],a))}return a}
|
1
dist/module/serialize.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{IndexInterface,DocumentInterface}from"./type.js";import{create_object,is_string}from"./common.js";function async(a,b,c,d,e,f){setTimeout(function(){const g=a(c,JSON.stringify(f));g&&g.then?g.then(function(){b.export(a,b,c,d,e+1)}):b.export(a,b,c,d,e+1)})}export function exportIndex(a,b,c,d,e){let f,g;switch(e||(e=0)){case 0:if(f="reg",this.fastupdate)for(let a in g=create_object(),this.register)g[a]=1;else g=this.register;break;case 1:f="cfg",g={doc:0,opt:this.optimize?1:0};break;case 2:f="map",g=this.map;break;case 3:f="ctx",g=this.ctx;break;default:return;}return async(a,b||this,c?c+"."+f:f,d,e,g),!0}export function importIndex(a,b){b&&(is_string(b)&&(b=JSON.parse(b)),"cfg"===a?this.optimize=!!b.opt:"reg"===a?(this.fastupdate=!1,this.register=b):"map"===a?this.map=b:"ctx"===a?this.ctx=b:void 0)}export function exportDocument(a,b,c,d,e){if(e||(e=0),d||(d=0),d<this.field.length){const c=this.field[d],f=this.index[c];b=this,setTimeout(function(){f.export(a,b,e?c.replace(":","-"):"",d,e++)||(d++,e=1,b.export(a,b,c,d,e))})}else{let b,c;switch(e){case 1:b="tag",c=this.tagindex;break;case 2:b="store",c=this.store;break;default:return;}async(a,this,b,d,e,c)}}export function importDocument(a,b){if(b)switch(is_string(b)&&(b=JSON.parse(b)),a){case"tag":this.tagindex=b;break;case"reg":this.fastupdate=!1,this.register=b;for(let a,c=0;c<this.field.length;c++)a=this.index[this.field[c]],a.register=b,a.fastupdate=!1;break;case"store":this.store=b;break;default:a=a.split(".");const c=a[0];a=a[1],c&&a&&this.index[c].import(a,b);}}
|
1
dist/module/type.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export function IndexInterface(){this.cache=null,this.matcher=null,this.stemmer=null,this.filter=null}IndexInterface.prototype.pipeline,IndexInterface.prototype.add,IndexInterface.prototype.append,IndexInterface.prototype.search,IndexInterface.prototype.update,IndexInterface.prototype.remove;export function DocumentInterface(){this.field=null,this.index=null}
|
1
dist/module/webpack.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{SUPPORT_ASYNC,SUPPORT_DOCUMENT,SUPPORT_CACHE,SUPPORT_SERIALIZE,SUPPORT_WORKER,SUPPORT_ENCODER}from"./config.js";import Document from"./document.js";import Index from"./index.js";import WorkerIndex from"./worker/index.js";import{registerCharset,registerLanguage}from"./global.js";import charset_default from"./lang/latin/default.js";import charset_simple from"./lang/latin/simple.js";import charset_balance from"./lang/latin/balance.js";import charset_advanced from"./lang/latin/advanced.js";import charset_extra from"./lang/latin/extra.js";Document.prototype.add,Document.prototype.append,Document.prototype.search,Document.prototype.update,Document.prototype.remove,Document.prototype.contain,Document.prototype.get,Document.prototype.set,Index.prototype.add,Index.prototype.append,Index.prototype.search,Index.prototype.update,Index.prototype.remove,Index.prototype.contain,SUPPORT_CACHE&&(Index.prototype.searchCache,Document.prototype.searchCache),SUPPORT_ASYNC&&(Document.prototype.addAsync,Document.prototype.appendAsync,Document.prototype.searchAsync,Document.prototype.updateAsync,Document.prototype.removeAsync,Index.prototype.addAsync,Index.prototype.appendAsync,Index.prototype.searchAsync,Index.prototype.updateAsync,Index.prototype.removeAsync),SUPPORT_SERIALIZE&&(Index.prototype.export,Index.prototype.import,Document.prototype.export,Document.prototype.import),SUPPORT_ENCODER&&(registerCharset("latin:default",charset_default),registerCharset("latin:simple",charset_simple),registerCharset("latin:balance",charset_balance),registerCharset("latin:advanced",charset_advanced),registerCharset("latin:extra",charset_extra));const root=self;let tmp;const FlexSearch={Index:Index,Document:SUPPORT_DOCUMENT?Document:null,Worker:SUPPORT_WORKER?WorkerIndex:null,registerCharset:registerCharset,registerLanguage:registerLanguage};(tmp=root.define)&&tmp.amd?tmp([],function(){return FlexSearch}):root.exports?root.exports=FlexSearch:root.FlexSearch=FlexSearch;
|
1
dist/module/worker/handler.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import Index from"../index.js";export default function(a){a=a.data;const b=self._index,c=a.args,d=a.task;switch(d){case"init":const e=a.options||{},f=a.factory,g=e.encode;e.cache=!1,g&&0===g.indexOf("function")&&(e.encode=Function("return "+g)()),f?(Function("return "+f)()(self),self._index=new self.FlexSearch.Index(e),delete self.FlexSearch):self._index=new Index(e);break;default:const h=a.id,i=b[d].apply(b,c);postMessage("search"===d?{id:h,msg:i}:{id:h});}}
|
1
dist/module/worker/index.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import{create_object,is_function,is_object,is_string}from"../common.js";import handler from"./handler.js";let pid=0;function WorkerIndex(a){let b;a?is_function(b=a.encode)&&(a.encode=b.toString()):a={};let c=(self||window)._factory;c&&(c=c.toString());const d=self.exports,e=this;this.worker=create(c,d,a.worker),this.resolver=create_object();this.worker&&(d?this.worker.on("message",function(a){e.resolver[a.id](a.msg),delete e.resolver[a.id]}):this.worker.onmessage=function(a){a=a.data,e.resolver[a.id](a.msg),delete e.resolver[a.id]},this.worker.postMessage({task:"init",factory:c,options:a}))}export default WorkerIndex;register("add"),register("append"),register("search"),register("update"),register("remove");function register(a){WorkerIndex.prototype[a]=WorkerIndex.prototype[a+"Async"]=function(){const b=this,c=[].slice.call(arguments),d=c[c.length-1];let e;is_function(d)&&(e=d,c.splice(c.length-1,1));const f=new Promise(function(d){setTimeout(function(){b.resolver[++pid]=d,b.worker.postMessage({task:a,id:pid,args:c})})});return e?(f.then(e),this):f}}function create(factory,is_node_js,worker_path){let worker;try{worker=is_node_js?eval("new (require(\"worker_threads\")[\"Worker\"])(\"../dist/node/node.js\")"):factory?new Worker(URL.createObjectURL(new Blob(["onmessage="+handler.toString()],{type:"text/javascript"}))):new Worker(is_string(worker_path)?worker_path:"worker/worker.js",{type:"module"})}catch(a){}return worker}
|
1
dist/module/worker/node.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
const{parentPort}=require("worker_threads"),{Index}=require("../flexsearch.bundle.js");let index;parentPort.on("message",function(a){const b=a.args,c=a.task,d=a.id;switch(c){case"init":const e=a.options||{},f=e.encode;e.cache=!1,f&&0===f.indexOf("function")&&(e.encode=new Function("return "+f)()),index=new Index(e);break;default:const g=index[c].apply(index,b);parentPort.postMessage("search"===c?{id:d,msg:g}:{id:d});}});
|
1
dist/module/worker/worker.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
import handler from"./handler.js";onmessage=handler;
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 8.4 KiB |
@@ -1,98 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
||||
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
||||
width="3098.000000pt" height="578.000000pt" viewBox="0 0 3098.000000 578.000000"
|
||||
preserveAspectRatio="xMidYMid meet">
|
||||
<g transform="translate(0.000000,578.000000) scale(0.100000,-0.100000)"
|
||||
fill="#000000" stroke="none">
|
||||
<path fill="#c21794" d="M3225 5749 c-88 -16 -202 -36 -252 -45 l-93 -16 0 -1898 c0 -1230 4
|
||||
-1934 10 -2001 48 -479 298 -696 836 -727 l113 -7 6 25 c6 29 75 446 75 453 0
|
||||
2 -24 7 -52 10 -82 10 -209 46 -253 72 -87 51 -136 137 -154 268 -8 53 -11
|
||||
691 -11 1988 l0 1909 -32 -1 c-18 -1 -105 -14 -193 -30z"/>
|
||||
<path fill="#1727c2" d="M23800 5744 c-102 -18 -215 -38 -252 -44 l-68 -12 0 -2289 0 -2289
|
||||
285 0 285 0 2 1303 3 1302 76 22 c148 42 315 65 504 70 155 4 194 2 280 -16
|
||||
290 -60 438 -234 499 -587 29 -169 36 -393 36 -1241 l0 -853 280 0 281 0 -3
|
||||
1048 c-4 1046 -4 1047 -27 1172 -40 219 -84 345 -166 483 -143 244 -373 398
|
||||
-697 469 -92 20 -131 22 -373 22 -255 0 -277 -1 -395 -26 -69 -15 -164 -41
|
||||
-212 -57 l-88 -30 0 795 0 794 -32 -1 c-18 -1 -116 -16 -218 -35z"/>
|
||||
<path fill="#1727c2" d="M11100 5355 c-532 -75 -894 -342 -1024 -755 -75 -236 -73 -553 4
|
||||
-774 86 -248 292 -456 610 -615 139 -70 217 -101 595 -241 395 -146 544 -233
|
||||
686 -398 123 -142 174 -348 135 -542 -55 -271 -250 -422 -617 -476 -91 -13
|
||||
-162 -15 -354 -11 -295 6 -412 24 -640 101 -156 53 -340 128 -359 147 -30 29
|
||||
-42 7 -126 -223 -47 -127 -87 -235 -88 -240 -2 -5 43 -30 100 -57 235 -111
|
||||
526 -190 838 -226 165 -20 536 -20 702 0 397 46 693 172 900 382 181 184 263
|
||||
387 275 678 18 429 -113 742 -408 978 -165 132 -384 242 -864 434 -306 123
|
||||
-414 174 -530 251 -92 60 -193 157 -233 223 -59 97 -86 269 -63 394 44 237
|
||||
249 406 560 460 109 20 393 19 530 0 193 -28 426 -97 573 -171 39 -20 74 -32
|
||||
78 -27 5 4 47 107 95 228 48 121 89 225 91 231 7 16 -132 86 -252 127 -127 44
|
||||
-317 91 -454 113 -144 22 -626 29 -760 9z"/>
|
||||
<path fill="#c21794" d="M0 3195 l0 -2085 295 0 295 0 0 955 0 955 855 0 855 0 0 250 0 250
|
||||
-855 0 -855 0 0 625 0 625 965 0 965 0 0 255 0 255 -1260 0 -1260 0 0 -2085z"/>
|
||||
<path fill="#c21794" d="M5235 4304 c-298 -53 -547 -184 -748 -393 -194 -203 -331 -474 -392
|
||||
-775 -61 -304 -57 -680 11 -976 144 -632 591 -1022 1258 -1101 146 -17 570 -6
|
||||
711 19 182 33 438 105 478 135 15 11 13 31 -22 240 -21 125 -40 230 -43 233
|
||||
-3 3 -53 -11 -109 -30 -255 -87 -429 -111 -736 -103 -223 6 -310 20 -447 71
|
||||
-305 115 -497 406 -544 824 l-8 72 1066 0 1067 0 6 78 c8 90 -7 431 -23 547
|
||||
-94 681 -438 1072 -1020 1160 -121 19 -398 18 -505 -1z m465 -492 c285 -93
|
||||
490 -413 490 -763 l0 -69 -765 0 -765 0 0 29 c0 42 53 245 84 321 101 247 308
|
||||
436 544 495 88 22 327 14 412 -13z"/>
|
||||
<path fill="#1727c2" d="M14105 4304 c-298 -53 -547 -184 -748 -393 -194 -203 -331 -474 -392
|
||||
-775 -61 -304 -57 -680 11 -976 143 -626 585 -1017 1244 -1100 177 -22 540
|
||||
-12 740 21 146 24 426 104 463 132 15 11 13 31 -22 240 -21 125 -40 230 -43
|
||||
233 -3 3 -53 -11 -109 -30 -255 -87 -429 -111 -736 -103 -223 6 -310 20 -447
|
||||
71 -305 115 -497 406 -544 824 l-8 72 1066 0 1067 0 6 78 c8 90 -7 431 -23
|
||||
547 -94 681 -438 1072 -1020 1160 -121 19 -398 18 -505 -1z m465 -492 c285
|
||||
-93 490 -413 490 -763 l0 -69 -765 0 -765 0 0 29 c0 42 53 245 84 321 101 247
|
||||
308 436 544 495 88 22 327 14 412 -13z"/>
|
||||
<path fill="#1727c2" d="M16810 4309 c-165 -17 -437 -73 -522 -106 -23 -9 -38 -22 -38 -32 0
|
||||
-9 14 -116 32 -237 l31 -222 54 19 c178 61 444 99 696 99 292 0 419 -40 553
|
||||
-174 128 -128 178 -277 191 -565 l6 -154 -24 6 c-314 78 -706 89 -1013 26
|
||||
-454 -92 -744 -332 -826 -682 -38 -165 -35 -386 9 -552 101 -385 393 -606 885
|
||||
-671 279 -37 838 -7 1344 73 l173 27 -4 1110 c-4 1214 -1 1164 -63 1366 -115
|
||||
375 -397 599 -837 664 -116 18 -497 20 -647 5z m866 -1787 c50 -11 101 -25
|
||||
113 -31 l21 -12 -2 -457 -3 -457 -70 -14 c-50 -9 -170 -14 -415 -14 -330 -2
|
||||
-349 -1 -425 21 -290 82 -405 231 -393 514 4 95 8 113 36 171 76 153 263 263
|
||||
505 297 34 5 170 7 302 5 195 -2 257 -7 331 -23z"/>
|
||||
<path fill="#1727c2" d="M22105 4313 c-316 -40 -612 -181 -821 -390 -224 -223 -371 -525 -435
|
||||
-889 -30 -172 -33 -518 -6 -694 59 -382 189 -662 412 -885 189 -190 435 -318
|
||||
722 -376 135 -27 467 -38 625 -19 237 27 454 74 553 121 l42 20 -40 240 c-35
|
||||
207 -42 239 -56 233 -50 -23 -226 -77 -314 -96 -89 -20 -132 -22 -342 -23
|
||||
-216 0 -249 2 -328 22 -363 93 -580 329 -665 723 -29 135 -45 334 -37 475 27
|
||||
486 192 800 500 951 143 70 220 86 430 91 151 4 200 2 301 -16 114 -19 252
|
||||
-58 336 -95 34 -15 37 -15 42 2 3 9 30 112 61 227 31 116 58 217 61 226 9 31
|
||||
-286 115 -509 144 -108 14 -446 19 -532 8z"/>
|
||||
<path fill="#1727c2" d="M19810 4303 c-204 -19 -494 -79 -722 -150 l-118 -36 0 -1504 0 -1503
|
||||
285 0 285 0 0 1314 0 1313 148 33 c131 30 168 34 341 38 219 5 331 -6 496 -48
|
||||
61 -15 117 -31 125 -34 12 -5 23 38 64 244 27 138 47 253 44 255 -5 6 -122 30
|
||||
-268 57 -94 17 -163 21 -375 23 -143 1 -280 1 -305 -2z"/>
|
||||
<path fill="#c21794" d="M6988 4173 c26 -38 268 -378 536 -756 l488 -689 -28 -38 c-16 -21
|
||||
-101 -132 -190 -247 -285 -369 -527 -705 -671 -933 -95 -149 -223 -372 -223
|
||||
-387 0 -10 57 -13 289 -13 l289 0 52 93 c103 181 273 431 483 712 107 143 259
|
||||
337 292 373 10 11 38 -19 147 -155 283 -352 531 -702 653 -920 l58 -103 281 1
|
||||
c154 1 293 4 308 8 l28 6 -88 150 c-208 355 -379 598 -865 1230 -94 121 -174
|
||||
227 -180 235 -7 13 106 179 512 755 l522 740 -303 3 c-233 2 -305 -1 -314 -10
|
||||
-6 -7 -172 -244 -369 -525 -196 -282 -360 -513 -364 -513 -3 0 -171 236 -372
|
||||
523 l-366 522 -327 3 -326 2 48 -67z"/>
|
||||
<path fill="#b5b5b5" d="M27919 5517 c-149 -63 -229 -201 -216 -372 17 -229 186 -361 424
|
||||
-333 117 14 221 89 272 197 23 50 26 68 26 166 0 98 -3 116 -26 166 -33 70
|
||||
-91 129 -161 166 -46 23 -67 27 -158 30 -92 3 -112 1 -161 -20z"/>
|
||||
<path fill="#b5b5b5" d="M29665 4304 c-316 -49 -572 -193 -715 -403 -95 -141 -134 -280 -133
|
||||
-481 0 -160 17 -250 68 -355 79 -164 225 -302 428 -402 56 -28 212 -97 346
|
||||
-153 484 -201 632 -293 703 -438 31 -62 33 -74 33 -167 0 -93 -3 -106 -30
|
||||
-160 -50 -97 -141 -154 -310 -193 -55 -13 -126 -17 -340 -17 -324 0 -362 6
|
||||
-647 103 -108 36 -199 64 -201 62 -2 -3 -26 -111 -53 -240 -35 -161 -47 -237
|
||||
-40 -243 6 -4 80 -30 164 -57 271 -88 425 -110 776 -110 153 0 272 5 351 15
|
||||
571 75 875 339 910 790 7 99 -6 257 -30 350 -22 88 -87 211 -147 282 -135 159
|
||||
-331 269 -783 438 -224 84 -402 170 -477 229 -179 143 -210 392 -65 536 44 45
|
||||
150 100 242 125 81 23 359 31 497 15 125 -14 305 -59 414 -104 l81 -33 51 245
|
||||
c39 182 49 248 40 253 -18 12 -235 66 -328 83 -262 48 -609 60 -805 30z"/>
|
||||
<path fill="#b5b5b5" d="M27778 2593 l-3 -1648 -23 -79 c-62 -212 -174 -330 -350 -367 -73
|
||||
-15 -297 -6 -372 14 -30 9 -56 14 -58 12 -8 -7 -73 -448 -69 -459 5 -13 88
|
||||
-36 201 -56 33 -5 124 -10 202 -10 220 0 380 34 541 115 231 116 381 313 454
|
||||
600 49 189 49 184 49 1908 l0 1617 -285 0 -285 0 -2 -1647z"/>
|
||||
<path fill="#b5b5b5" d="M26731 1824 c-101 -36 -174 -106 -224 -213 -29 -61 -32 -74 -32 -171
|
||||
0 -97 3 -110 32 -172 81 -173 225 -247 435 -226 223 22 366 219 337 463 -16
|
||||
128 -102 250 -214 302 -53 24 -74 28 -175 30 -86 2 -126 -1 -159 -13z"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 6.8 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
1203
doc/pipeline.svg
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 47 KiB |
4071
flexsearch.js
16
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "flexsearch",
|
||||
"version": "0.7.0-beta",
|
||||
"version": "0.7.0",
|
||||
"description": "Next-Generation full text search library with zero dependencies.",
|
||||
"homepage": "https://github.com/nextapps-de/flexsearch/",
|
||||
"author": "Thomas Wilkerling",
|
||||
@@ -39,17 +39,15 @@
|
||||
"build:es5": "node task/build RELEASE=es5 LANGUAGE_OUT=ECMASCRIPT5_STRICT POLYFILL=true",
|
||||
"build:pre": "node task/build RELEASE=pre COMPILATION_LEVEL=WHITESPACE FORMATTING=PRETTY_PRINT",
|
||||
"build:lang": "node task/build RELEASE=lang",
|
||||
"build:module": "babel src -d dist/module && exit 0",
|
||||
"build:all": "npm run build && npm run build:light && npm run build:compact && npm run build:es5 && npm run build:debug",
|
||||
"test": "npm run build:pre && cd test && npm install && npm run test",
|
||||
"update": "npm install google-closure-compiler@nightly"
|
||||
"build:module": "npx babel src -d dist/module && exit 0",
|
||||
"build:all": "npm run build && npm run build:light && npm run build:compact && npm run build:es5 && npm run build:debug && npm run build:module",
|
||||
"test": "cd test && npm install && npm run test",
|
||||
"server": "node task/server"
|
||||
},
|
||||
"files": [
|
||||
"dist/**",
|
||||
"src/**",
|
||||
"task/**",
|
||||
"test/",
|
||||
"index.d.ts",
|
||||
"README.md",
|
||||
"CHANGELOG.md",
|
||||
"LICENSE"
|
||||
@@ -57,7 +55,6 @@
|
||||
"readme": "README.md",
|
||||
"devDependencies": {
|
||||
"babel-cli": "^6.26.0",
|
||||
"babel-plugin-conditional-compile": "0.0.5",
|
||||
"babel-plugin-minify-constant-folding": "^0.5.0",
|
||||
"babel-plugin-minify-dead-code-elimination": "^0.5.1",
|
||||
"babel-plugin-minify-flip-comparisons": "^0.4.3",
|
||||
@@ -74,6 +71,7 @@
|
||||
"babel-plugin-transform-simplify-comparison-operators": "^6.9.4",
|
||||
"babel-plugin-transform-undefined-to-void": "^6.9.4",
|
||||
"cpx": "^1.5.0",
|
||||
"google-closure-compiler": "^20210505.0.0"
|
||||
"google-closure-compiler": "^20210604.0.0-nightly",
|
||||
"web-servo": "^0.5.1"
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/** @define {boolean} */
|
||||
export const DEBUG = true;
|
||||
export const DEBUG = false;
|
||||
|
||||
/** @define {boolean} */
|
||||
export const POLYFILL = true;
|
||||
@@ -10,9 +10,6 @@ export const SUPPORT_WORKER = true;
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_ENCODER = true;
|
||||
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_LANG = true;
|
||||
|
||||
/** @define {boolean} */
|
||||
export const SUPPORT_CACHE = true;
|
||||
|
||||
|
@@ -10,9 +10,6 @@ export const SUPPORT_WORKER = true;
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_ENCODER = true;
|
||||
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_LANG = true;
|
||||
|
||||
/** @define {boolean} */
|
||||
export const SUPPORT_CACHE = true;
|
||||
|
||||
|
@@ -10,9 +10,6 @@ export const SUPPORT_WORKER = false;
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_ENCODER = true;
|
||||
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_LANG = false;
|
||||
|
||||
/** @define {boolean} */
|
||||
export const SUPPORT_CACHE = false;
|
||||
|
||||
|
@@ -10,9 +10,6 @@ export const SUPPORT_WORKER = true;
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_ENCODER = true;
|
||||
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_LANG = true;
|
||||
|
||||
/** @define {boolean} */
|
||||
export const SUPPORT_CACHE = true;
|
||||
|
||||
|
@@ -10,9 +10,6 @@ export const SUPPORT_WORKER = false;
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_ENCODER = false;
|
||||
|
||||
/** @define {boolean|string} */
|
||||
export const SUPPORT_LANG = false;
|
||||
|
||||
/** @define {boolean} */
|
||||
export const SUPPORT_CACHE = false;
|
||||
|
||||
|
@@ -248,16 +248,20 @@ function add_index(obj, tree, marker, pos, index, id, key, _append){
|
||||
|
||||
if(is_array(obj)){
|
||||
|
||||
// append array contents so each entry gets a new scoring context
|
||||
|
||||
if(marker[pos]){
|
||||
|
||||
for(let i = 0; i < obj.length; i++){
|
||||
|
||||
index.add(id, obj[i], /* append: */ true, /* skip_update: */ true);
|
||||
index.add(id, obj[i], /* append: */ true, /* skip update: */ true);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// or join array contents and use one scoring context
|
||||
|
||||
obj = obj.join(" ");
|
||||
}
|
||||
|
||||
@@ -270,6 +274,7 @@ function add_index(obj, tree, marker, pos, index, id, key, _append){
|
||||
for(let i = 0; i < obj.length; i++){
|
||||
|
||||
// do not increase index, an array is not a field
|
||||
|
||||
add_index(obj, tree, marker, pos, index, id, i, _append);
|
||||
}
|
||||
}
|
||||
@@ -300,7 +305,7 @@ Document.prototype.add = function(id, content, _append){
|
||||
|
||||
if(content && (id || (id === 0))){
|
||||
|
||||
if(this.register[id]){
|
||||
if(!_append && this.register[id]){
|
||||
|
||||
return this.update(id, content);
|
||||
}
|
||||
@@ -353,7 +358,9 @@ Document.prototype.add = function(id, content, _append){
|
||||
}
|
||||
}
|
||||
|
||||
if(SUPPORT_STORE && this.store){
|
||||
// TODO: how to handle store when appending contents?
|
||||
|
||||
if(SUPPORT_STORE && this.store && (!_append || !this.store[id])){
|
||||
|
||||
let store;
|
||||
|
||||
@@ -402,15 +409,13 @@ Document.prototype.remove = function(id){
|
||||
|
||||
if(this.register[id]){
|
||||
|
||||
const fastupdate = this.fastupdate && !this.worker;
|
||||
|
||||
for(let i = 0; i < this.field.length; i++){
|
||||
|
||||
this.index[this.field[i]].remove(id, fastupdate);
|
||||
|
||||
// workers does not share the register
|
||||
|
||||
if(fastupdate){
|
||||
this.index[this.field[i]].remove(id, !this.worker);
|
||||
|
||||
if(this.fastupdate){
|
||||
|
||||
// when fastupdate was enabled all ids are removed
|
||||
|
||||
@@ -422,7 +427,7 @@ Document.prototype.remove = function(id){
|
||||
|
||||
// when fastupdate was enabled all ids are already removed
|
||||
|
||||
if(!fastupdate){
|
||||
if(!this.fastupdate){
|
||||
|
||||
for(let key in this.tagindex){
|
||||
|
||||
@@ -528,10 +533,6 @@ Document.prototype.search = function(query, limit, options, _resolve){
|
||||
|
||||
field = [field];
|
||||
}
|
||||
else if(!is_array(field)){
|
||||
|
||||
field = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
32
src/index.js
@@ -126,23 +126,24 @@ Index.prototype.append = function(id, content){
|
||||
|
||||
Index.prototype.add = function(id, content, _append, _skip_update){
|
||||
|
||||
if(!_skip_update && !_append && this.register[id]){
|
||||
|
||||
return this.update(id, content);
|
||||
}
|
||||
|
||||
if(content && (id || (id === 0))){
|
||||
|
||||
if(!_skip_update && !_append && this.register[id]){
|
||||
|
||||
return this.update(id, content);
|
||||
}
|
||||
|
||||
content = this.encode(content);
|
||||
const length = content.length;
|
||||
|
||||
if(length){
|
||||
|
||||
// check context dupes to skip all contextual redundancy along a document
|
||||
|
||||
const dupes_ctx = create_object();
|
||||
const dupes = create_object();
|
||||
const depth = this.depth;
|
||||
const resolution = this.resolution;
|
||||
const dupes = create_object();
|
||||
// check context dupes to skip all contextual redundancy along a document
|
||||
const dupes_ctx = create_object();
|
||||
|
||||
for(let i = 0; i < length; i++){
|
||||
|
||||
@@ -215,22 +216,27 @@ Index.prototype.add = function(id, content, _append, _skip_update){
|
||||
this.push_index(dupes, token, score, id, _append);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
// fallthrough to next case when token has a length of 1
|
||||
|
||||
//case "strict":
|
||||
default:
|
||||
// case "strict":
|
||||
|
||||
this.push_index(dupes, term, score, id, _append);
|
||||
|
||||
// context is just supported by tokenizer "strict"
|
||||
|
||||
if(depth){
|
||||
|
||||
if((length > 1) && (i < (length - 1))){
|
||||
|
||||
const resolution = this.resolution_ctx;
|
||||
// check inner dupes to skip repeating words in the current context
|
||||
|
||||
const dupes_inner = create_object();
|
||||
const resolution = this.resolution_ctx;
|
||||
const keyword = term;
|
||||
const size = Math.min(depth + 1, length - i);
|
||||
|
||||
@@ -643,6 +649,10 @@ function get_array(arr, term, keyword, bidirectional){
|
||||
|
||||
if(keyword){
|
||||
|
||||
// the frequency of the starting letter is slightly less
|
||||
// on the last half of the alphabet (m-z) in almost every latin language,
|
||||
// so we sort downwards (https://en.wikipedia.org/wiki/Letter_frequency)
|
||||
|
||||
const swap = bidirectional && (term > keyword);
|
||||
|
||||
arr = arr[swap ? term : keyword];
|
||||
|