mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-10-03 00:21:51 +02:00
v0.5.0 Where / Find / Tags / Custom Sort
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
#### v0.5.0
|
||||
|
||||
- Where / Find Documents
|
||||
- Document Tags
|
||||
- Custom Sort
|
||||
|
||||
#### v0.4.0
|
||||
|
||||
- Index Documents (Field-Search)
|
||||
|
293
README.md
293
README.md
@@ -21,7 +21,7 @@ FlexSearch also provides you a non-blocking asynchronous processing model as wel
|
||||
|
||||
FlexSearch Server is also available here: <a target="_blank" href="https://github.com/nextapps-de/flexsearch-server">https://github.com/nextapps-de/flexsearch-server</a>.
|
||||
|
||||
<a href="#installation">Installation Guide</a>  •  <a href="#api">API Reference</a>  •  <a href="#presets">Presets</a>  •  <a href="#builds">Custom Builds</a>  •  <a target="_blank" href="https://github.com/nextapps-de/flexsearch-server">Flexsearch Server</a>  •  <a href="CHANGELOG.md">Changelog</a>
|
||||
<a href="#installation">Installation Guide</a>  •  <a href="#api">API Reference</a>  •  <a href="#builds">Custom Builds</a>  •  <a target="_blank" href="https://github.com/nextapps-de/flexsearch-server">Flexsearch Server</a>  •  <a href="CHANGELOG.md">Changelog</a>
|
||||
|
||||
Supported Platforms:
|
||||
- Browser
|
||||
@@ -123,6 +123,15 @@ All Features:
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#where">Where / Find</a> / <a href="#tags">Tags</a>
|
||||
</td>
|
||||
<td>✔</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
<tr>
|
||||
<td>
|
||||
Partial Matching
|
||||
@@ -681,7 +690,9 @@ index.search({
|
||||
limit: 1000,
|
||||
threshold: 5, // >= threshold
|
||||
depth: 3, // <= depth
|
||||
callback: function(results){/* ... */}
|
||||
callback: function(results){
|
||||
// ...
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
@@ -1080,23 +1091,23 @@ Assume the document array looks more complex (has nested branches etc.), e.g.:
|
||||
var docs = [{
|
||||
data:{
|
||||
id: 0,
|
||||
title: "Title",
|
||||
title: "Foo",
|
||||
body: {
|
||||
content: "Body"
|
||||
content: "Foobar"
|
||||
}
|
||||
}
|
||||
},{
|
||||
data:{
|
||||
id: 1,
|
||||
title: "Title",
|
||||
title: "Bar",
|
||||
body: {
|
||||
content: "Body"
|
||||
content: "Foobar"
|
||||
}
|
||||
}
|
||||
}];
|
||||
```
|
||||
|
||||
Then use the colon separated notation ___"root:child"___ to define hierarchy within the document descriptor:
|
||||
Then use the colon separated notation ___"root:child:child"___ to define hierarchy within the document descriptor:
|
||||
|
||||
```js
|
||||
var index = new FlexSearch({
|
||||
@@ -1104,7 +1115,7 @@ var index = new FlexSearch({
|
||||
id: "data:id",
|
||||
field: [
|
||||
"data:title",
|
||||
"data:content:body"
|
||||
"data:body:content"
|
||||
]
|
||||
}
|
||||
});
|
||||
@@ -1146,7 +1157,9 @@ index.remove(id);
|
||||
|
||||
#### Field-Search
|
||||
|
||||
Searching gives you several options when using documents.
|
||||
The search gives you several options when using documents.
|
||||
|
||||
> The colon notation also has to be applied for the searching respectively.
|
||||
|
||||
This will search through all indexed fields:
|
||||
|
||||
@@ -1159,24 +1172,22 @@ This will search on a specific field):
|
||||
```js
|
||||
var results = index.search({
|
||||
field: "title",
|
||||
query: "title"
|
||||
query: "foobar"
|
||||
});
|
||||
```
|
||||
|
||||
The colon notation also has to be applied for the searching respectively, e.g.:
|
||||
|
||||
```js
|
||||
var results = index.search({
|
||||
field: "data:body",
|
||||
query: "body"
|
||||
field: "data:body:content",
|
||||
query: "foobar"
|
||||
});
|
||||
```
|
||||
|
||||
This could also be written as:
|
||||
|
||||
```js
|
||||
var results = index.search("body", {
|
||||
field: "data:body",
|
||||
var results = index.search("foobar", {
|
||||
field: "data:body:content",
|
||||
});
|
||||
```
|
||||
|
||||
@@ -1184,7 +1195,7 @@ Search the same query on multiple fields:
|
||||
|
||||
```js
|
||||
var results = index.search({
|
||||
query: "title",
|
||||
query: "foobar",
|
||||
field: ["title", "body"]
|
||||
});
|
||||
```
|
||||
@@ -1202,10 +1213,10 @@ Search different queries on multiple fields:
|
||||
```js
|
||||
var results = index.search([{
|
||||
field: "title",
|
||||
query: "title"
|
||||
query: "foo"
|
||||
},{
|
||||
field: "body",
|
||||
query: "body"
|
||||
query: "bar"
|
||||
}]);
|
||||
```
|
||||
|
||||
@@ -1214,15 +1225,206 @@ Boost scoring on specific fields:
|
||||
```js
|
||||
var results = index.search([{
|
||||
field: "title",
|
||||
query: "title",
|
||||
query: "foo",
|
||||
boost: 2
|
||||
},{
|
||||
field: "body",
|
||||
query: "body",
|
||||
query: "bar",
|
||||
boost: 0.5
|
||||
}]);
|
||||
```
|
||||
|
||||
<a name="where"></a>
|
||||
## Find / Where
|
||||
|
||||
When indexing documents, you are also able to get results by specific attributes.
|
||||
|
||||
> The colon notation also has to be applied for using "where" and "find" respectively.
|
||||
|
||||
#### Find a document by an attribute
|
||||
|
||||
```js
|
||||
index.find("cat", "comedy");
|
||||
```
|
||||
|
||||
Same as:
|
||||
```js
|
||||
index.find({"cat": "comedy"});
|
||||
```
|
||||
|
||||
To get by ID, you can also use short form:
|
||||
```js
|
||||
index.find(1);
|
||||
```
|
||||
|
||||
Find by a custom function:
|
||||
```js
|
||||
index.find(function(item){
|
||||
return item.cat === "comedy";
|
||||
});
|
||||
```
|
||||
|
||||
#### Find documents by multiple attributes
|
||||
|
||||
Get just the first result:
|
||||
```js
|
||||
index.find({
|
||||
cat: "comedy",
|
||||
year: "2018"
|
||||
});
|
||||
```
|
||||
|
||||
Get all matched results:
|
||||
```js
|
||||
index.where({
|
||||
cat: "comedy",
|
||||
year: "2018"
|
||||
});
|
||||
```
|
||||
|
||||
Get all results and set a limit:
|
||||
```js
|
||||
index.where({
|
||||
cat: "comedy",
|
||||
year: "2018"
|
||||
}, 100);
|
||||
```
|
||||
|
||||
Get all by a custom function:
|
||||
```js
|
||||
index.where(function(item){
|
||||
return item.cat === "comedy";
|
||||
});
|
||||
```
|
||||
|
||||
#### Combine fuzzy search with a where-clause:
|
||||
|
||||
Add some content, e.g.:
|
||||
```js
|
||||
index.add([{
|
||||
id: 0,
|
||||
title: "Foobar",
|
||||
cat: "adventure",
|
||||
content: "Body"
|
||||
},{
|
||||
id: 1,
|
||||
title: "Title",
|
||||
cat: "comedy",
|
||||
content: "Foobar"
|
||||
}]);
|
||||
```
|
||||
|
||||
Using search and also apply a where-clause:
|
||||
```js
|
||||
index.search("foo", {
|
||||
field: [
|
||||
"title",
|
||||
"body"
|
||||
],
|
||||
where: {
|
||||
"cat": "comedy"
|
||||
},
|
||||
limit: 10
|
||||
});
|
||||
```
|
||||
|
||||
<a name="tags"></a>
|
||||
## Tags
|
||||
|
||||
Tagging is pretty much the same like adding an index to a database column. Whenever you use ___where___ on an indexed/tagged attribute will improve performance drastically but also at a cost of additional memory.
|
||||
|
||||
> The colon notation also has to be applied for tags respectively.
|
||||
|
||||
Add one single tag to the index:
|
||||
```js
|
||||
var index = new FlexSearch({
|
||||
doc: {
|
||||
id: "id",
|
||||
field: ["title", "content"],
|
||||
tag: "cat"
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Or add multiple tags to the index:
|
||||
```js
|
||||
var index = new FlexSearch({
|
||||
doc: {
|
||||
id: "id",
|
||||
field: ["title", "content"],
|
||||
tag: ["cat", "year"]
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Add some content:
|
||||
```js
|
||||
index.add([{
|
||||
id: 0,
|
||||
title: "Foobar",
|
||||
cat: "adventure",
|
||||
year: "2018",
|
||||
content: "Body"
|
||||
},{
|
||||
id: 1,
|
||||
title: "Title",
|
||||
cat: "comedy",
|
||||
year: "2018",
|
||||
content: "Foobar"
|
||||
}]);
|
||||
```
|
||||
|
||||
Find all documents by an attribute:
|
||||
```js
|
||||
index.where({"cat": "comedy"}, 10);
|
||||
```
|
||||
|
||||
Since the attribute "cat" was tagged (has its own index) this expression performs extremely fast. This is actually the fastest way to retrieve results from documents.
|
||||
|
||||
Search documents and also apply a where-clause:
|
||||
```js
|
||||
index.search("foo", {
|
||||
field: [
|
||||
"title",
|
||||
"content"
|
||||
],
|
||||
where: {
|
||||
"cat": "comedy"
|
||||
},
|
||||
limit: 10
|
||||
});
|
||||
```
|
||||
|
||||
For a better understanding, using the same expression without the where clause has pretty much the same performance. On the other hand, using a where-clause without a tag on its property has an additional cost.
|
||||
|
||||
<a name="sort"></a>
|
||||
## Custom Sort
|
||||
|
||||
> The colon notation also has to be applied for a custom sort respectively.
|
||||
|
||||
Sort by an attribute:
|
||||
```js
|
||||
var results = index.search("John", {
|
||||
|
||||
limit: 100,
|
||||
sort: "data:title"
|
||||
});
|
||||
```
|
||||
|
||||
Sort by a custom function:
|
||||
```js
|
||||
var results = index.search("John", {
|
||||
|
||||
limit: 100,
|
||||
sort: function(a, b){
|
||||
return (
|
||||
a.id < b.id ? -1 : (
|
||||
a.id > b.id ? 1 : 0
|
||||
));
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
<a name="chaining"></a>
|
||||
### Chaining
|
||||
|
||||
@@ -1864,45 +2066,36 @@ var comedy = new FlexSearch();
|
||||
|
||||
This way you can also provide different settings for each category.
|
||||
|
||||
To make this workaround more extendable you can define a tiny helper:
|
||||
You can also gets the same effect when using documents in combination with tags and a ___where___ clause, e.g.:
|
||||
|
||||
```js
|
||||
var settings = {};
|
||||
var index = {};
|
||||
|
||||
function add(id, cat, content){
|
||||
(index[cat] || (
|
||||
index[cat] = new FlexSearch(settings[cat])
|
||||
)).add(id, content);
|
||||
}
|
||||
|
||||
function search(cat, query){
|
||||
return index[cat] ? index[cat].search(query) : [];
|
||||
}
|
||||
```
|
||||
|
||||
Provide settings optionally (or skip and use defaults):
|
||||
```js
|
||||
settings = {
|
||||
action: "score",
|
||||
adventure: "match",
|
||||
comedy: {
|
||||
encode: "advanced",
|
||||
tokenize: "forward",
|
||||
threshold: 5
|
||||
var movies = new FlexSearch({
|
||||
doc: {
|
||||
id: "id",
|
||||
title: "title"
|
||||
},
|
||||
tag:{
|
||||
cat: "cat",
|
||||
}
|
||||
};
|
||||
});
|
||||
```
|
||||
|
||||
Add content to the index:
|
||||
|
||||
```js
|
||||
add(1, "action", "Movie Title");
|
||||
add(2, "adventure", "Movie Title");
|
||||
add(3, "comedy", "Movie Title");
|
||||
add({ id: 1, cat: "action", title: "Movie Title" });
|
||||
add({ id: 2, cat: "adventure", title: "Movie Title" });
|
||||
add({ id: 3, cat: "comedy", title: "Movie Title" });
|
||||
```
|
||||
|
||||
Perform queries:
|
||||
```js
|
||||
var results = search("action", "movie title"); // --> [1]
|
||||
var results = search("movie title", {
|
||||
field: "title",
|
||||
where: {
|
||||
cat: "adventure"
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Filter queries by categories will hugely improve performance.
|
||||
|
@@ -14,7 +14,7 @@
|
||||
table{
|
||||
width: 300px;
|
||||
table-layout: fixed;
|
||||
position: sticky;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
padding-top: 10px;
|
||||
background-color: #fff;
|
||||
@@ -43,7 +43,7 @@
|
||||
}
|
||||
#suggestions{
|
||||
position: relative;
|
||||
top: 35px;
|
||||
top: 50px;
|
||||
}
|
||||
#suggestions div{
|
||||
padding: 10px 0;
|
||||
@@ -58,7 +58,7 @@
|
||||
td,
|
||||
tr,
|
||||
input{
|
||||
width: 100%;
|
||||
width: 97%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -83,15 +83,15 @@
|
||||
suggest: true
|
||||
});
|
||||
|
||||
var suggestions = document.getElementById("suggestions");
|
||||
var autocomplete = document.getElementById("autocomplete");
|
||||
var userinput = document.getElementById("userinput");
|
||||
|
||||
for(var i = 0; i < data.length; i++){
|
||||
|
||||
index.add(i, data[i]);
|
||||
}
|
||||
|
||||
var suggestions = document.getElementById("suggestions");
|
||||
var autocomplete = document.getElementById("autocomplete");
|
||||
var userinput = document.getElementById("userinput");
|
||||
|
||||
userinput.addEventListener("input", show_results, true);
|
||||
userinput.addEventListener("keyup", accept_autocomplete, true);
|
||||
suggestions.addEventListener("click", accept_suggestion, true);
|
||||
@@ -99,7 +99,7 @@
|
||||
function show_results(){
|
||||
|
||||
var value = this.value;
|
||||
var results = index.search(value, 20);
|
||||
var results = index.search(value, 25);
|
||||
var entry, childs = suggestions.childNodes;
|
||||
var i = 0, len = results.length;
|
||||
|
||||
@@ -131,8 +131,7 @@
|
||||
}
|
||||
else{
|
||||
|
||||
autocomplete.value = value;
|
||||
autocomplete.current = value;
|
||||
autocomplete.value = autocomplete.current = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +156,6 @@
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}());
|
||||
</script>
|
||||
</body>
|
||||
|
42
dist/flexsearch.compact.js
vendored
42
dist/flexsearch.compact.js
vendored
@@ -1,27 +1,27 @@
|
||||
/*
|
||||
FlexSearch v0.4.0
|
||||
FlexSearch v0.5.0
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(f,x,d){let p;(p=d.define)&&p.amd?p([],function(){return x}):(p=d.modules)?p[f.toLowerCase()]=x:"object"===typeof exports?module.exports=x:d[f]=x})("FlexSearch",function(){function f(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:M++;this.init(a,b);x(this,"index",function(){return this.c});x(this,"length",function(){return Object.keys(this.c).length})}function x(a,b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function p(a,b){for(let c=0;c<b.length;c+=
|
||||
2)a=a.replace(b[c],b[c+1]);return a}function A(a,b,c,h,g,l,e){if(b[c])return b[c];g=g?(9-(e||6))*l+(e||6)*g:l;b[c]=g;g>=e&&(a=a[9-(g+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=h);return g}function E(a,b){if(a){const c=Object.keys(a);for(let h=0,g=c.length;h<g;h++){const g=c[h],e=a[g];if(e)for(let c=0,h=e.length;c<h;c++)if(e[c]===b){1===h?delete a[g]:e.splice(c,1);break}else y(e[c])&&E(e[c],b)}}}function F(a){let b="",c="";var h="";for(let g=0;g<a.length;g++){const l=a[g];if(l!==c)if(g&&"h"===l){if(h="a"===
|
||||
h||"e"===h||"i"===h||"o"===h||"u"===h||"y"===h,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&h||" "===c)b+=l}else b+=l;h=g===a.length-1?"":a[g+1];c=l}return b}function N(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function O(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function P(a,b,c,h){let g=[],l;const e=a.length;if(1<e){a.sort(O);const n=v();let q=a[0],k=q.length,r=0;for(;r<k;)n["@"+q[r++]]=1;let m,f=0,t=0;for(;++t<e;){let w=!1;const p=t===e-1;l=[];q=a[t];k=q.length;for(r=0;r<k;){m=
|
||||
q[r++];var d="@"+m;if(n[d]){const a=n[d];if(a===t){if(p){if(g[f++]=c?c[d]:m,b&&f===b)return g}else n[d]=t+1;w=!0}else h&&(d=l[a]||(l[a]=[]),d[d.length]=m)}}if(!w&&!h)break}if(h&&(f=g.length,(t=l.length)&&(!b||f<b)))for(;t--;)if(m=l[t])for(r=0,k=m.length;r<k;r++)if(g[f++]=c?c["@"+m[r]]:m[r],b&&f===b)return g}else if(e)if(c)for(a=a[0],h=a.length,b&&b<h&&(h=b),g=Array(h),b=0;b<h;b++)g[b]=c["@"+a[b]];else g=a[0],b&&g.length>b&&(g=g.slice(0,b));return g}function B(a){return"string"===typeof a}function C(a){return"function"===
|
||||
typeof a}function y(a){return"object"===typeof a}function D(a){return"undefined"===typeof a}function H(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=v();return b}function v(){return Object.create(null)}const u={encode:"icase",b:"forward",o:!1,cache:!1,async:!1,s:!1,l:!1,threshold:0,depth:0,a:!1},I={memory:{encode:"extra",b:"strict",threshold:7},speed:{encode:"icase",b:"strict",threshold:7,depth:2},match:{encode:"extra",b:"full"},score:{encode:"extra",b:"strict",threshold:5,depth:4},balance:{encode:"balance",
|
||||
b:"strict",threshold:6,depth:3},fastest:{encode:"icase",b:"strict",threshold:9,depth:1}},G=[];let M=0;const J=d("\\W+"),K={},L={};f.create=function(a){return new f(a)};f.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&G.push(d(b),a[b]);return this};f.registerEncoder=function(a,b){z[a]=b.bind(z);return this};f.registerLanguage=function(a,b){K[a]=b.filter;L[a]=b.stemmer;return this};f.encode=function(a,b){return z[a](b)};f.prototype.init=function(a,b){this.m=[];if(b){var c=b.preset;
|
||||
a=b}else a||(a=u),c=a.preset;b={};B(a)?(b=I[a],a={}):c&&(b=I[c]);this.b=a.tokenize||b.b||this.b||u.b;this.l=a.rtl||this.l||u.l;this.async="undefined"===typeof Promise||D(c=a.async)?this.async||u.async:c;this.threshold=D(c=a.threshold)?b.threshold||this.threshold||u.threshold:c;this.depth=D(c=a.depth)?b.depth||this.depth||u.depth:c;this.h=(c=D(c=a.encode)?b.encode||u.encode:c)&&z[c]&&z[c].bind(z)||(C(c)?c:this.h||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=K[c]||c;b=this.h;var h=v();if(c)for(var g=
|
||||
0;g<c.length;g++){var l=b?b(c[g]):c[g];h[l]=String.fromCharCode(65E3-c.length+g)}this.filter=c=h}if(c=a.stemmer){var e;b=L[c]||c;h=this.h;g=[];if(b)for(e in b)b.hasOwnProperty(e)&&(l=h?h(e):e,g.push(d("(?=.{"+(l.length+3)+",})"+l+"$"),h?h(b[e]):b[e]));this.stemmer=e=g}this.a=e=(c=a.doc)?c:this.a||u.a;this.j=H(10-(this.threshold||0));this.g=v();this.c=v();this.f=e&&v();if(e)if(a.doc=null,c=e.field,b=e.index=[],h=e.ref={},e.id=e.id.split(":"),c.constructor===Array)for(e=0;e<c.length;e++)h[c[e]]=e,c[e]=
|
||||
c[e].split(":"),b[e]=new f(a),b[e].f=this.f;else h[c]=0,e.field=[c.split(":")],b[0]=new f(a),b[0].f=this.f;return this};f.prototype.encode=function(a){a&&G.length&&(a=p(a,G));a&&this.m.length&&(a=p(a,this.m));a&&this.h&&(a=this.h(a));a&&this.stemmer&&(a=p(a,this.stemmer));return a};f.prototype.addMatcher=function(a){const b=this.m;for(const c in a)a.hasOwnProperty(c)&&b.push(d(c),a[c]);return this};f.prototype.add=function(a,b,c,h,g){if(this.a&&y(a))return this.i("add",a,b);if(b&&B(b)&&(a||0===a)){var l=
|
||||
"@"+a;if(this.c[l]&&!h)return this.update(a,b);if(!g){if(this.async&&"function"!==typeof importScripts){let e=this;l=new Promise(function(c){setTimeout(function(){e.add(a,b,null,h,!0);e=null;c()})});if(c)l.then(c);else return l;return this}if(c)return this.add(a,b,null,h,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.b;g=C(c)?c(b):b.split(J);const q=v();q._ctx=v();const m=this.threshold,p=this.depth,t=this.j,w=g.length,u=this.l;for(let b=0;b<w;b++){var e=g[b];if(e){var d=e.length,n=
|
||||
(u?b+1:w-b)/w,f="";switch(c){case "reverse":case "both":for(var k=d;--k;)f=e[k]+f,A(t,q,f,a,u?1:(d-k)/d,n,m);f="";case "forward":for(k=0;k<d;k++)f+=e[k],A(t,q,f,a,u?(k+1)/d:1,n,m);break;case "full":for(k=0;k<d;k++){const b=(u?k+1:d-k)/d;for(let c=d;c>k;c--)f=e.substring(k,c),A(t,q,f,a,b,n,m)}break;default:if(d=A(t,q,e,a,1,n,m),p&&1<w&&d>=m)for(d=q._ctx[e]||(q._ctx[e]=v()),e=this.g[e]||(this.g[e]=H(10-(m||0))),n=b-p,f=b+p+1,0>n&&(n=0),f>w&&(f=w);n<f;n++)n!==b&&A(e,d,g[n],a,0,10-(n<b?b-n:n-b),m)}}}this.c[l]=
|
||||
1}return this};f.prototype.i=function(a,b,c){if(b.constructor===Array)for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.i(a,b[d],c);this.i(a,b[d])}else{const h=this.a.index;let e=this.a.id,f;for(var d=0;d<e.length;d++)f=(f||b)[e[d]];if("remove"===a){delete this.f["@"+f];for(let a=0,b=h.length;a<b;a++){if(a===b-1)return h[a].remove(f,c);h[a].remove(f)}}e=this.a.field;for(let l=0,q=e.length;l<q;l++){d=e[l];let k;for(var g=0;g<d.length;g++)k=(k||b)[d[g]];this.f["@"+f]=b;d=h[l];g="add"===a?d.add:
|
||||
d.update;if(l===q-1)return g.call(d,f,k,c);g.call(d,f,k)}}};f.prototype.update=function(a,b,c){if(this.a&&y(a))return this.i("update",a,b);this.c["@"+a]&&B(b)&&(this.remove(a),this.add(a,b,c,!0));return this};f.prototype.remove=function(a,b,c){if(this.a&&y(a))return this.i("remove",a,b);var d="@"+a;if(this.c[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,
|
||||
null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)E(this.j[b],a);this.depth&&E(this.g,a);delete this.c[d]}return this};f.prototype.search=function(a,b,c,d){if(y(b)){if(b.constructor===Array)for(var g=0;g<b.length;g++)b[g].query=a;else b.query=a;a=b;b=0}let f=a;let e=[];if(y(a)&&a.constructor!==Array){(c=a.callback||b)&&(f.callback=null);b=a.limit;var h=a.threshold;var n=a.boost;a=a.query}if(this.a){h=this.a.ref;var p=this.a.index,k=f.field;if(k)f.field=null;else if(f.constructor===Array){var r=
|
||||
f;k=[];for(var m=0;m<f.length;m++)k[m]=f[m].field}else k=Object.keys(h);if(y(k)){k.constructor===Array||(k=[k]);m=k.length;for(a=0;a<m;a++)r&&(f=r[a]),e[a]=p[h[k[a]]].search(f);return c?c(e.concat.apply([],e)):this.async?new Promise(function(a){Promise.all(e).then(function(b){a(b.concat.apply([],b))})}):e.concat.apply([],e)}return p[h[k]].search(f,c)}h||(h=this.threshold||0);C(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!d){if(this.async&&"function"!==typeof importScripts){let a=this;h=new Promise(function(c){setTimeout(function(){c(a.search(f,
|
||||
b,null,!0));a=null})});if(c)h.then(c);else return h;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!B(a))return e;f=a;f=this.encode(f);if(!f.length)return e;c=this.b;c=C(c)?c(f):f.split(J);r=c.length;a=!0;d=[];g=v();1<r&&(this.depth?(p=!0,m=c[0],g[m]=1):c.sort(N));if(!p||(k=this.g)[m]){let b=0;n&&(h=(h||1)/n,0>n&&(b=h));for(n=p?1:0;n<r;n++){const e=c[n];if(e){if(!g[e]){const c=[];let f=!1,l=0;if(m=p?k[m]:this.j){let a;for(let d=b;d<10-h;d++)if(a=m[d][e])c[l++]=a,f=!0}if(f)d[d.length]=
|
||||
1<l?c.concat.apply([],c):c[0];else{a=!1;break}g[e]=1}m=e}}}else a=!1;a&&(e=P(d,b,this.f,!1));return e};f.prototype.clear=function(){return this.destroy().init()};f.prototype.destroy=function(){this.j=this.g=this.c=null;return this};const z={icase:function(a){return a.toLowerCase()},simple:function(){const a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),
|
||||
"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){b=p(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);
|
||||
2<b.length&&(b=p(b,a));c||1<b.length&&(b=F(b));return b}}(),extra:function(){const a=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+p(d.substring(1),a))}b=b.join(" ");b=F(b)}return b}}(),balance:function(){const a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){return F(p(b.toLowerCase(),
|
||||
a))}}()};return f}(!1),this);
|
||||
'use strict';(function(g,t,A){let d;(d=A.define)&&d.amd?d([],function(){return t}):(d=A.modules)?d[g.toLowerCase()]=t:"object"===typeof exports?module.exports=t:A[g]=t})("FlexSearch",function(){function g(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:P++;this.init(a,b);A(this,"index",function(){return this.c});A(this,"length",function(){return Object.keys(this.c).length})}function t(a,b){a=a.concat.apply([],a);b&&(D(b)||(w=b.split(":"),1<w.length?b=Q:(w=w[0],b=R)),a.sort(b));return a}function A(a,
|
||||
b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function y(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function E(a,b,c,e,h,k,f){if(b[c])return b[c];h=h?(9-(f||6))*k+(f||6)*h:k;b[c]=h;h>=f&&(a=a[9-(h+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=e);return h}function H(a,b){if(a){const c=Object.keys(a);for(let e=0,h=c.length;e<h;e++){const h=c[e],f=a[h];if(f)for(let c=0,e=f.length;c<e;c++)if(f[c]===b){1===e?delete a[h]:f.splice(c,1);break}else z(f[c])&&
|
||||
H(f[c],b)}}}function I(a){let b="",c="";var e="";for(let h=0;h<a.length;h++){const k=a[h];if(k!==c)if(h&&"h"===k){if(e="a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&e||" "===c)b+=k}else b+=k;e=h===a.length-1?"":a[h+1];c=k}return b}function S(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function T(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function R(a,b){a=a[w];b=b[w];return a<b?-1:a>b?1:0}function Q(a,b){const c=w.length;for(let e=
|
||||
0;e<c;e++)a=a[w[e]],b=b[w[e]];return a<b?-1:a>b?1:0}function U(a,b,c,e){let h=[],k;const f=a.length;if(1<f){a.sort(T);const m=v();let l=a[0],n=l.length,p=0;for(;p<n;)m["@"+l[p++]]=1;let r,q=0,g=0;for(;++g<f;){let u=!1;const V=g===f-1;k=[];l=a[g];n=l.length;for(p=0;p<n;){r=l[p++];var d="@"+r;if(m[d]){const a=m[d];if(a===g){if(V){if(h[q++]=c?c[d]:r,b&&q===b)return h}else m[d]=g+1;u=!0}else e&&(d=k[a]||(k[a]=[]),d[d.length]=r)}}if(!u&&!e)break}if(e&&(q=h.length,(g=k.length)&&(!b||q<b)))for(;g--;)if(r=
|
||||
k[g])for(p=0,n=r.length;p<n;p++)if(h[q++]=c?c["@"+r[p]]:r[p],b&&q===b)return h}else if(f)if(c)for(a=a[0],e=a.length,b&&b<e&&(e=b),h=Array(e),b=0;b<e;b++)h[b]=c["@"+a[b]];else h=a[0],b&&h.length>b&&(h=h.slice(0,b));return h}function F(a){return"string"===typeof a}function D(a){return"function"===typeof a}function z(a){return"object"===typeof a}function G(a){return"undefined"===typeof a}function K(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=v();return b}function v(){return Object.create(null)}const x=
|
||||
{encode:"icase",b:"forward",o:!1,cache:!1,async:!1,s:!1,l:!1,threshold:0,depth:0,a:!1},L={memory:{encode:"extra",b:"strict",threshold:7},speed:{encode:"icase",b:"strict",threshold:7,depth:2},match:{encode:"extra",b:"full"},score:{encode:"extra",b:"strict",threshold:5,depth:4},balance:{encode:"balance",b:"strict",threshold:6,depth:3},fastest:{encode:"icase",b:"strict",threshold:9,depth:1}},J=[];let P=0;const M=d("\\W+"),N={},O={};g.create=function(a){return new g(a)};g.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&
|
||||
J.push(d(b),a[b]);return this};g.registerEncoder=function(a,b){C[a]=b.bind(C);return this};g.registerLanguage=function(a,b){N[a]=b.filter;O[a]=b.stemmer;return this};g.encode=function(a,b){return C[a](b)};g.prototype.init=function(a,b){this.m=[];if(b){var c=b.preset;a=b}else a||(a=x),c=a.preset;b={};F(a)?(b=L[a],a={}):c&&(b=L[c]);this.b=a.tokenize||b.b||this.b||x.b;this.l=a.rtl||this.l||x.l;this.async="undefined"===typeof Promise||G(c=a.async)?this.async||x.async:c;this.threshold=G(c=a.threshold)?
|
||||
b.threshold||this.threshold||x.threshold:c;this.depth=G(c=a.depth)?b.depth||this.depth||x.depth:c;this.h=(c=G(c=a.encode)?b.encode||x.encode:c)&&C[c]&&C[c].bind(C)||(D(c)?c:this.h||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=N[c]||c;b=this.h;var e=v();if(c)for(var h=0;h<c.length;h++){var k=b?b(c[h]):c[h];e[k]=String.fromCharCode(65E3-c.length+h)}this.filter=c=e}if(c=a.stemmer){var f;b=O[c]||c;e=this.h;h=[];if(b)for(f in b)b.hasOwnProperty(f)&&(k=e?e(f):f,h.push(d("(?=.{"+(k.length+3)+",})"+
|
||||
k+"$"),e?e(b[f]):b[f]));this.stemmer=f=h}this.a=f=(c=a.doc)?c:this.a||x.a;this.j=K(10-(this.threshold||0));this.g=v();this.c=v();if(f&&(this.f=v(),a.doc=null,c=f.index=[],b=f.ref={},e=f.field,f.id=f.id.split(":"),e))for(e.constructor===Array||(f.field=e=[e]),f=0;f<e.length;f++)b[e[f]]=f,e[f]=e[f].split(":"),c[f]=new g(a),c[f].f=this.f;return this};g.prototype.encode=function(a){a&&J.length&&(a=y(a,J));a&&this.m.length&&(a=y(a,this.m));a&&this.h&&(a=this.h(a));a&&this.stemmer&&(a=y(a,this.stemmer));
|
||||
return a};g.prototype.addMatcher=function(a){const b=this.m;for(const c in a)a.hasOwnProperty(c)&&b.push(d(c),a[c]);return this};g.prototype.add=function(a,b,c,e,h){if(this.a&&z(a))return this.i("add",a,b);if(b&&F(b)&&(a||0===a)){var d="@"+a;if(this.c[d]&&!e)return this.update(a,b);if(!h){if(this.async&&"function"!==typeof importScripts){let f=this;d=new Promise(function(c){setTimeout(function(){f.add(a,b,null,e,!0);f=null;c()})});if(c)d.then(c);else return d;return this}if(c)return this.add(a,b,
|
||||
null,e,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.b;h=D(c)?c(b):b.split(M);const k=v();k._ctx=v();const r=this.threshold,q=this.depth,u=this.j,B=h.length,t=this.l;for(let b=0;b<B;b++){var f=h[b];if(f){var n=f.length,m=(t?b+1:B-b)/B,l="";switch(c){case "reverse":case "both":for(var g=n;--g;)l=f[g]+l,E(u,k,l,a,t?1:(n-g)/n,m,r);l="";case "forward":for(g=0;g<n;g++)l+=f[g],E(u,k,l,a,t?(g+1)/n:1,m,r);break;case "full":for(g=0;g<n;g++){const b=(t?g+1:n-g)/n;for(let c=n;c>g;c--)l=f.substring(g,
|
||||
c),E(u,k,l,a,b,m,r)}break;default:if(n=E(u,k,f,a,1,m,r),q&&1<B&&n>=r)for(n=k._ctx[f]||(k._ctx[f]=v()),f=this.g[f]||(this.g[f]=K(10-(r||0))),m=b-q,l=b+q+1,0>m&&(m=0),l>B&&(l=B);m<l;m++)m!==b&&E(f,n,h[m],a,0,10-(m<b?b-m:m-b),r)}}}this.c[d]=1}return this};g.prototype.i=function(a,b,c){if(b.constructor===Array)for(let e=0,d=b.length;e<d;e++){if(e===d-1)return this.i(a,b[e],c);this.i(a,b[e])}else{const f=this.a.index;var e=this.a.tag,h=this.a.id;let k;for(var d=0;d<h.length;d++)k=(k||b)[h[d]];if(e)for(h=
|
||||
0;h<e.length;h++);if("remove"===a){delete this.f["@"+k];for(let a=0,b=f.length;a<b;a++){if(a===b-1)return f[a].remove(k,c);f[a].remove(k)}}h=this.a.field;for(let g=0,l=h.length;g<l;g++){e=h[g];let n;for(d=0;d<e.length;d++)n=(n||b)[e[d]];this.f["@"+k]=b;e=f[g];d="add"===a?e.add:e.update;if(g===l-1)return d.call(e,k,n,c);d.call(e,k,n)}}};g.prototype.update=function(a,b,c){if(this.a&&z(a))return this.i("update",a,b);this.c["@"+a]&&F(b)&&(this.remove(a),this.add(a,b,c,!0));return this};g.prototype.remove=
|
||||
function(a,b,c){if(this.a&&z(a))return this.i("remove",a,b);var e="@"+a;if(this.c[e]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;e=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)e.then(b);else return e;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)H(this.j[b],a);this.depth&&H(this.g,a);delete this.c[e]}return this};let w;g.prototype.search=function(a,b,c,e){if(z(b)){if(b.constructor===Array)for(var d=
|
||||
0;d<b.length;d++)b[d].query=a;else b.query=a;a=b;b=0}let k=a;let f,g=[];if(z(a)&&a.constructor!==Array){(c=a.callback||b)&&(k.callback=null);var m=a.boost;f=a.sort;b=a.limit;var l=a.threshold;a=a.query}if(this.a){l=this.a.ref;var u=this.a.index,p=k.field;if(p)k.field=null;else if(k.constructor===Array){var r=k;p=[];for(var q=0;q<k.length;q++)p[q]=k[q].field}else p=Object.keys(l);if(z(p)){p.constructor===Array||(p=[p]);q=p.length;for(a=0;a<q;a++)r&&(k=r[a]),g[a]=u[l[p[a]]].search(k);return c?c(t(g,
|
||||
f)):this.async?new Promise(function(a){Promise.all(g).then(function(b){a(t(b,f))})}):t(g,f)}return u[l[p]].search(k,c)}l||(l=this.threshold||0);D(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!e){if(this.async&&"function"!==typeof importScripts){let a=this;l=new Promise(function(c){setTimeout(function(){c(a.search(k,b,null,!0));a=null})});if(c)l.then(c);else return l;return this}if(c)return c(this.search(k,b,null,!0)),this}if(!a||!F(a))return g;k=a;k=this.encode(k);if(!k.length)return g;c=this.b;c=D(c)?c(k):
|
||||
k.split(M);r=c.length;a=!0;e=[];d=v();1<r&&(this.depth?(u=!0,q=c[0],d[q]=1):c.sort(S));if(!u||(p=this.g)[q]){let b=0;m&&(l=(l||1)/m,0>m&&(b=l));for(m=u?1:0;m<r;m++){const f=c[m];if(f){if(!d[f]){const c=[];let g=!1,h=0;if(q=u?p[q]:this.j){let a;for(let d=b;d<10-l;d++)if(a=q[d][f])c[h++]=a,g=!0}if(g)e[e.length]=1<h?c.concat.apply([],c):c[0];else{a=!1;break}d[f]=1}q=f}}}else a=!1;a&&(g=U(e,b,this.f,!1));f&&(g=t([g],f));return g};g.prototype.clear=function(){return this.destroy().init()};g.prototype.destroy=
|
||||
function(){this.j=this.g=this.c=null;if(this.a){const a=this.f.index;for(let b=0;b<a.length;b++)a.destroy();this.f=null}return this};const C={icase:function(a){return a.toLowerCase()},simple:function(){const a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & "),
|
||||
" and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){b=y(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=y(b,a));c||1<b.length&&(b=I(b));return b}}(),extra:function(){const a=[d("p"),
|
||||
"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+y(d.substring(1),a))}b=b.join(" ");b=I(b)}return b}}(),balance:function(){const a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){return I(y(b.toLowerCase(),a))}}()};return g}(!1),this);
|
||||
|
73
dist/flexsearch.es5.js
vendored
73
dist/flexsearch.es5.js
vendored
@@ -1,41 +1,44 @@
|
||||
/*
|
||||
FlexSearch v0.4.0
|
||||
FlexSearch v0.5.0
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';function L(g){var l=0;return function(){return l<g.length?{done:!1,value:g[l++]}:{done:!0}}}function M(g){var l="undefined"!=typeof Symbol&&Symbol.iterator&&g[Symbol.iterator];return l?l.call(g):{next:L(g)}}var S="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,T="function"==typeof Object.defineProperties?Object.defineProperty:function(g,l,d){g!=Array.prototype&&g!=Object.prototype&&(g[l]=d.value)};
|
||||
function U(g,l){if(l){var d=S;g=g.split(".");for(var m=0;m<g.length-1;m++){var k=g[m];k in d||(d[k]={});d=d[k]}g=g[g.length-1];m=d[g];l=l(m);l!=m&&null!=l&&T(d,g,{configurable:!0,writable:!0,value:l})}}
|
||||
U("Promise",function(g){function l(e){this.f=0;this.o=void 0;this.a=[];var d=this.i();try{e(d.resolve,d.reject)}catch(C){d.reject(C)}}function d(){this.a=null}function m(e){return e instanceof l?e:new l(function(d){d(e)})}if(g)return g;d.prototype.f=function(e){if(null==this.a){this.a=[];var d=this;this.i(function(){d.o()})}this.a.push(e)};var k=S.setTimeout;d.prototype.i=function(e){k(e,0)};d.prototype.o=function(){for(;this.a&&this.a.length;){var e=this.a;this.a=[];for(var d=0;d<e.length;++d){var f=
|
||||
e[d];e[d]=null;try{f()}catch(G){this.l(G)}}}this.a=null};d.prototype.l=function(e){this.i(function(){throw e;})};l.prototype.i=function(){function e(e){return function(l){f||(f=!0,e.call(d,l))}}var d=this,f=!1;return{resolve:e(this.L),reject:e(this.l)}};l.prototype.L=function(e){if(e===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(e instanceof l)this.M(e);else{a:switch(typeof e){case "object":var d=null!=e;break a;case "function":d=!0;break a;default:d=!1}d?this.K(e):this.v(e)}};
|
||||
l.prototype.K=function(e){var d=void 0;try{d=e.then}catch(C){this.l(C);return}"function"==typeof d?this.N(d,e):this.v(e)};l.prototype.l=function(d){this.I(2,d)};l.prototype.v=function(d){this.I(1,d)};l.prototype.I=function(d,f){if(0!=this.f)throw Error("Cannot settle("+d+", "+f+"): Promise already settled in state"+this.f);this.f=d;this.o=f;this.J()};l.prototype.J=function(){if(null!=this.a){for(var d=0;d<this.a.length;++d)f.f(this.a[d]);this.a=null}};var f=new d;l.prototype.M=function(d){var e=this.i();
|
||||
d.D(e.resolve,e.reject)};l.prototype.N=function(d,f){var e=this.i();try{d.call(f,e.resolve,e.reject)}catch(G){e.reject(G)}};l.prototype.then=function(d,f){function e(d,e){return"function"==typeof d?function(e){try{g(d(e))}catch(E){m(E)}}:e}var g,m,D=new l(function(d,e){g=d;m=e});this.D(e(d,g),e(f,m));return D};l.prototype.catch=function(d){return this.then(void 0,d)};l.prototype.D=function(d,l){function e(){switch(g.f){case 1:d(g.o);break;case 2:l(g.o);break;default:throw Error("Unexpected state: "+
|
||||
g.f);}}var g=this;null==this.a?f.f(e):this.a.push(e)};l.resolve=m;l.reject=function(d){return new l(function(e,f){f(d)})};l.race=function(d){return new l(function(e,f){for(var l=M(d),g=l.next();!g.done;g=l.next())m(g.value).D(e,f)})};l.all=function(d){var e=M(d),f=e.next();return f.done?m([]):new l(function(d,l){function g(e){return function(f){k[e]=f;F--;0==F&&d(k)}}var k=[],F=0;do k.push(void 0),F++,m(f.value).D(g(k.length-1),l),f=e.next();while(!f.done)})};return l});
|
||||
(function(g,l,d){var m;(m=d.define)&&m.amd?m([],function(){return l}):(m=d.modules)?m[g.toLowerCase()]=l:"object"===typeof exports?module.exports=l:d[g]=l})("FlexSearch",function Y(g){function d(a,b){var c=b?b.id:a&&a.id;this.id=c||0===c?c:Z++;this.init(a,b);k(this,"index",function(){return this.b});k(this,"length",function(){return Object.keys(this.b).length})}function m(a,b,c,d){this.B!==this.h&&(this.u=this.u.concat(c),this.B++,d&&this.u.length>=d&&(this.B=this.h),this.G&&this.B===this.h&&(this.cache&&
|
||||
this.w.set(b,this.u),this.G(this.u),this.u=[]));return this}function k(a,b,c){Object.defineProperty(a,b,{get:c})}function f(a){return new RegExp(a,"g")}function e(a,b){for(var c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function D(a,b,c,d,h,u,e){if(b[c])return b[c];h=h?(9-(e||6))*u+(e||6)*h:u;b[c]=h;h>=e&&(a=a[9-(h+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return h}function C(a,b){if(a)for(var c=Object.keys(a),d=0,h=c.length;d<h;d++){var u=c[d],e=a[u];if(e)for(var f=0,g=e.length;f<g;f++)if(e[f]===
|
||||
b){1===g?delete a[u]:e.splice(f,1);break}else E(e[f])&&C(e[f],b)}}function G(a){for(var b="",c="",d="",h=0;h<a.length;h++){var u=a[h];if(u!==c)if(h&&"h"===u){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=u}else b+=u;d=h===a.length-1?"":a[h+1];c=u}return b}function V(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function X(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function W(a,b,c,d){var h=[],u=a.length;if(1<u){a.sort(X);
|
||||
for(var e=B(),f=a[0],r=f.length,g=0;g<r;)e["@"+f[g++]]=1;for(var p,m=0,q=0;++q<u;){var k=!1,x=q===u-1;var v=[];f=a[q];r=f.length;for(g=0;g<r;){p=f[g++];var n="@"+p;if(e[n]){var w=e[n];if(w===q){if(x){if(h[m++]=c?c[n]:p,b&&m===b)return h}else e[n]=q+1;k=!0}else d&&(n=v[w]||(v[w]=[]),n[n.length]=p)}}if(!k&&!d)break}if(d&&(m=h.length,(q=v.length)&&(!b||m<b)))for(;q--;)if(p=v[q])for(g=0,r=p.length;g<r;g++)if(h[m++]=c?c["@"+p[g]]:p[g],b&&m===b)return h}else if(u)if(c)for(a=a[0],d=a.length,b&&b<d&&(d=b),
|
||||
h=Array(d),b=0;b<d;b++)h[b]=c["@"+a[b]];else h=a[0],b&&h.length>b&&(h=h.slice(0,b));return h}function F(a){return"string"===typeof a}function I(a){return"function"===typeof a}function E(a){return"object"===typeof a}function z(a){return"undefined"===typeof a}function N(a){for(var b=Array(a),c=0;c<a;c++)b[c]=B();return b}function B(){return Object.create(null)}function aa(){var a,b;self.onmessage=function(c){if(c=c.data)if(c.search){var d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:
|
||||
c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ba(a,b,c,d){a=g("flexsearch","id"+a,aa,function(a){(a=a.data)&&a.result&&
|
||||
d(a.id,a.content,a.result,a.limit)},b);var h=Y.toString();c.id=b;a.postMessage({register:h,options:c,id:b});return a}var t={encode:"icase",g:"forward",C:!1,cache:!1,async:!1,h:!1,F:!1,threshold:0,depth:0,c:!1},O={memory:{encode:"extra",g:"strict",threshold:7},speed:{encode:"icase",g:"strict",threshold:7,depth:2},match:{encode:"extra",g:"full"},score:{encode:"extra",g:"strict",threshold:5,depth:4},balance:{encode:"balance",g:"strict",threshold:6,depth:3},fastest:{encode:"icase",g:"strict",threshold:9,
|
||||
depth:1}},K=[],Z=0,P=f("\\W+"),Q={},R={};d.create=function(a){return new d(a)};d.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&K.push(f(b),a[b]);return this};d.registerEncoder=function(a,b){H[a]=b.bind(H);return this};d.registerLanguage=function(a,b){Q[a]=b.filter;R[a]=b.stemmer;return this};d.encode=function(a,b){return H[a](b)};d.prototype.init=function(a,b){this.f=[];if(b){var c=b.preset;a=b}else a||(a=t),c=a.preset;b={};F(a)?((b=O[a])||console.warn("Preset not found: "+a),a=
|
||||
{}):c&&((b=O[c])||console.warn("Preset not found: "+c));if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.a=null;else{var e=parseInt(c,10)||4;this.v=-1;this.B=0;this.u=[];this.G=null;this.a=Array(e);for(var h=0;h<e;h++)this.a[h]=ba(this.id,h,a,m.bind(this))}this.g=a.tokenize||b.g||this.g||t.g;this.F=a.rtl||this.F||t.F;this.async="undefined"===typeof Promise||z(c=a.async)?this.async||t.async:c;this.h=z(c=a.worker)?this.h||t.h:c;this.threshold=z(c=a.threshold)?b.threshold||this.threshold||
|
||||
t.threshold:c;this.depth=z(c=a.depth)?b.depth||this.depth||t.depth:c;this.C=z(c=a.suggest)?this.C||t.C:c;this.i=(c=z(c=a.encode)?b.encode||t.encode:c)&&H[c]&&H[c].bind(H)||(I(c)?c:this.i||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=Q[c]||c;b=this.i;e=B();if(c)for(h=0;h<c.length;h++){var u=b?b(c[h]):c[h];e[u]=String.fromCharCode(65E3-c.length+h)}this.filter=e}if(c=a.stemmer){b=R[c]||c;e=this.i;h=[];if(b)for(var g in b)b.hasOwnProperty(g)&&(u=e?e(g):g,h.push(f("(?=.{"+(u.length+3)+",})"+
|
||||
u+"$"),e?e(b[g]):b[g]));this.stemmer=h}this.c=h=(c=a.doc)?c:this.c||t.c;this.m=N(10-(this.threshold||0));this.s=B();this.b=B();this.j=h&&B();if(h)if(a.doc=null,g=h.field,b=h.index=[],e=h.ref={},h.id=h.id.split(":"),g.constructor===Array)for(h=0;h<g.length;h++)e[g[h]]=h,g[h]=g[h].split(":"),b[h]=new d(a),b[h].j=this.j;else e[g]=0,h.field=[g.split(":")],b[0]=new d(a),b[0].j=this.j;this.o=!0;this.w=(this.cache=c=z(c=a.cache)?this.cache||t.cache:c)?new ca(c):!1;return this};d.prototype.encode=function(a){a&&
|
||||
K.length&&(a=e(a,K));a&&this.f.length&&(a=e(a,this.f));a&&this.i&&(a=this.i(a));a&&this.stemmer&&(a=e(a,this.stemmer));return a};d.prototype.addMatcher=function(a){var b=this.f,c;for(c in a)a.hasOwnProperty(c)&&b.push(f(c),a[c]);return this};d.prototype.add=function(a,b,c,d,h){if(this.c&&E(a))return this.l("add",a,b);if(b&&F(b)&&(a||0===a)){var e="@"+a;if(this.b[e]&&!d)return this.update(a,b);if(this.h)return++this.v>=this.a.length&&(this.v=0),this.a[this.v].postMessage({add:!0,id:a,content:b}),this.b[e]=
|
||||
""+this.v,c&&c(),this;if(!h){if(this.async&&"function"!==typeof importScripts){var f=this;e=new Promise(function(c){setTimeout(function(){f.add(a,b,null,d,!0);f=null;c()})});if(c)e.then(c);else return e;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.g;h=I(c)?c(b):b.split(P);var g=B();g._ctx=B();for(var r=this.threshold,m=this.depth,p=this.m,k=h.length,q=this.F,A=0;A<k;A++){var x=h[A];if(x){var v=x.length,n=(q?A+1:k-A)/k,w="";switch(c){case "reverse":case "both":for(var y=
|
||||
v;--y;)w=x[y]+w,D(p,g,w,a,q?1:(v-y)/v,n,r);w="";case "forward":for(y=0;y<v;y++)w+=x[y],D(p,g,w,a,q?(y+1)/v:1,n,r);break;case "full":for(y=0;y<v;y++)for(var t=(q?y+1:v-y)/v,z=v;z>y;z--)w=x.substring(y,z),D(p,g,w,a,t,n,r);break;default:if(v=D(p,g,x,a,1,n,r),m&&1<k&&v>=r)for(v=g._ctx[x]||(g._ctx[x]=B()),x=this.s[x]||(this.s[x]=N(10-(r||0))),n=A-m,w=A+m+1,0>n&&(n=0),w>k&&(w=k);n<w;n++)n!==A&&D(x,v,h[n],a,0,10-(n<A?A-n:n-A),r)}}}this.b[e]=1;this.o=!1}return this};d.prototype.l=function(a,b,c){if(b.constructor===
|
||||
Array)for(var d=0,e=b.length;d<e;d++){if(d===e-1)return this.l(a,b[d],c);this.l(a,b[d])}else{d=this.c.index;for(var f=this.c.id,g=0;g<f.length;g++)e=(e||b)[f[g]];if("remove"===a)for(delete this.j["@"+e],f=0,g=d.length;f<g;f++){if(f===g-1)return d[f].remove(e,c);d[f].remove(e)}f=this.c.field;g=0;for(var m=f.length;g<m;g++){for(var k=f[g],J=void 0,p=0;p<k.length;p++)J=(J||b)[k[p]];this.j["@"+e]=b;k=d[g];p="add"===a?k.add:k.update;if(g===m-1)return p.call(k,e,J,c);p.call(k,e,J)}}};d.prototype.update=
|
||||
function(a,b,c){if(this.c&&E(a))return this.l("update",a,b);this.b["@"+a]&&F(b)&&(this.remove(a),this.add(a,b,c,!0));return this};d.prototype.remove=function(a,b,c){if(this.c&&E(a))return this.l("remove",a,b);var d="@"+a;if(this.b[d]){if(this.h)return this.a[this.b[d]].postMessage({remove:!0,id:a}),delete this.b[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){var e=this;d=new Promise(function(b){setTimeout(function(){e.remove(a,null,!0);e=null;b()})});if(b)d.then(b);else return d;
|
||||
return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)C(this.m[b],a);this.depth&&C(this.s,a);delete this.b[d];this.o=!1}return this};d.prototype.search=function(a,b,c,d){if(E(b)){if(b.constructor===Array)for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}var f=a,g=[];if(E(a)&&a.constructor!==Array){(c=a.callback||b)&&(f.callback=null);b=a.limit;var r=a.threshold;var m=a.boost;a=a.query}if(this.c){a=this.c.ref;r=this.c.index;var k=f.field;if(k)f.field=
|
||||
null;else if(f.constructor===Array){var p=f;k=[];for(var t=0;t<f.length;t++)k[t]=f[t].field}else k=Object.keys(a);if(E(k)){k.constructor===Array||(k=[k]);t=k.length;for(var q=0;q<t;q++)p&&(f=p[q]),g[q]=r[a[k[q]]].search(f);return c?c(g.concat.apply([],g)):this.async?new Promise(function(a){Promise.all(g).then(function(b){a(b.concat.apply([],b))})}):g.concat.apply([],g)}return r[a[k]].search(f,c)}r||(r=this.threshold||0);I(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.h)for(this.G=c,this.B=0,this.u=[],
|
||||
k=0;k<this.h;k++)this.a[k].postMessage({search:!0,limit:b,threshold:r,content:a});else{if(!d){if(this.async&&"function"!==typeof importScripts){var A=this;a=new Promise(function(a){setTimeout(function(){a(A.search(f,b,null,!0));A=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!F(a))return g;f=a;if(this.cache)if(this.o){if(c=this.w.get(a))return c}else this.w.clear(),this.o=!0;f=this.encode(f);if(!f.length)return g;c=this.g;c=I(c)?c(f):f.split(P);
|
||||
p=c.length;d=!0;e=[];var x=B();1<p&&(this.depth?(k=!0,q=c[0],x[q]=1):c.sort(V));if(!k||(t=this.s)[q]){var v=0;m&&(r=(r||1)/m,0>m&&(v=r));for(m=k?1:0;m<p;m++){var n=c[m];if(n){if(!x[n]){var w=[],y=!1,z=0;if(q=k?t[q]:this.m)for(var D=void 0,C=v;C<10-r;C++)if(D=q[C][n])w[z++]=D,y=!0;if(y)e[e.length]=1<z?w.concat.apply([],w):w[0];else if(!this.C){d=!1;break}x[n]=1}q=n}}}else d=!1;d&&(g=W(e,b,this.j,this.C));this.cache&&this.w.set(a,g);return g}};d.prototype.info=function(){if(this.h)for(var a=0;a<this.h;a++)this.a[a].postMessage({info:!0,
|
||||
id:this.id});else{for(var b,c=0,d=0,e=0,f=0;f<10-(this.threshold||0);f++){a=Object.keys(this.m[f]);for(var g=0;g<a.length;g++)b=this.m[f][a[g]].length,c+=1*b+2*a[g].length+4,d+=b,e+=2*a[g].length}a=Object.keys(this.b);b=a.length;for(f=0;f<b;f++)c+=2*a[f].length+2;return{id:this.id,memory:c,items:b,sequences:d,chars:e,cache:this.cache&&this.cache.A?this.cache.A.length:!1,matcher:K.length+(this.f?this.f.length:0),worker:this.h,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===
|
||||
this.g}}};d.prototype.clear=function(){return this.destroy().init()};d.prototype.destroy=function(){this.cache&&(this.w.clear(),this.w=null);this.m=this.s=this.b=null;return this};d.prototype.export=function(){if(this.c){for(var a=this.c.index,b=Array(a.length+1),c=0;c<a.length;c++)b[c]=[a[c].m,a[c].s,a[c].b];b[c]=this.j;return JSON.stringify(b)}return JSON.stringify([this.m,this.s,this.b])};d.prototype.import=function(a){a=JSON.parse(a);if(this.c){for(var b=this.c.index,c=b.length,d=0;d<c;d++){var e=
|
||||
b[d];e.m=a[d][0];e.s=a[d][1];e.b=a[d][2];e.j=a[c]}this.j=a[c]}else this.m=a[0],this.s=a[1],this.b=a[2],this.j=a[3]};var H={icase:function(a){return a.toLowerCase()},simple:function(){var a=[f("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",f("[\u00e8\u00e9\u00ea\u00eb]"),"e",f("[\u00ec\u00ed\u00ee\u00ef]"),"i",f("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",f("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",f("[\u00fd\u0177\u00ff]"),"y",f("\u00f1"),"n",f("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]"),
|
||||
" ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){b=e(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){var a=[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),"k",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=e(b,a));c||1<b.length&&(b=G(b));return b}}(),extra:function(){var a=[f("p"),"b",f("z"),"s",f("[cgq]"),
|
||||
"k",f("n"),"m",f("d"),"t",f("[vw]"),"f",f("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var c=0;c<b.length;c++){var d=b[c];1<d.length&&(b[c]=d[0]+e(d.substring(1),a))}b=b.join(" ");b=G(b)}return b}}(),balance:function(){var a=[f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){return G(e(b.toLowerCase(),a))}}()},ca=function(){function a(a){this.clear();this.H=!0!==a&&a}a.prototype.clear=function(){this.cache=B();this.count=
|
||||
B();this.index=B();this.A=[]};a.prototype.set=function(a,c){if(this.H&&z(this.cache[a])){var b=this.A.length;if(b===this.H){b--;var d=this.A[b];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=b;this.A[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){var b=this.cache[a];if(this.H&&b){var d=++this.count[a],e=this.index,f=e[a];if(0<f){for(var g=this.A,k=f;this.count[g[--f]]<=d&&-1!==f;);f++;if(f!==k){for(d=k;d>f;d--)k=g[d-
|
||||
1],g[d]=k,e[k]=d;g[f]=a;e[a]=f}}}return b};return a}();return d}(function(){var g={},l="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(d,m,k,f,e){k=l?URL.createObjectURL(new Blob(["("+k.toString()+")()"],{type:"text/javascript"})):d+".es5.js";d+="-"+m;g[d]||(g[d]=[]);g[d][e]=new Worker(k);g[d][e].onmessage=f;console.log("Register Worker: "+d+"@"+e);return g[d][e]}}()),this);
|
||||
'use strict';function Q(f){var k=0;return function(){return k<f.length?{done:!1,value:f[k++]}:{done:!0}}}function R(f){var k="undefined"!=typeof Symbol&&Symbol.iterator&&f[Symbol.iterator];return k?k.call(f):{next:Q(f)}}var X="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this,Y="function"==typeof Object.defineProperties?Object.defineProperty:function(f,k,e){f!=Array.prototype&&f!=Object.prototype&&(f[k]=e.value)};
|
||||
function Z(f,k){if(k){var e=X;f=f.split(".");for(var g=0;g<f.length-1;g++){var l=f[g];l in e||(e[l]={});e=e[l]}f=f[f.length-1];g=e[f];k=k(g);k!=g&&null!=k&&Y(e,f,{configurable:!0,writable:!0,value:k})}}
|
||||
Z("Promise",function(f){function k(c){this.f=0;this.o=void 0;this.a=[];var e=this.j();try{c(e.resolve,e.reject)}catch(A){e.reject(A)}}function e(){this.a=null}function g(c){return c instanceof k?c:new k(function(e){e(c)})}if(f)return f;e.prototype.f=function(c){if(null==this.a){this.a=[];var e=this;this.j(function(){e.o()})}this.a.push(c)};var l=X.setTimeout;e.prototype.j=function(c){l(c,0)};e.prototype.o=function(){for(;this.a&&this.a.length;){var c=this.a;this.a=[];for(var e=0;e<c.length;++e){var k=
|
||||
c[e];c[e]=null;try{k()}catch(G){this.l(G)}}}this.a=null};e.prototype.l=function(c){this.j(function(){throw c;})};k.prototype.j=function(){function c(c){return function(f){k||(k=!0,c.call(e,f))}}var e=this,k=!1;return{resolve:c(this.M),reject:c(this.l)}};k.prototype.M=function(c){if(c===this)this.l(new TypeError("A Promise cannot resolve to itself"));else if(c instanceof k)this.N(c);else{a:switch(typeof c){case "object":var e=null!=c;break a;case "function":e=!0;break a;default:e=!1}e?this.L(c):this.v(c)}};
|
||||
k.prototype.L=function(c){var e=void 0;try{e=c.then}catch(A){this.l(A);return}"function"==typeof e?this.O(e,c):this.v(c)};k.prototype.l=function(c){this.J(2,c)};k.prototype.v=function(c){this.J(1,c)};k.prototype.J=function(c,e){if(0!=this.f)throw Error("Cannot settle("+c+", "+e+"): Promise already settled in state"+this.f);this.f=c;this.o=e;this.K()};k.prototype.K=function(){if(null!=this.a){for(var c=0;c<this.a.length;++c)I.f(this.a[c]);this.a=null}};var I=new e;k.prototype.N=function(c){var e=this.j();
|
||||
c.D(e.resolve,e.reject)};k.prototype.O=function(c,e){var k=this.j();try{c.call(e,k.resolve,k.reject)}catch(G){k.reject(G)}};k.prototype.then=function(c,e){function f(c,e){return"function"==typeof c?function(e){try{g(c(e))}catch(P){r(P)}}:e}var g,r,l=new k(function(c,e){g=c;r=e});this.D(f(c,g),f(e,r));return l};k.prototype.catch=function(c){return this.then(void 0,c)};k.prototype.D=function(c,e){function k(){switch(f.f){case 1:c(f.o);break;case 2:e(f.o);break;default:throw Error("Unexpected state: "+
|
||||
f.f);}}var f=this;null==this.a?I.f(k):this.a.push(k)};k.resolve=g;k.reject=function(c){return new k(function(e,k){k(c)})};k.race=function(c){return new k(function(e,k){for(var f=R(c),l=f.next();!l.done;l=f.next())g(l.value).D(e,k)})};k.all=function(c){var e=R(c),f=e.next();return f.done?g([]):new k(function(c,k){function l(e){return function(k){r[e]=k;A--;0==A&&c(r)}}var r=[],A=0;do r.push(void 0),A++,g(f.value).D(l(r.length-1),k),f=e.next();while(!f.done)})};return k});
|
||||
(function(f,k,e){var g;(g=e.define)&&g.amd?g([],function(){return k}):(g=e.modules)?g[f.toLowerCase()]=k:"object"===typeof exports?module.exports=k:e[f]=k})("FlexSearch",function ea(f){function e(a,b){var d=b?b.id:a&&a.id;this.id=d||0===d?d:fa++;this.init(a,b);I(this,"index",function(){return this.c});I(this,"length",function(){return Object.keys(this.c).length})}function g(a,b,d,m){this.B!==this.h&&(this.u=this.u.concat(d),this.B++,m&&this.u.length>=m&&(this.B=this.h),this.G&&this.B===this.h&&(this.cache&&
|
||||
this.w.set(b,this.u),this.G(this.u),this.u=[]));return this}function l(a,b){a=a.concat.apply([],a);b&&(K(b)||(E=b.split(":"),1<E.length?b=ca:(E=E[0],b=ba)),a.sort(b));return a}function I(a,b,d){Object.defineProperty(a,b,{get:d})}function c(a){return new RegExp(a,"g")}function r(a,b){for(var d=0;d<b.length;d+=2)a=a.replace(b[d],b[d+1]);return a}function A(a,b,d,m,c,h,e){if(b[d])return b[d];c=c?(9-(e||6))*h+(e||6)*c:h;b[d]=c;c>=e&&(a=a[9-(c+.5>>0)],a=a[d]||(a[d]=[]),a[a.length]=m);return c}function G(a,
|
||||
b){if(a)for(var d=Object.keys(a),c=0,e=d.length;c<e;c++){var h=d[c],D=a[h];if(D)for(var B=0,f=D.length;B<f;B++)if(D[B]===b){1===f?delete a[h]:D.splice(B,1);break}else J(D[B])&&G(D[B],b)}}function O(a){for(var b="",d="",c="",e=0;e<a.length;e++){var h=a[e];if(h!==d)if(e&&"h"===h){if(c="a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c,("a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d)&&c||" "===d)b+=h}else b+=h;c=e===a.length-1?"":a[e+1];d=h}return b}function da(a,b){a=a.length-b.length;return 0>
|
||||
a?1:a?-1:0}function aa(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function ba(a,b){a=a[E];b=b[E];return a<b?-1:a>b?1:0}function ca(a,b){for(var d=E.length,c=0;c<d;c++)a=a[E[c]],b=b[E[c]];return a<b?-1:a>b?1:0}function P(a,b,d,c){var e=[],h=a.length;if(1<h){a.sort(aa);for(var m=C(),B=a[0],f=B.length,w=0;w<f;)m["@"+B[w++]]=1;for(var n,F=0,u=0;++u<h;){var t=!1,g=u===h-1;var v=[];B=a[u];f=B.length;for(w=0;w<f;){n=B[w++];var p="@"+n;if(m[p]){var y=m[p];if(y===u){if(g){if(e[F++]=d?d[p]:n,b&&F===b)return e}else m[p]=
|
||||
u+1;t=!0}else c&&(p=v[y]||(v[y]=[]),p[p.length]=n)}}if(!t&&!c)break}if(c&&(F=e.length,(u=v.length)&&(!b||F<b)))for(;u--;)if(n=v[u])for(w=0,f=n.length;w<f;w++)if(e[F++]=d?d["@"+n[w]]:n[w],b&&F===b)return e}else if(h)if(d)for(a=a[0],c=a.length,b&&b<c&&(c=b),e=Array(c),b=0;b<c;b++)e[b]=d["@"+a[b]];else e=a[0],b&&e.length>b&&(e=e.slice(0,b));return e}function M(a){return"string"===typeof a}function K(a){return"function"===typeof a}function J(a){return"object"===typeof a}function H(a){return"undefined"===
|
||||
typeof a}function S(a){for(var b=Array(a),d=0;d<a;d++)b[d]=C();return b}function C(){return Object.create(null)}function ha(){var a,b;self.onmessage=function(d){if(d=d.data)if(d.search){var c=b.search(d.content,d.threshold?{limit:d.limit,threshold:d.threshold}:d.limit);self.postMessage({id:a,content:d.content,limit:d.limit,result:c})}else d.add?b.add(d.id,d.content):d.update?b.update(d.id,d.content):d.remove?b.remove(d.id):d.clear?b.clear():d.info?(d=b.info(),d.worker=a,console.log(d)):d.register&&
|
||||
(a=d.id,d.options.cache=!1,d.options.async=!1,d.options.worker=!1,b=(new Function(d.register.substring(d.register.indexOf("{")+1,d.register.lastIndexOf("}"))))(),b=new b(d.options))}}function ia(a,b,d,c){a=f("flexsearch","id"+a,ha,function(a){(a=a.data)&&a.result&&c(a.id,a.content,a.result,a.limit)},b);var e=ea.toString();d.id=b;a.postMessage({register:e,options:d,id:b});return a}var z={encode:"icase",g:"forward",C:!1,cache:!1,async:!1,h:!1,F:!1,threshold:0,depth:0,b:!1},T={memory:{encode:"extra",
|
||||
g:"strict",threshold:7},speed:{encode:"icase",g:"strict",threshold:7,depth:2},match:{encode:"extra",g:"full"},score:{encode:"extra",g:"strict",threshold:5,depth:4},balance:{encode:"balance",g:"strict",threshold:6,depth:3},fastest:{encode:"icase",g:"strict",threshold:9,depth:1}},N=[],fa=0,U=c("\\W+"),V={},W={};e.create=function(a){return new e(a)};e.registerMatcher=function(a){for(var b in a)a.hasOwnProperty(b)&&N.push(c(b),a[b]);return this};e.registerEncoder=function(a,b){L[a]=b.bind(L);return this};
|
||||
e.registerLanguage=function(a,b){V[a]=b.filter;W[a]=b.stemmer;return this};e.encode=function(a,b){return L[a](b)};e.prototype.init=function(a,b){this.f=[];if(b){var d=b.preset;a=b}else a||(a=z),d=a.preset;b={};M(a)?((b=T[a])||console.warn("Preset not found: "+a),a={}):d&&((b=T[d])||console.warn("Preset not found: "+d));if(d=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.a=null;else{var m=parseInt(d,10)||4;this.v=-1;this.B=0;this.u=[];this.G=null;this.a=Array(m);for(var q=0;q<m;q++)this.a[q]=
|
||||
ia(this.id,q,a,g.bind(this))}this.g=a.tokenize||b.g||this.g||z.g;this.F=a.rtl||this.F||z.F;this.async="undefined"===typeof Promise||H(d=a.async)?this.async||z.async:d;this.h=H(d=a.worker)?this.h||z.h:d;this.threshold=H(d=a.threshold)?b.threshold||this.threshold||z.threshold:d;this.depth=H(d=a.depth)?b.depth||this.depth||z.depth:d;this.C=H(d=a.suggest)?this.C||z.C:d;this.j=(d=H(d=a.encode)?b.encode||z.encode:d)&&L[d]&&L[d].bind(L)||(K(d)?d:this.j||!1);(d=a.matcher)&&this.addMatcher(d);if(d=a.filter){d=
|
||||
V[d]||d;b=this.j;m=C();if(d)for(q=0;q<d.length;q++){var h=b?b(d[q]):d[q];m[h]=String.fromCharCode(65E3-d.length+q)}this.filter=m}if(d=a.stemmer){b=W[d]||d;m=this.j;q=[];if(b)for(var D in b)b.hasOwnProperty(D)&&(h=m?m(D):D,q.push(c("(?=.{"+(h.length+3)+",})"+h+"$"),m?m(b[D]):b[D]));this.stemmer=q}this.b=h=(d=a.doc)?d:this.b||z.b;this.m=S(10-(this.threshold||0));this.s=C();this.c=C();if(h){this.i=C();a.doc=null;D=h.index=[];b=h.ref={};m=h.field;q=h.tag;h.id=h.id.split(":");if(q){this.H=C();q.constructor===
|
||||
Array||(h.tag=q=[q]);for(var f=0;f<q.length;f++)this.H[q[f]]=C(),q[f]=q[f].split(":")}if(m)for(m.constructor===Array||(h.field=m=[m]),h=0;h<m.length;h++)b[m[h]]=h,m[h]=m[h].split(":"),D[h]=new e(a),D[h].i=this.i,q&&(D[h].H=this.H)}this.o=!0;this.w=(this.cache=d=H(d=a.cache)?this.cache||z.cache:d)?new ja(d):!1;return this};e.prototype.encode=function(a){a&&N.length&&(a=r(a,N));a&&this.f.length&&(a=r(a,this.f));a&&this.j&&(a=this.j(a));a&&this.stemmer&&(a=r(a,this.stemmer));return a};e.prototype.addMatcher=
|
||||
function(a){var b=this.f,d;for(d in a)a.hasOwnProperty(d)&&b.push(c(d),a[d]);return this};e.prototype.add=function(a,b,d,c,e){if(this.b&&J(a))return this.l("add",a,b);if(b&&M(b)&&(a||0===a)){var h="@"+a;if(this.c[h]&&!c)return this.update(a,b);if(this.h)return++this.v>=this.a.length&&(this.v=0),this.a[this.v].postMessage({add:!0,id:a,content:b}),this.c[h]=""+this.v,d&&d(),this;if(!e){if(this.async&&"function"!==typeof importScripts){var m=this;h=new Promise(function(d){setTimeout(function(){m.add(a,
|
||||
b,null,c,!0);m=null;d()})});if(d)h.then(d);else return h;return this}if(d)return this.add(a,b,null,c,!0),d(),this}b=this.encode(b);if(!b.length)return this;d=this.g;e=K(d)?d(b):b.split(U);var q=C();q._ctx=C();for(var f=this.threshold,w=this.depth,n=this.m,g=e.length,u=this.F,t=0;t<g;t++){var l=e[t];if(l){var v=l.length,p=(u?t+1:g-t)/g,y="";switch(d){case "reverse":case "both":for(var x=v;--x;)y=l[x]+y,A(n,q,y,a,u?1:(v-x)/v,p,f);y="";case "forward":for(x=0;x<v;x++)y+=l[x],A(n,q,y,a,u?(x+1)/v:1,p,f);
|
||||
break;case "full":for(x=0;x<v;x++)for(var r=(u?x+1:v-x)/v,z=v;z>x;z--)y=l.substring(x,z),A(n,q,y,a,r,p,f);break;default:if(v=A(n,q,l,a,1,p,f),w&&1<g&&v>=f)for(v=q._ctx[l]||(q._ctx[l]=C()),l=this.s[l]||(this.s[l]=S(10-(f||0))),p=t-w,y=t+w+1,0>p&&(p=0),y>g&&(y=g);p<y;p++)p!==t&&A(l,v,e[p],a,0,10-(p<t?t-p:p-t),f)}}}this.c[h]=1;this.o=!1}return this};e.prototype.l=function(a,b,d){if(b.constructor===Array)for(var c=0,e=b.length;c<e;c++){if(c===e-1)return this.l(a,b[c],d);this.l(a,b[c])}else{c=this.b.index;
|
||||
for(var h=this.b.tag,f=this.b.id,B=0;B<f.length;B++)e=(e||b)[f[B]];if(h)for(f=0;f<h.length;f++);if("remove"===a)for(delete this.i["@"+e],f=0,h=c.length;f<h;f++){if(f===h-1)return c[f].remove(e,d);c[f].remove(e)}f=this.b.field;h=0;for(B=f.length;h<B;h++){for(var l=f[h],g=void 0,n=0;n<l.length;n++)g=(g||b)[l[n]];this.i["@"+e]=b;l=c[h];n="add"===a?l.add:l.update;if(h===B-1)return n.call(l,e,g,d);n.call(l,e,g)}}};e.prototype.update=function(a,b,d){if(this.b&&J(a))return this.l("update",a,b);this.c["@"+
|
||||
a]&&M(b)&&(this.remove(a),this.add(a,b,d,!0));return this};e.prototype.remove=function(a,b,d){if(this.b&&J(a))return this.l("remove",a,b);var c="@"+a;if(this.c[c]){if(this.h)return this.a[this.c[c]].postMessage({remove:!0,id:a}),delete this.c[c],b&&b(),this;if(!d){if(this.async&&"function"!==typeof importScripts){var e=this;c=new Promise(function(b){setTimeout(function(){e.remove(a,null,!0);e=null;b()})});if(b)c.then(b);else return c;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<
|
||||
10-(this.threshold||0);b++)G(this.m[b],a);this.depth&&G(this.s,a);delete this.c[c];this.o=!1}return this};var E;e.prototype.search=function(a,b,d,c){if(J(b)){if(b.constructor===Array)for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}var h=a,f=[];if(J(a)&&a.constructor!==Array){(d=a.callback||b)&&(h.callback=null);var m=a.boost;var g=a.where;var w=a.sort;b=a.limit;var n=a.threshold;a=a.query}if(this.b){a=this.b.ref;n=this.b.index;if(g=h.field)h.field=null;else if(h.constructor===Array){var F=
|
||||
h;g=[];for(var u=0;u<h.length;u++)g[u]=h[u].field}else g=Object.keys(a);if(J(g)){g.constructor===Array||(g=[g]);u=g.length;for(var t=0;t<u;t++)F&&(h=F[t]),f[t]=n[a[g[t]]].search(h);return d?d(l(f,w)):this.async?new Promise(function(a){Promise.all(f).then(function(b){a(l(b,w))})}):l(f,w)}return n[a[g]].search(h,d)}n||(n=this.threshold||0);K(b)?(d=b,b=1E3):b||0===b||(b=1E3);if(this.h)for(this.G=d,this.B=0,this.u=[],g=0;g<this.h;g++)this.a[g].postMessage({search:!0,limit:b,threshold:n,content:a});else{if(!c){if(this.async&&
|
||||
"function"!==typeof importScripts){var r=this;a=new Promise(function(a){setTimeout(function(){a(r.search(h,b,null,!0));r=null})});if(d)a.then(d);else return a;return this}if(d)return d(this.search(h,b,null,!0)),this}if(!a||!M(a))return f;h=a;if(this.cache)if(this.o){if(d=this.w.get(a))return d}else this.w.clear(),this.o=!0;h=this.encode(h);if(!h.length)return f;d=this.g;d=K(d)?d(h):h.split(U);F=d.length;c=!0;e=[];var v=C();if(1<F)if(this.depth){u=!0;var p=d[0];v[p]=1}else d.sort(da);if(!u||(t=this.s)[p]){var y=
|
||||
0;m&&(n=(n||1)/m,0>m&&(y=n));for(m=u?1:0;m<F;m++){var x=d[m];if(x){if(!v[x]){var z=[],A=!1,E=0;if(p=u?t[p]:this.m)for(var H=void 0,G=y;G<10-n;G++)if(H=p[G][x])z[E++]=H,A=!0;if(A)e[e.length]=1<E?z.concat.apply([],z):z[0];else if(!this.C){c=!1;break}v[x]=1}p=x}}}else c=!1;c&&(f=P(e,b,this.i,this.C));g&&(f=this.where(g,null,b,f));w&&(f=l([f],w));this.cache&&this.w.set(a,f);return f}};e.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};e.prototype.where=function(a,b,d,c){var e=c||this.i,
|
||||
f=[],m=0,g;if(M(a)){if("id"===a)return[e["@"+b]];var l=1;var w=[a.split(":")];var n=!0}else{if(K(a)){b=c||Object.keys(e);d=b.length;for(g=0;g<d;g++)l=c?c[g]:e[b[g]],a(l)&&(f[m++]=l);return f}d||(d=b);g=Object.keys(a);l=g.length;n=!1;if(1===l&&"id"===g[0])return[e["@"+a.id]];w=Array(l);for(var r=0;r<l;r++)w[r]=g[r].split(":")}r=c||Object.keys(e);for(var u=r.length,t=0;t<u;t++){for(var z=c?c[t]:e[r[t]],v=!0,p=0;p<l;p++){n||(b=a[g[p]]);var y=w[p],x=y.length,A=z;if(1<x)for(var C=0;C<x;C++)A=A[y[C]];else A=
|
||||
A[y[0]];if(A!==b){v=!1;break}}if(v&&(f[m++]=z,d&&m===d))break}return f};e.prototype.info=function(){if(this.h)for(var a=0;a<this.h;a++)this.a[a].postMessage({info:!0,id:this.id});else{for(var b,d=0,c=0,e=0,f=0;f<10-(this.threshold||0);f++){a=Object.keys(this.m[f]);for(var g=0;g<a.length;g++)b=this.m[f][a[g]].length,d+=1*b+2*a[g].length+4,c+=b,e+=2*a[g].length}a=Object.keys(this.c);b=a.length;for(f=0;f<b;f++)d+=2*a[f].length+2;return{id:this.id,memory:d,items:b,sequences:c,chars:e,cache:this.cache&&
|
||||
this.cache.A?this.cache.A.length:!1,matcher:N.length+(this.f?this.f.length:0),worker:this.h,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.g}}};e.prototype.clear=function(){return this.destroy().init()};e.prototype.destroy=function(){this.cache&&(this.w.clear(),this.w=null);this.m=this.s=this.c=null;if(this.b){for(var a=this.i.index,b=0;b<a.length;b++)a.destroy();this.i=null}return this};e.prototype.export=function(){if(this.b){for(var a=this.b.index,b=Array(a.length+
|
||||
1),d=0;d<a.length;d++)b[d]=[a[d].m,a[d].s,a[d].c];b[d]=this.i;return JSON.stringify(b)}return JSON.stringify([this.m,this.s,this.c])};e.prototype.import=function(a){a=JSON.parse(a);if(this.b){for(var b=this.b.index,d=b.length,c=0;c<d;c++){var e=b[c];e.m=a[c][0];e.s=a[c][1];e.c=a[c][2];e.i=a[d]}this.i=a[d]}else this.m=a[0],this.s=a[1],this.c=a[2],this.i=a[3]};var L={icase:function(a){return a.toLowerCase()},simple:function(){var a=[c("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",c("[\u00e8\u00e9\u00ea\u00eb]"),
|
||||
"e",c("[\u00ec\u00ed\u00ee\u00ef]"),"i",c("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",c("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",c("[\u00fd\u0177\u00ff]"),"y",c("\u00f1"),"n",c("\u00e7"),"c",c("\u00df"),"s",c(" & ")," and ",c("[-/]")," ",c("[^a-z0-9 ]"),"",c("\\s+")," "];return function(b){b=r(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){var a=[c("ae"),"a",c("ai"),"ei",c("ay"),"ei",c("ey"),"ei",c("oe"),"o",c("ue"),"u",c("ie"),"i",c("sz"),"s",c("zs"),"s",c("sh"),"s",c("ck"),"k",c("cc"),
|
||||
"k",c("dt"),"t",c("ph"),"f",c("pf"),"f",c("ou"),"o",c("uo"),"u"];return function(b,d){if(!b)return b;b=this.simple(b);2<b.length&&(b=r(b,a));d||1<b.length&&(b=O(b));return b}}(),extra:function(){var a=[c("p"),"b",c("z"),"s",c("[cgq]"),"k",c("n"),"m",c("d"),"t",c("[vw]"),"f",c("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(var d=0;d<b.length;d++){var c=b[d];1<c.length&&(b[d]=c[0]+r(c.substring(1),a))}b=b.join(" ");b=O(b)}return b}}(),balance:function(){var a=
|
||||
[c("[-/]")," ",c("[^a-z0-9 ]"),"",c("\\s+")," "];return function(b){return O(r(b.toLowerCase(),a))}}()},ja=function(){function a(a){this.clear();this.I=!0!==a&&a}a.prototype.clear=function(){this.cache=C();this.count=C();this.index=C();this.A=[]};a.prototype.set=function(a,c){if(this.I&&H(this.cache[a])){var b=this.A.length;if(b===this.I){b--;var d=this.A[b];delete this.cache[d];delete this.count[d];delete this.index[d]}this.index[a]=b;this.A[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=
|
||||
c};a.prototype.get=function(a){var b=this.cache[a];if(this.I&&b){var c=++this.count[a],e=this.index,f=e[a];if(0<f){for(var g=this.A,l=f;this.count[g[--f]]<=c&&-1!==f;);f++;if(f!==l){for(c=l;c>f;c--)l=g[c-1],g[c]=l,e[l]=c;g[f]=a;e[a]=f}}}return b};return a}();return e}(function(){var f={},k="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(e,g,l,I,c){l=k?URL.createObjectURL(new Blob(["("+l.toString()+")()"],{type:"text/javascript"})):e+".es5.js";e+="-"+g;f[e]||
|
||||
(f[e]=[]);f[e][c]=new Worker(l);f[e][c].onmessage=I;console.log("Register Worker: "+e+"@"+c);return f[e][c]}}()),this);
|
||||
|
2
dist/flexsearch.light.js
vendored
2
dist/flexsearch.light.js
vendored
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
FlexSearch v0.4.0
|
||||
FlexSearch v0.5.0
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
|
60
dist/flexsearch.min.js
vendored
60
dist/flexsearch.min.js
vendored
@@ -1,35 +1,37 @@
|
||||
/*
|
||||
FlexSearch v0.4.0
|
||||
FlexSearch v0.5.0
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(t,A,g){let w;(w=g.define)&&w.amd?w([],function(){return A}):(w=g.modules)?w[t.toLowerCase()]=A:"object"===typeof exports?module.exports=A:g[t]=A})("FlexSearch",function Q(t){function g(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:R++;this.init(a,b);B(this,"index",function(){return this.a});B(this,"length",function(){return Object.keys(this.a).length})}function w(a,b,c,e){this.s!==this.f&&(this.j=this.j.concat(c),this.s++,e&&this.j.length>=e&&(this.s=this.f),this.F&&this.s===
|
||||
this.f&&(this.cache&&this.m.set(b,this.j),this.F(this.j),this.j=[]));return this}function B(a,b,c){Object.defineProperty(a,b,{get:c})}function f(a){return new RegExp(a,"g")}function n(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function F(a,b,c,e,d,l,h){if(b[c])return b[c];d=d?(9-(h||6))*l+(h||6)*d:l;b[c]=d;d>=h&&(a=a[9-(d+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=e);return d}function J(a,b){if(a){const c=Object.keys(a);for(let e=0,d=c.length;e<d;e++){const d=c[e],h=a[d];if(h)for(let c=
|
||||
0,e=h.length;c<e;c++)if(h[c]===b){1===e?delete a[d]:h.splice(c,1);break}else z(h[c])&&J(h[c],b)}}}function K(a){let b="",c="";var e="";for(let d=0;d<a.length;d++){const l=a[d];if(l!==c)if(d&&"h"===l){if(e="a"===e||"e"===e||"i"===e||"o"===e||"u"===e||"y"===e,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&e||" "===c)b+=l}else b+=l;e=d===a.length-1?"":a[d+1];c=l}return b}function S(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function T(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function U(a,
|
||||
b,c,e){let d=[],l;const h=a.length;if(1<h){a.sort(T);const x=u();let k=a[0],r=k.length,g=0;for(;g<r;)x["@"+k[g++]]=1;let m,C=0,v=0;for(;++v<h;){let p=!1;const V=v===h-1;l=[];k=a[v];r=k.length;for(g=0;g<r;){m=k[g++];var f="@"+m;if(x[f]){const a=x[f];if(a===v){if(V){if(d[C++]=c?c[f]:m,b&&C===b)return d}else x[f]=v+1;p=!0}else e&&(f=l[a]||(l[a]=[]),f[f.length]=m)}}if(!p&&!e)break}if(e&&(C=d.length,(v=l.length)&&(!b||C<b)))for(;v--;)if(m=l[v])for(g=0,r=m.length;g<r;g++)if(d[C++]=c?c["@"+m[g]]:m[g],b&&
|
||||
C===b)return d}else if(h)if(c)for(a=a[0],e=a.length,b&&b<e&&(e=b),d=Array(e),b=0;b<e;b++)d[b]=c["@"+a[b]];else d=a[0],b&&d.length>b&&(d=d.slice(0,b));return d}function G(a){return"string"===typeof a}function H(a){return"function"===typeof a}function z(a){return"object"===typeof a}function y(a){return"undefined"===typeof a}function L(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=u();return b}function u(){return Object.create(null)}function W(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const e=
|
||||
b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:e})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function X(a,
|
||||
b,c,e){a=t("flexsearch","id"+a,W,function(a){(a=a.data)&&a.result&&e(a.id,a.content,a.result,a.limit)},b);const d=Q.toString();c.id=b;a.postMessage({register:d,options:c,id:b});return a}const q={encode:"icase",c:"forward",A:!1,cache:!1,async:!1,f:!1,D:!1,threshold:0,depth:0,b:!1},M={memory:{encode:"extra",c:"strict",threshold:7},speed:{encode:"icase",c:"strict",threshold:7,depth:2},match:{encode:"extra",c:"full"},score:{encode:"extra",c:"strict",threshold:5,depth:4},balance:{encode:"balance",c:"strict",
|
||||
threshold:6,depth:3},fastest:{encode:"icase",c:"strict",threshold:9,depth:1}},I=[];let R=0;const N=f("\\W+"),O={},P={};g.create=function(a){return new g(a)};g.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&I.push(f(b),a[b]);return this};g.registerEncoder=function(a,b){E[a]=b.bind(E);return this};g.registerLanguage=function(a,b){O[a]=b.filter;P[a]=b.stemmer;return this};g.encode=function(a,b){return E[a](b)};g.prototype.init=function(a,b){this.u=[];if(b){var c=b.preset;a=b}else a||
|
||||
(a=q),c=a.preset;b={};G(a)?(b=M[a],a={}):c&&(b=M[c]);if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.l=null;else{var e=parseInt(c,10)||4;this.C=-1;this.s=0;this.j=[];this.F=null;this.l=Array(e);for(var d=0;d<e;d++)this.l[d]=X(this.id,d,a,w.bind(this))}this.c=a.tokenize||b.c||this.c||q.c;this.D=a.rtl||this.D||q.D;this.async="undefined"===typeof Promise||y(c=a.async)?this.async||q.async:c;this.f=y(c=a.worker)?this.f||q.f:c;this.threshold=y(c=a.threshold)?b.threshold||this.threshold||q.threshold:
|
||||
c;this.depth=y(c=a.depth)?b.depth||this.depth||q.depth:c;this.A=y(c=a.suggest)?this.A||q.A:c;this.v=(c=y(c=a.encode)?b.encode||q.encode:c)&&E[c]&&E[c].bind(E)||(H(c)?c:this.v||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=O[c]||c;b=this.v;e=u();if(c)for(d=0;d<c.length;d++){var l=b?b(c[d]):c[d];e[l]=String.fromCharCode(65E3-c.length+d)}this.filter=c=e}if(c=a.stemmer){var h;b=P[c]||c;e=this.v;d=[];if(b)for(h in b)b.hasOwnProperty(h)&&(l=e?e(h):h,d.push(f("(?=.{"+(l.length+3)+",})"+l+"$"),e?
|
||||
e(b[h]):b[h]));this.stemmer=h=d}this.b=d=(c=a.doc)?c:this.b||q.b;this.h=L(10-(this.threshold||0));this.i=u();this.a=u();this.g=d&&u();if(d)if(a.doc=null,h=d.field,b=d.index=[],e=d.ref={},d.id=d.id.split(":"),h.constructor===Array)for(d=0;d<h.length;d++)e[h[d]]=d,h[d]=h[d].split(":"),b[d]=new g(a),b[d].g=this.g;else e[h]=0,d.field=[h.split(":")],b[0]=new g(a),b[0].g=this.g;this.B=!0;this.m=(this.cache=c=y(c=a.cache)?this.cache||q.cache:c)?new Y(c):!1;return this};g.prototype.encode=function(a){a&&
|
||||
I.length&&(a=n(a,I));a&&this.u.length&&(a=n(a,this.u));a&&this.v&&(a=this.v(a));a&&this.stemmer&&(a=n(a,this.stemmer));return a};g.prototype.addMatcher=function(a){const b=this.u;for(const c in a)a.hasOwnProperty(c)&&b.push(f(c),a[c]);return this};g.prototype.add=function(a,b,c,e,d){if(this.b&&z(a))return this.w("add",a,b);if(b&&G(b)&&(a||0===a)){var l="@"+a;if(this.a[l]&&!e)return this.update(a,b);if(this.f)return++this.C>=this.l.length&&(this.C=0),this.l[this.C].postMessage({add:!0,id:a,content:b}),
|
||||
this.a[l]=""+this.C,c&&c(),this;if(!d){if(this.async&&"function"!==typeof importScripts){let d=this;l=new Promise(function(c){setTimeout(function(){d.add(a,b,null,e,!0);d=null;c()})});if(c)l.then(c);else return l;return this}if(c)return this.add(a,b,null,e,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.c;d=H(c)?c(b):b.split(N);const r=u();r._ctx=u();const m=this.threshold,x=this.depth,v=this.h,D=d.length,n=this.D;for(let b=0;b<D;b++){var h=d[b];if(h){var f=h.length,g=(n?b+1:D-b)/D,
|
||||
k="";switch(c){case "reverse":case "both":for(var p=f;--p;)k=h[p]+k,F(v,r,k,a,n?1:(f-p)/f,g,m);k="";case "forward":for(p=0;p<f;p++)k+=h[p],F(v,r,k,a,n?(p+1)/f:1,g,m);break;case "full":for(p=0;p<f;p++){const b=(n?p+1:f-p)/f;for(let c=f;c>p;c--)k=h.substring(p,c),F(v,r,k,a,b,g,m)}break;default:if(f=F(v,r,h,a,1,g,m),x&&1<D&&f>=m)for(f=r._ctx[h]||(r._ctx[h]=u()),h=this.i[h]||(this.i[h]=L(10-(m||0))),g=b-x,k=b+x+1,0>g&&(g=0),k>D&&(k=D);g<k;g++)g!==b&&F(h,f,d[g],a,0,10-(g<b?b-g:g-b),m)}}}this.a[l]=1;this.B=
|
||||
!1}return this};g.prototype.w=function(a,b,c){if(b.constructor===Array)for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.w(a,b[d],c);this.w(a,b[d])}else{const f=this.b.index;let h=this.b.id,g;for(var e=0;e<h.length;e++)g=(g||b)[h[e]];if("remove"===a){delete this.g["@"+g];for(let a=0,b=f.length;a<b;a++){if(a===b-1)return f[a].remove(g,c);f[a].remove(g)}}h=this.b.field;for(let l=0,k=h.length;l<k;l++){e=h[l];let r;for(var d=0;d<e.length;d++)r=(r||b)[e[d]];this.g["@"+g]=b;e=f[l];d="add"===a?e.add:
|
||||
e.update;if(l===k-1)return d.call(e,g,r,c);d.call(e,g,r)}}};g.prototype.update=function(a,b,c){if(this.b&&z(a))return this.w("update",a,b);this.a["@"+a]&&G(b)&&(this.remove(a),this.add(a,b,c,!0));return this};g.prototype.remove=function(a,b,c){if(this.b&&z(a))return this.w("remove",a,b);var e="@"+a;if(this.a[e]){if(this.f)return this.l[this.a[e]].postMessage({remove:!0,id:a}),delete this.a[e],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;e=new Promise(function(b){setTimeout(function(){c.remove(a,
|
||||
null,!0);c=null;b()})});if(b)e.then(b);else return e;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)J(this.h[b],a);this.depth&&J(this.i,a);delete this.a[e];this.B=!1}return this};g.prototype.search=function(a,b,c,e){if(z(b)){if(b.constructor===Array)for(var d=0;d<b.length;d++)b[d].query=a;else b.query=a;a=b;b=0}let f=a;let h=[];if(z(a)&&a.constructor!==Array){(c=a.callback||b)&&(f.callback=null);b=a.limit;var g=a.threshold;var n=a.boost;a=a.query}if(this.b){a=
|
||||
this.b.ref;g=this.b.index;var k=f.field;if(k)f.field=null;else if(f.constructor===Array){var p=f;k=[];for(var q=0;q<f.length;q++)k[q]=f[q].field}else k=Object.keys(a);if(z(k)){k.constructor===Array||(k=[k]);q=k.length;for(var m=0;m<q;m++)p&&(f=p[m]),h[m]=g[a[k[m]]].search(f);return c?c(h.concat.apply([],h)):this.async?new Promise(function(a){Promise.all(h).then(function(b){a(b.concat.apply([],b))})}):h.concat.apply([],h)}return g[a[k]].search(f,c)}g||(g=this.threshold||0);H(b)?(c=b,b=1E3):b||0===
|
||||
b||(b=1E3);if(this.f)for(this.F=c,this.s=0,this.j=[],k=0;k<this.f;k++)this.l[k].postMessage({search:!0,limit:b,threshold:g,content:a});else{if(!e){if(this.async&&"function"!==typeof importScripts){let d=this;a=new Promise(function(a){setTimeout(function(){a(d.search(f,b,null,!0));d=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(f,b,null,!0)),this}if(!a||!G(a))return h;f=a;if(this.cache)if(this.B){if(c=this.m.get(a))return c}else this.m.clear(),this.B=!0;f=this.encode(f);
|
||||
if(!f.length)return h;c=this.c;c=H(c)?c(f):f.split(N);p=c.length;e=!0;d=[];var t=u();1<p&&(this.depth?(k=!0,m=c[0],t[m]=1):c.sort(S));if(!k||(q=this.i)[m]){let a=0;n&&(g=(g||1)/n,0>n&&(a=g));for(n=k?1:0;n<p;n++){const b=c[n];if(b){if(!t[b]){const c=[];let f=!1,h=0;if(m=k?q[m]:this.h){let d;for(let e=a;e<10-g;e++)if(d=m[e][b])c[h++]=d,f=!0}if(f)d[d.length]=1<h?c.concat.apply([],c):c[0];else if(!this.A){e=!1;break}t[b]=1}m=b}}}else e=!1;e&&(h=U(d,b,this.g,this.A));this.cache&&this.m.set(a,h);return h}};
|
||||
g.prototype.info=function(){if(this.f)for(var a=0;a<this.f;a++)this.l[a].postMessage({info:!0,id:this.id});else{var b=0,c=0,e=0;for(var d=0;d<10-(this.threshold||0);d++){a=Object.keys(this.h[d]);for(let h=0;h<a.length;h++){var f=this.h[d][a[h]].length;b+=1*f+2*a[h].length+4;c+=f;e+=2*a[h].length}}a=Object.keys(this.a);f=a.length;for(d=0;d<f;d++)b+=2*a[d].length+2;return{id:this.id,memory:b,items:f,sequences:c,chars:e,cache:this.cache&&this.cache.o?this.cache.o.length:!1,matcher:I.length+(this.u?this.u.length:
|
||||
0),worker:this.f,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.c}}};g.prototype.clear=function(){return this.destroy().init()};g.prototype.destroy=function(){this.cache&&(this.m.clear(),this.m=null);this.h=this.i=this.a=null;return this};g.prototype.export=function(){if(this.b){const a=this.b.index,b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=[a[c].h,a[c].i,a[c].a];b[c]=this.g;return JSON.stringify(b)}return JSON.stringify([this.h,this.i,this.a])};g.prototype.import=
|
||||
function(a){a=JSON.parse(a);if(this.b){const b=this.b.index,c=b.length;for(let e=0;e<c;e++){const d=b[e];d.h=a[e][0];d.i=a[e][1];d.a=a[e][2];d.g=a[c]}this.g=a[c]}else this.h=a[0],this.i=a[1],this.a=a[2],this.g=a[3]};const E={icase:function(a){return a.toLowerCase()},simple:function(){const a=[f("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",f("[\u00e8\u00e9\u00ea\u00eb]"),"e",f("[\u00ec\u00ed\u00ee\u00ef]"),"i",f("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",f("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",
|
||||
f("[\u00fd\u0177\u00ff]"),"y",f("\u00f1"),"n",f("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){b=n(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),"k",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&
|
||||
(b=n(b,a));c||1<b.length&&(b=K(b));return b}}(),extra:function(){const a=[f("p"),"b",f("z"),"s",f("[cgq]"),"k",f("n"),"m",f("d"),"t",f("[vw]"),"f",f("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const e=b[c];1<e.length&&(b[c]=e[0]+n(e.substring(1),a))}b=b.join(" ");b=K(b)}return b}}(),balance:function(){const a=[f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){return K(n(b.toLowerCase(),a))}}()},
|
||||
Y=function(){function a(a){this.clear();this.G=!0!==a&&a}a.prototype.clear=function(){this.cache=u();this.count=u();this.index=u();this.o=[]};a.prototype.set=function(a,c){if(this.G&&y(this.cache[a])){let b=this.o.length;if(b===this.G){b--;const a=this.o[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.o[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.G&&b){var e=++this.count[a];
|
||||
const b=this.index;let c=b[a];if(0<c){const f=this.o;for(var d=c;this.count[f[--c]]<=e&&-1!==c;);c++;if(c!==d){for(e=d;e>c;e--)d=f[e-1],f[e]=d,b[d]=e;f[c]=a;b[a]=c}}}return b};return a}();return g}(function(){const t={},A="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;return function(g,w,B,f,n){B=A?URL.createObjectURL(new Blob(["("+B.toString()+")()"],{type:"text/javascript"})):g+".min.js";g+="-"+w;t[g]||(t[g]=[]);t[g][n]=new Worker(B);t[g][n].onmessage=f;return t[g][n]}}()),
|
||||
this);
|
||||
'use strict';(function(x,F,f){let y;(y=f.define)&&y.amd?y([],function(){return F}):(y=f.modules)?y[x.toLowerCase()]=F:"object"===typeof exports?module.exports=F:f[x]=F})("FlexSearch",function U(x){function f(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:V++;this.init(a,b);K(this,"index",function(){return this.b});K(this,"length",function(){return Object.keys(this.b).length})}function y(a,b,c,d){this.s!==this.f&&(this.j=this.j.concat(c),this.s++,d&&this.j.length>=d&&(this.s=this.f),this.F&&this.s===
|
||||
this.f&&(this.cache&&this.m.set(b,this.j),this.F(this.j),this.j=[]));return this}function A(a,b){a=a.concat.apply([],a);b&&(G(b)||(z=b.split(":"),1<z.length?b=W:(z=z[0],b=X)),a.sort(b));return a}function K(a,b,c){Object.defineProperty(a,b,{get:c})}function h(a){return new RegExp(a,"g")}function C(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,d,e,g,k){if(b[c])return b[c];e=e?(9-(k||6))*g+(k||6)*e:g;b[c]=e;e>=k&&(a=a[9-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);
|
||||
return e}function N(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],k=a[e];if(k)for(let c=0,d=k.length;c<d;c++)if(k[c]===b){1===d?delete a[e]:k.splice(c,1);break}else D(k[c])&&N(k[c],b)}}}function O(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const g=a[e];if(g!==c)if(e&&"h"===g){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=g}else b+=g;d=e===a.length-1?"":a[e+1];c=g}return b}
|
||||
function Y(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function Z(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function X(a,b){a=a[z];b=b[z];return a<b?-1:a>b?1:0}function W(a,b){const c=z.length;for(let d=0;d<c;d++)a=a[z[d]],b=b[z[d]];return a<b?-1:a>b?1:0}function aa(a,b,c,d){let e=[],g;const k=a.length;if(1<k){a.sort(Z);const h=q();let l=a[0],m=l.length,f=0;for(;f<m;)h["@"+l[f++]]=1;let n,u=0,t=0;for(;++t<k;){let r=!1;const E=t===k-1;g=[];l=a[t];m=l.length;for(f=0;f<m;){n=l[f++];var p="@"+n;if(h[p]){const a=
|
||||
h[p];if(a===t){if(E){if(e[u++]=c?c[p]:n,b&&u===b)return e}else h[p]=t+1;r=!0}else d&&(p=g[a]||(g[a]=[]),p[p.length]=n)}}if(!r&&!d)break}if(d&&(u=e.length,(t=g.length)&&(!b||u<b)))for(;t--;)if(n=g[t])for(f=0,m=n.length;f<m;f++)if(e[u++]=c?c["@"+n[f]]:n[f],b&&u===b)return e}else if(k)if(c)for(a=a[0],d=a.length,b&&b<d&&(d=b),e=Array(d),b=0;b<d;b++)e[b]=c["@"+a[b]];else e=a[0],b&&e.length>b&&(e=e.slice(0,b));return e}function J(a){return"string"===typeof a}function G(a){return"function"===typeof a}function D(a){return"object"===
|
||||
typeof a}function B(a){return"undefined"===typeof a}function P(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=q();return b}function q(){return Object.create(null)}function ba(){let a,b;self.onmessage=function(c){if(c=c.data)if(c.search){const d=b.search(c.content,c.threshold?{limit:c.limit,threshold:c.threshold}:c.limit);self.postMessage({id:a,content:c.content,limit:c.limit,result:d})}else c.add?b.add(c.id,c.content):c.update?b.update(c.id,c.content):c.remove?b.remove(c.id):c.clear?b.clear():c.info?
|
||||
(c=b.info(),c.worker=a,console.log(c)):c.register&&(a=c.id,c.options.cache=!1,c.options.async=!1,c.options.worker=!1,b=(new Function(c.register.substring(c.register.indexOf("{")+1,c.register.lastIndexOf("}"))))(),b=new b(c.options))}}function ca(a,b,c,d){a=x("flexsearch","id"+a,ba,function(a){(a=a.data)&&a.result&&d(a.id,a.content,a.result,a.limit)},b);const e=U.toString();c.id=b;a.postMessage({register:e,options:c,id:b});return a}const w={encode:"icase",c:"forward",A:!1,cache:!1,async:!1,f:!1,D:!1,
|
||||
threshold:0,depth:0,a:!1},Q={memory:{encode:"extra",c:"strict",threshold:7},speed:{encode:"icase",c:"strict",threshold:7,depth:2},match:{encode:"extra",c:"full"},score:{encode:"extra",c:"strict",threshold:5,depth:4},balance:{encode:"balance",c:"strict",threshold:6,depth:3},fastest:{encode:"icase",c:"strict",threshold:9,depth:1}},M=[];let V=0;const R=h("\\W+"),S={},T={};f.create=function(a){return new f(a)};f.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&M.push(h(b),a[b]);return this};
|
||||
f.registerEncoder=function(a,b){H[a]=b.bind(H);return this};f.registerLanguage=function(a,b){S[a]=b.filter;T[a]=b.stemmer;return this};f.encode=function(a,b){return H[a](b)};f.prototype.init=function(a,b){this.u=[];if(b){var c=b.preset;a=b}else a||(a=w),c=a.preset;b={};J(a)?(b=Q[a],a={}):c&&(b=Q[c]);if(c=a.worker)if("undefined"===typeof Worker)a.worker=!1,this.l=null;else{var d=parseInt(c,10)||4;this.C=-1;this.s=0;this.j=[];this.F=null;this.l=Array(d);for(var e=0;e<d;e++)this.l[e]=ca(this.id,e,a,
|
||||
y.bind(this))}this.c=a.tokenize||b.c||this.c||w.c;this.D=a.rtl||this.D||w.D;this.async="undefined"===typeof Promise||B(c=a.async)?this.async||w.async:c;this.f=B(c=a.worker)?this.f||w.f:c;this.threshold=B(c=a.threshold)?b.threshold||this.threshold||w.threshold:c;this.depth=B(c=a.depth)?b.depth||this.depth||w.depth:c;this.A=B(c=a.suggest)?this.A||w.A:c;this.v=(c=B(c=a.encode)?b.encode||w.encode:c)&&H[c]&&H[c].bind(H)||(G(c)?c:this.v||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=S[c]||c;b=
|
||||
this.v;d=q();if(c)for(e=0;e<c.length;e++){var g=b?b(c[e]):c[e];d[g]=String.fromCharCode(65E3-c.length+e)}this.filter=c=d}if(c=a.stemmer){var k;b=T[c]||c;d=this.v;e=[];if(b)for(k in b)b.hasOwnProperty(k)&&(g=d?d(k):k,e.push(h("(?=.{"+(g.length+3)+",})"+g+"$"),d?d(b[k]):b[k]));this.stemmer=k=e}this.a=g=(c=a.doc)?c:this.a||w.a;this.h=P(10-(this.threshold||0));this.i=q();this.b=q();if(g){this.g=q();a.doc=null;k=g.index=[];b=g.ref={};d=g.field;e=g.tag;g.id=g.id.split(":");if(e){this.G=q();e.constructor===
|
||||
Array||(g.tag=e=[e]);for(let a=0;a<e.length;a++)this.G[e[a]]=q(),e[a]=e[a].split(":")}if(d)for(d.constructor===Array||(g.field=d=[d]),g=0;g<d.length;g++)b[d[g]]=g,d[g]=d[g].split(":"),k[g]=new f(a),k[g].g=this.g,e&&(k[g].G=this.G)}this.B=!0;this.m=(this.cache=c=B(c=a.cache)?this.cache||w.cache:c)?new da(c):!1;return this};f.prototype.encode=function(a){a&&M.length&&(a=C(a,M));a&&this.u.length&&(a=C(a,this.u));a&&this.v&&(a=this.v(a));a&&this.stemmer&&(a=C(a,this.stemmer));return a};f.prototype.addMatcher=
|
||||
function(a){const b=this.u;for(const c in a)a.hasOwnProperty(c)&&b.push(h(c),a[c]);return this};f.prototype.add=function(a,b,c,d,e){if(this.a&&D(a))return this.w("add",a,b);if(b&&J(b)&&(a||0===a)){var g="@"+a;if(this.b[g]&&!d)return this.update(a,b);if(this.f)return++this.C>=this.l.length&&(this.C=0),this.l[this.C].postMessage({add:!0,id:a,content:b}),this.b[g]=""+this.C,c&&c(),this;if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(a,
|
||||
b,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.c;e=G(c)?c(b):b.split(R);const m=q();m._ctx=q();const n=this.threshold,r=this.depth,t=this.h,v=e.length,L=this.D;for(let b=0;b<v;b++){var k=e[b];if(k){var p=k.length,h=(L?b+1:v-b)/v,l="";switch(c){case "reverse":case "both":for(var f=p;--f;)l=k[f]+l,I(t,m,l,a,L?1:(p-f)/p,h,n);l="";case "forward":for(f=0;f<p;f++)l+=k[f],I(t,m,l,a,L?(f+1)/
|
||||
p:1,h,n);break;case "full":for(f=0;f<p;f++){const b=(L?f+1:p-f)/p;for(let c=p;c>f;c--)l=k.substring(f,c),I(t,m,l,a,b,h,n)}break;default:if(p=I(t,m,k,a,1,h,n),r&&1<v&&p>=n)for(p=m._ctx[k]||(m._ctx[k]=q()),k=this.i[k]||(this.i[k]=P(10-(n||0))),h=b-r,l=b+r+1,0>h&&(h=0),l>v&&(l=v);h<l;h++)h!==b&&I(k,p,e[h],a,0,10-(h<b?b-h:h-b),n)}}}this.b[g]=1;this.B=!1}return this};f.prototype.w=function(a,b,c){if(b.constructor===Array)for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.w(a,b[d],c);this.w(a,b[d])}else{const k=
|
||||
this.a.index;var d=this.a.tag,e=this.a.id;let h;for(var g=0;g<e.length;g++)h=(h||b)[e[g]];if(d)for(e=0;e<d.length;e++);if("remove"===a){delete this.g["@"+h];for(let a=0,b=k.length;a<b;a++){if(a===b-1)return k[a].remove(h,c);k[a].remove(h)}}e=this.a.field;for(let f=0,p=e.length;f<p;f++){d=e[f];let l;for(g=0;g<d.length;g++)l=(l||b)[d[g]];this.g["@"+h]=b;d=k[f];g="add"===a?d.add:d.update;if(f===p-1)return g.call(d,h,l,c);g.call(d,h,l)}}};f.prototype.update=function(a,b,c){if(this.a&&D(a))return this.w("update",
|
||||
a,b);this.b["@"+a]&&J(b)&&(this.remove(a),this.add(a,b,c,!0));return this};f.prototype.remove=function(a,b,c){if(this.a&&D(a))return this.w("remove",a,b);var d="@"+a;if(this.b[d]){if(this.f)return this.l[this.b[d]].postMessage({remove:!0,id:a}),delete this.b[d],b&&b(),this;if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),
|
||||
b(),this}for(b=0;b<10-(this.threshold||0);b++)N(this.h[b],a);this.depth&&N(this.i,a);delete this.b[d];this.B=!1}return this};let z;f.prototype.search=function(a,b,c,d){if(D(b)){if(b.constructor===Array)for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let g=a;let h,f=[];if(D(a)&&a.constructor!==Array){(c=a.callback||b)&&(g.callback=null);var r=a.boost;var l=a.where;h=a.sort;b=a.limit;var m=a.threshold;a=a.query}if(this.a){a=this.a.ref;m=this.a.index;if(l=g.field)g.field=null;else if(g.constructor===
|
||||
Array){var E=g;l=[];for(var n=0;n<g.length;n++)l[n]=g[n].field}else l=Object.keys(a);if(D(l)){l.constructor===Array||(l=[l]);n=l.length;for(var u=0;u<n;u++)E&&(g=E[u]),f[u]=m[a[l[u]]].search(g);return c?c(A(f,h)):this.async?new Promise(function(a){Promise.all(f).then(function(b){a(A(b,h))})}):A(f,h)}return m[a[l]].search(g,c)}m||(m=this.threshold||0);G(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(this.f)for(this.F=c,this.s=0,this.j=[],l=0;l<this.f;l++)this.l[l].postMessage({search:!0,limit:b,threshold:m,content:a});
|
||||
else{if(!d){if(this.async&&"function"!==typeof importScripts){let d=this;a=new Promise(function(a){setTimeout(function(){a(d.search(g,b,null,!0));d=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!J(a))return f;g=a;if(this.cache)if(this.B){if(c=this.m.get(a))return c}else this.m.clear(),this.B=!0;g=this.encode(g);if(!g.length)return f;c=this.c;c=G(c)?c(g):g.split(R);E=c.length;d=!0;e=[];var t=q();if(1<E)if(this.depth){n=!0;var v=c[0];t[v]=1}else c.sort(Y);
|
||||
if(!n||(u=this.i)[v]){let a=0;r&&(m=(m||1)/r,0>r&&(a=m));for(r=n?1:0;r<E;r++){const b=c[r];if(b){if(!t[b]){const c=[];let g=!1,h=0;if(v=n?u[v]:this.h){let d;for(let e=a;e<10-m;e++)if(d=v[e][b])c[h++]=d,g=!0}if(g)e[e.length]=1<h?c.concat.apply([],c):c[0];else if(!this.A){d=!1;break}t[b]=1}v=b}}}else d=!1;d&&(f=aa(e,b,this.g,this.A));l&&(f=this.where(l,null,b,f));h&&(f=A([f],h));this.cache&&this.m.set(a,f);return f}};f.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};f.prototype.where=
|
||||
function(a,b,c,d){const e=d||this.g,g=[];let h=0;var f;let r,l;if(J(a)){if("id"===a)return[e["@"+b]];var m=1;l=[a.split(":")];r=!0}else{if(G(a)){b=d||Object.keys(e);c=b.length;for(f=0;f<c;f++)m=d?d[f]:e[b[f]],a(m)&&(g[h++]=m);return g}c||(c=b);f=Object.keys(a);m=f.length;r=!1;if(1===m&&"id"===f[0])return[e["@"+a.id]];l=Array(m);for(var q=0;q<m;q++)l[q]=f[q].split(":")}q=d||Object.keys(e);const n=q.length;for(let k=0;k<n;k++){const p=d?d[k]:e[q[k]];let n=!0;for(let c=0;c<m;c++){r||(b=a[f[c]]);const d=
|
||||
l[c],e=d.length;let g=p;if(1<e)for(let a=0;a<e;a++)g=g[d[a]];else g=g[d[0]];if(g!==b){n=!1;break}}if(n&&(g[h++]=p,c&&h===c))break}return g};f.prototype.info=function(){if(this.f)for(var a=0;a<this.f;a++)this.l[a].postMessage({info:!0,id:this.id});else{var b=0,c=0,d=0;for(var e=0;e<10-(this.threshold||0);e++){a=Object.keys(this.h[e]);for(let f=0;f<a.length;f++){var g=this.h[e][a[f]].length;b+=1*g+2*a[f].length+4;c+=g;d+=2*a[f].length}}a=Object.keys(this.b);g=a.length;for(e=0;e<g;e++)b+=2*a[e].length+
|
||||
2;return{id:this.id,memory:b,items:g,sequences:c,chars:d,cache:this.cache&&this.cache.o?this.cache.o.length:!1,matcher:M.length+(this.u?this.u.length:0),worker:this.f,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.c}}};f.prototype.clear=function(){return this.destroy().init()};f.prototype.destroy=function(){this.cache&&(this.m.clear(),this.m=null);this.h=this.i=this.b=null;if(this.a){const a=this.g.index;for(let b=0;b<a.length;b++)a.destroy();this.g=null}return this};
|
||||
f.prototype.export=function(){if(this.a){const a=this.a.index,b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=[a[c].h,a[c].i,a[c].b];b[c]=this.g;return JSON.stringify(b)}return JSON.stringify([this.h,this.i,this.b])};f.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.index,c=b.length;for(let d=0;d<c;d++){const e=b[d];e.h=a[d][0];e.i=a[d][1];e.b=a[d][2];e.g=a[c]}this.g=a[c]}else this.h=a[0],this.i=a[1],this.b=a[2],this.g=a[3]};const H={icase:function(a){return a.toLowerCase()},
|
||||
simple:function(){const a=[h("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",h("[\u00e8\u00e9\u00ea\u00eb]"),"e",h("[\u00ec\u00ed\u00ee\u00ef]"),"i",h("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",h("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",h("[\u00fd\u0177\u00ff]"),"y",h("\u00f1"),"n",h("\u00e7"),"c",h("\u00df"),"s",h(" & ")," and ",h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(b){b=C(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[h("ae"),"a",h("ai"),"ei",h("ay"),
|
||||
"ei",h("ey"),"ei",h("oe"),"o",h("ue"),"u",h("ie"),"i",h("sz"),"s",h("zs"),"s",h("sh"),"s",h("ck"),"k",h("cc"),"k",h("dt"),"t",h("ph"),"f",h("pf"),"f",h("ou"),"o",h("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=C(b,a));c||1<b.length&&(b=O(b));return b}}(),extra:function(){const a=[h("p"),"b",h("z"),"s",h("[cgq]"),"k",h("n"),"m",h("d"),"t",h("[vw]"),"f",h("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=
|
||||
0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+C(d.substring(1),a))}b=b.join(" ");b=O(b)}return b}}(),balance:function(){const a=[h("[-/]")," ",h("[^a-z0-9 ]"),"",h("\\s+")," "];return function(b){return O(C(b.toLowerCase(),a))}}()},da=function(){function a(a){this.clear();this.H=!0!==a&&a}a.prototype.clear=function(){this.cache=q();this.count=q();this.index=q();this.o=[]};a.prototype.set=function(a,c){if(this.H&&B(this.cache[a])){let b=this.o.length;if(b===this.H){b--;const a=this.o[b];delete this.cache[a];
|
||||
delete this.count[a];delete this.index[a]}this.index[a]=b;this.o[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.H&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.o;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return a}();return f}(function(){const x={},F="undefined"!==typeof Blob&&"undefined"!==typeof URL&&URL.createObjectURL;
|
||||
return function(f,y,A,K,h){A=F?URL.createObjectURL(new Blob(["("+A.toString()+")()"],{type:"text/javascript"})):f+".min.js";f+="-"+y;x[f]||(x[f]=[]);x[f][h]=new Worker(A);x[f][h].onmessage=K;return x[f][h]}}()),this);
|
||||
|
52
dist/flexsearch.node.js
vendored
52
dist/flexsearch.node.js
vendored
@@ -1,31 +1,33 @@
|
||||
/*
|
||||
FlexSearch v0.4.0
|
||||
FlexSearch v0.5.0
|
||||
Copyright 2019 Nextapps GmbH
|
||||
Author: Thomas Wilkerling
|
||||
Released under the Apache 2.0 Licence
|
||||
https://github.com/nextapps-de/flexsearch
|
||||
*/
|
||||
'use strict';(function(h,w,d){let p;(p=d.define)&&p.amd?p([],function(){return w}):(p=d.modules)?p[h.toLowerCase()]=w:"object"===typeof exports?module.exports=w:d[h]=w})("FlexSearch",function(){function h(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:N++;this.init(a,b);w(this,"index",function(){return this.b});w(this,"length",function(){return Object.keys(this.b).length})}function w(a,b,c){Object.defineProperty(a,b,{get:c})}function d(a){return new RegExp(a,"g")}function p(a,b){for(let c=0;c<b.length;c+=
|
||||
2)a=a.replace(b[c],b[c+1]);return a}function C(a,b,c,f,e,l,g){if(b[c])return b[c];e=e?(9-(g||6))*l+(g||6)*e:l;b[c]=e;e>=g&&(a=a[9-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=f);return e}function G(a,b){if(a){const c=Object.keys(a);for(let f=0,e=c.length;f<e;f++){const e=c[f],g=a[e];if(g)for(let c=0,f=g.length;c<f;c++)if(g[c]===b){1===f?delete a[e]:g.splice(c,1);break}else x(g[c])&&G(g[c],b)}}}function H(a){let b="",c="";var f="";for(let e=0;e<a.length;e++){const l=a[e];if(l!==c)if(e&&"h"===l){if(f="a"===
|
||||
f||"e"===f||"i"===f||"o"===f||"u"===f||"y"===f,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&f||" "===c)b+=l}else b+=l;f=e===a.length-1?"":a[e+1];c=l}return b}function O(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function P(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function Q(a,b,c,f){let e=[],l;const g=a.length;if(1<g){a.sort(P);const n=u();let k=a[0],r=k.length,q=0;for(;q<r;)n["@"+k[q++]]=1;let m,h=0,v=0;for(;++v<g;){let y=!1;const p=v===g-1;l=[];k=a[v];r=k.length;for(q=0;q<r;){m=
|
||||
k[q++];var d="@"+m;if(n[d]){const a=n[d];if(a===v){if(p){if(e[h++]=c?c[d]:m,b&&h===b)return e}else n[d]=v+1;y=!0}else f&&(d=l[a]||(l[a]=[]),d[d.length]=m)}}if(!y&&!f)break}if(f&&(h=e.length,(v=l.length)&&(!b||h<b)))for(;v--;)if(m=l[v])for(q=0,r=m.length;q<r;q++)if(e[h++]=c?c["@"+m[q]]:m[q],b&&h===b)return e}else if(g)if(c)for(a=a[0],f=a.length,b&&b<f&&(f=b),e=Array(f),b=0;b<f;b++)e[b]=c["@"+a[b]];else e=a[0],b&&e.length>b&&(e=e.slice(0,b));return e}function D(a){return"string"===typeof a}function E(a){return"function"===
|
||||
typeof a}function x(a){return"object"===typeof a}function z(a){return"undefined"===typeof a}function I(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=u();return b}function u(){return Object.create(null)}const t={encode:"icase",c:"forward",s:!1,cache:!1,async:!1,A:!1,v:!1,threshold:0,depth:0,a:!1},J={memory:{encode:"extra",c:"strict",threshold:7},speed:{encode:"icase",c:"strict",threshold:7,depth:2},match:{encode:"extra",c:"full"},score:{encode:"extra",c:"strict",threshold:5,depth:4},balance:{encode:"balance",
|
||||
c:"strict",threshold:6,depth:3},fastest:{encode:"icase",c:"strict",threshold:9,depth:1}},F=[];let N=0;const K=d("\\W+"),L={},M={};h.create=function(a){return new h(a)};h.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&F.push(d(b),a[b]);return this};h.registerEncoder=function(a,b){B[a]=b.bind(B);return this};h.registerLanguage=function(a,b){L[a]=b.filter;M[a]=b.stemmer;return this};h.encode=function(a,b){return B[a](b)};h.prototype.init=function(a,b){this.l=[];if(b){var c=b.preset;
|
||||
a=b}else a||(a=t),c=a.preset;b={};D(a)?(b=J[a],a={}):c&&(b=J[c]);this.c=a.tokenize||b.c||this.c||t.c;this.v=a.rtl||this.v||t.v;this.async="undefined"===typeof Promise||z(c=a.async)?this.async||t.async:c;this.threshold=z(c=a.threshold)?b.threshold||this.threshold||t.threshold:c;this.depth=z(c=a.depth)?b.depth||this.depth||t.depth:c;this.s=z(c=a.suggest)?this.s||t.s:c;this.m=(c=z(c=a.encode)?b.encode||t.encode:c)&&B[c]&&B[c].bind(B)||(E(c)?c:this.m||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=
|
||||
L[c]||c;b=this.m;var f=u();if(c)for(var e=0;e<c.length;e++){var l=b?b(c[e]):c[e];f[l]=String.fromCharCode(65E3-c.length+e)}this.filter=c=f}if(c=a.stemmer){var g;b=M[c]||c;f=this.m;e=[];if(b)for(g in b)b.hasOwnProperty(g)&&(l=f?f(g):g,e.push(d("(?=.{"+(l.length+3)+",})"+l+"$"),f?f(b[g]):b[g]));this.stemmer=g=e}this.a=e=(c=a.doc)?c:this.a||t.a;this.g=I(10-(this.threshold||0));this.h=u();this.b=u();this.f=e&&u();if(e)if(a.doc=null,g=e.field,b=e.index=[],f=e.ref={},e.id=e.id.split(":"),g.constructor===
|
||||
Array)for(e=0;e<g.length;e++)f[g[e]]=e,g[e]=g[e].split(":"),b[e]=new h(a),b[e].f=this.f;else f[g]=0,e.field=[g.split(":")],b[0]=new h(a),b[0].f=this.f;this.u=!0;this.j=(this.cache=c=z(c=a.cache)?this.cache||t.cache:c)?new R(c):!1;return this};h.prototype.encode=function(a){a&&F.length&&(a=p(a,F));a&&this.l.length&&(a=p(a,this.l));a&&this.m&&(a=this.m(a));a&&this.stemmer&&(a=p(a,this.stemmer));return a};h.prototype.addMatcher=function(a){const b=this.l;for(const c in a)a.hasOwnProperty(c)&&b.push(d(c),
|
||||
a[c]);return this};h.prototype.add=function(a,b,c,f,e){if(this.a&&x(a))return this.o("add",a,b);if(b&&D(b)&&(a||0===a)){var l="@"+a;if(this.b[l]&&!f)return this.update(a,b);if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;l=new Promise(function(c){setTimeout(function(){e.add(a,b,null,f,!0);e=null;c()})});if(c)l.then(c);else return l;return this}if(c)return this.add(a,b,null,f,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.c;e=E(c)?c(b):b.split(K);const r=u();r._ctx=
|
||||
u();const m=this.threshold,p=this.depth,v=this.g,A=e.length,y=this.v;for(let b=0;b<A;b++){var g=e[b];if(g){var d=g.length,n=(y?b+1:A-b)/A,k="";switch(c){case "reverse":case "both":for(var h=d;--h;)k=g[h]+k,C(v,r,k,a,y?1:(d-h)/d,n,m);k="";case "forward":for(h=0;h<d;h++)k+=g[h],C(v,r,k,a,y?(h+1)/d:1,n,m);break;case "full":for(h=0;h<d;h++){const b=(y?h+1:d-h)/d;for(let c=d;c>h;c--)k=g.substring(h,c),C(v,r,k,a,b,n,m)}break;default:if(d=C(v,r,g,a,1,n,m),p&&1<A&&d>=m)for(d=r._ctx[g]||(r._ctx[g]=u()),g=
|
||||
this.h[g]||(this.h[g]=I(10-(m||0))),n=b-p,k=b+p+1,0>n&&(n=0),k>A&&(k=A);n<k;n++)n!==b&&C(g,d,e[n],a,0,10-(n<b?b-n:n-b),m)}}}this.b[l]=1;this.u=!1}return this};h.prototype.o=function(a,b,c){if(b.constructor===Array)for(let e=0,f=b.length;e<f;e++){if(e===f-1)return this.o(a,b[e],c);this.o(a,b[e])}else{const d=this.a.index;let g=this.a.id,h;for(var f=0;f<g.length;f++)h=(h||b)[g[f]];if("remove"===a){delete this.f["@"+h];for(let a=0,b=d.length;a<b;a++){if(a===b-1)return d[a].remove(h,c);d[a].remove(h)}}g=
|
||||
this.a.field;for(let l=0,k=g.length;l<k;l++){f=g[l];let r;for(var e=0;e<f.length;e++)r=(r||b)[f[e]];this.f["@"+h]=b;f=d[l];e="add"===a?f.add:f.update;if(l===k-1)return e.call(f,h,r,c);e.call(f,h,r)}}};h.prototype.update=function(a,b,c){if(this.a&&x(a))return this.o("update",a,b);this.b["@"+a]&&D(b)&&(this.remove(a),this.add(a,b,c,!0));return this};h.prototype.remove=function(a,b,c){if(this.a&&x(a))return this.o("remove",a,b);var f="@"+a;if(this.b[f]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=
|
||||
this;f=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=null;b()})});if(b)f.then(b);else return f;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)G(this.g[b],a);this.depth&&G(this.h,a);delete this.b[f];this.u=!1}return this};h.prototype.search=function(a,b,c,f){if(x(b)){if(b.constructor===Array)for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let d=a;let g=[];if(x(a)&&a.constructor!==Array){(c=a.callback||b)&&(d.callback=
|
||||
null);b=a.limit;var h=a.threshold;var n=a.boost;a=a.query}if(this.a){a=this.a.ref;h=this.a.index;var k=d.field;if(k)d.field=null;else if(d.constructor===Array){var p=d;k=[];for(var q=0;q<d.length;q++)k[q]=d[q].field}else k=Object.keys(a);if(x(k)){k.constructor===Array||(k=[k]);q=k.length;for(var m=0;m<q;m++)p&&(d=p[m]),g[m]=h[a[k[m]]].search(d);return c?c(g.concat.apply([],g)):this.async?new Promise(function(a){Promise.all(g).then(function(b){a(b.concat.apply([],b))})}):g.concat.apply([],g)}return h[a[k]].search(d,
|
||||
c)}h||(h=this.threshold||0);E(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!f){if(this.async&&"function"!==typeof importScripts){let e=this;a=new Promise(function(a){setTimeout(function(){a(e.search(d,b,null,!0));e=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(d,b,null,!0)),this}if(!a||!D(a))return g;d=a;if(this.cache)if(this.u){if(c=this.j.get(a))return c}else this.j.clear(),this.u=!0;d=this.encode(d);if(!d.length)return g;c=this.c;c=E(c)?c(d):d.split(K);p=c.length;f=!0;e=[];
|
||||
const t=u();1<p&&(this.depth?(k=!0,m=c[0],t[m]=1):c.sort(O));if(!k||(q=this.h)[m]){let a=0;n&&(h=(h||1)/n,0>n&&(a=h));for(n=k?1:0;n<p;n++){const b=c[n];if(b){if(!t[b]){const c=[];let d=!1,g=0;if(m=k?q[m]:this.g){let e;for(let f=a;f<10-h;f++)if(e=m[f][b])c[g++]=e,d=!0}if(d)e[e.length]=1<g?c.concat.apply([],c):c[0];else if(!this.s){f=!1;break}t[b]=1}m=b}}}else f=!1;f&&(g=Q(e,b,this.f,this.s));this.cache&&this.j.set(a,g);return g};h.prototype.info=function(){let a;let b=0,c=0,f=0;for(var e=0;e<10-(this.threshold||
|
||||
0);e++){a=Object.keys(this.g[e]);for(let g=0;g<a.length;g++){var d=this.g[e][a[g]].length;b+=1*d+2*a[g].length+4;c+=d;f+=2*a[g].length}}a=Object.keys(this.b);d=a.length;for(e=0;e<d;e++)b+=2*a[e].length+2;return{id:this.id,memory:b,items:d,sequences:c,chars:f,cache:this.cache&&this.cache.i?this.cache.i.length:!1,matcher:F.length+(this.l?this.l.length:0),worker:this.A,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.c}};h.prototype.clear=function(){return this.destroy().init()};
|
||||
h.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.g=this.h=this.b=null;return this};h.prototype.export=function(){if(this.a){const a=this.a.index,b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=[a[c].g,a[c].h,a[c].b];b[c]=this.f;return JSON.stringify(b)}return JSON.stringify([this.g,this.h,this.b])};h.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.index,c=b.length;for(let d=0;d<c;d++){const e=b[d];e.g=a[d][0];e.h=a[d][1];e.b=a[d][2];e.f=a[c]}this.f=
|
||||
a[c]}else this.g=a[0],this.h=a[1],this.b=a[2],this.f=a[3]};const B={icase:function(a){return a.toLowerCase()},simple:function(){const a=[d("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",d("[\u00e8\u00e9\u00ea\u00eb]"),"e",d("[\u00ec\u00ed\u00ee\u00ef]"),"i",d("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",d("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",d("[\u00fd\u0177\u00ff]"),"y",d("\u00f1"),"n",d("\u00e7"),"c",d("\u00df"),"s",d(" & ")," and ",d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){b=
|
||||
p(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[d("ae"),"a",d("ai"),"ei",d("ay"),"ei",d("ey"),"ei",d("oe"),"o",d("ue"),"u",d("ie"),"i",d("sz"),"s",d("zs"),"s",d("sh"),"s",d("ck"),"k",d("cc"),"k",d("dt"),"t",d("ph"),"f",d("pf"),"f",d("ou"),"o",d("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=p(b,a));c||1<b.length&&(b=H(b));return b}}(),extra:function(){const a=[d("p"),"b",d("z"),"s",d("[cgq]"),"k",d("n"),"m",d("d"),"t",d("[vw]"),"f",d("[aeiouy]"),
|
||||
""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+p(d.substring(1),a))}b=b.join(" ");b=H(b)}return b}}(),balance:function(){const a=[d("[-/]")," ",d("[^a-z0-9 ]"),"",d("\\s+")," "];return function(b){return H(p(b.toLowerCase(),a))}}()},R=function(){function a(a){this.clear();this.w=!0!==a&&a}a.prototype.clear=function(){this.cache=u();this.count=u();this.index=u();this.i=[]};a.prototype.set=function(a,
|
||||
c){if(this.w&&z(this.cache[a])){let b=this.i.length;if(b===this.w){b--;const a=this.i[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.i[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=c};a.prototype.get=function(a){const b=this.cache[a];if(this.w&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.i;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};
|
||||
return a}();return h}(!1),this);
|
||||
'use strict';(function(h,w,C){let f;(f=C.define)&&f.amd?f([],function(){return w}):(f=C.modules)?f[h.toLowerCase()]=w:"object"===typeof exports?module.exports=w:C[h]=w})("FlexSearch",function(){function h(a,b){const c=b?b.id:a&&a.id;this.id=c||0===c?c:R++;this.init(a,b);C(this,"index",function(){return this.b});C(this,"length",function(){return Object.keys(this.b).length})}function w(a,b){a=a.concat.apply([],a);b&&(D(b)||(x=b.split(":"),1<x.length?b=S:(x=x[0],b=T)),a.sort(b));return a}function C(a,
|
||||
b,c){Object.defineProperty(a,b,{get:c})}function f(a){return new RegExp(a,"g")}function y(a,b){for(let c=0;c<b.length;c+=2)a=a.replace(b[c],b[c+1]);return a}function H(a,b,c,d,e,g,l){if(b[c])return b[c];e=e?(9-(l||6))*g+(l||6)*e:g;b[c]=e;e>=l&&(a=a[9-(e+.5>>0)],a=a[c]||(a[c]=[]),a[a.length]=d);return e}function K(a,b){if(a){const c=Object.keys(a);for(let d=0,e=c.length;d<e;d++){const e=c[d],l=a[e];if(l)for(let c=0,d=l.length;c<d;c++)if(l[c]===b){1===d?delete a[e]:l.splice(c,1);break}else z(l[c])&&
|
||||
K(l[c],b)}}}function L(a){let b="",c="";var d="";for(let e=0;e<a.length;e++){const g=a[e];if(g!==c)if(e&&"h"===g){if(d="a"===d||"e"===d||"i"===d||"o"===d||"u"===d||"y"===d,("a"===c||"e"===c||"i"===c||"o"===c||"u"===c||"y"===c)&&d||" "===c)b+=g}else b+=g;d=e===a.length-1?"":a[e+1];c=g}return b}function U(a,b){a=a.length-b.length;return 0>a?1:a?-1:0}function V(a,b){a=a.length-b.length;return 0>a?-1:a?1:0}function T(a,b){a=a[x];b=b[x];return a<b?-1:a>b?1:0}function S(a,b){const c=x.length;for(let d=
|
||||
0;d<c;d++)a=a[x[d]],b=b[x[d]];return a<b?-1:a>b?1:0}function W(a,b,c,d){let e=[],g;const l=a.length;if(1<l){a.sort(V);const f=u();let n=a[0],m=n.length,q=0;for(;q<m;)f["@"+n[q++]]=1;let p,h=0,r=0;for(;++r<l;){let E=!1;const F=r===l-1;g=[];n=a[r];m=n.length;for(q=0;q<m;){p=n[q++];var k="@"+p;if(f[k]){const a=f[k];if(a===r){if(F){if(e[h++]=c?c[k]:p,b&&h===b)return e}else f[k]=r+1;E=!0}else d&&(k=g[a]||(g[a]=[]),k[k.length]=p)}}if(!E&&!d)break}if(d&&(h=e.length,(r=g.length)&&(!b||h<b)))for(;r--;)if(p=
|
||||
g[r])for(q=0,m=p.length;q<m;q++)if(e[h++]=c?c["@"+p[q]]:p[q],b&&h===b)return e}else if(l)if(c)for(a=a[0],d=a.length,b&&b<d&&(d=b),e=Array(d),b=0;b<d;b++)e[b]=c["@"+a[b]];else e=a[0],b&&e.length>b&&(e=e.slice(0,b));return e}function I(a){return"string"===typeof a}function D(a){return"function"===typeof a}function z(a){return"object"===typeof a}function B(a){return"undefined"===typeof a}function M(a){const b=Array(a);for(let c=0;c<a;c++)b[c]=u();return b}function u(){return Object.create(null)}const v=
|
||||
{encode:"icase",c:"forward",s:!1,cache:!1,async:!1,B:!1,v:!1,threshold:0,depth:0,a:!1},N={memory:{encode:"extra",c:"strict",threshold:7},speed:{encode:"icase",c:"strict",threshold:7,depth:2},match:{encode:"extra",c:"full"},score:{encode:"extra",c:"strict",threshold:5,depth:4},balance:{encode:"balance",c:"strict",threshold:6,depth:3},fastest:{encode:"icase",c:"strict",threshold:9,depth:1}},J=[];let R=0;const O=f("\\W+"),P={},Q={};h.create=function(a){return new h(a)};h.registerMatcher=function(a){for(const b in a)a.hasOwnProperty(b)&&
|
||||
J.push(f(b),a[b]);return this};h.registerEncoder=function(a,b){G[a]=b.bind(G);return this};h.registerLanguage=function(a,b){P[a]=b.filter;Q[a]=b.stemmer;return this};h.encode=function(a,b){return G[a](b)};h.prototype.init=function(a,b){this.l=[];if(b){var c=b.preset;a=b}else a||(a=v),c=a.preset;b={};I(a)?(b=N[a],a={}):c&&(b=N[c]);this.c=a.tokenize||b.c||this.c||v.c;this.v=a.rtl||this.v||v.v;this.async="undefined"===typeof Promise||B(c=a.async)?this.async||v.async:c;this.threshold=B(c=a.threshold)?
|
||||
b.threshold||this.threshold||v.threshold:c;this.depth=B(c=a.depth)?b.depth||this.depth||v.depth:c;this.s=B(c=a.suggest)?this.s||v.s:c;this.m=(c=B(c=a.encode)?b.encode||v.encode:c)&&G[c]&&G[c].bind(G)||(D(c)?c:this.m||!1);(c=a.matcher)&&this.addMatcher(c);if(c=a.filter){c=P[c]||c;b=this.m;var d=u();if(c)for(var e=0;e<c.length;e++){var g=b?b(c[e]):c[e];d[g]=String.fromCharCode(65E3-c.length+e)}this.filter=c=d}if(c=a.stemmer){var l;b=Q[c]||c;d=this.m;e=[];if(b)for(l in b)b.hasOwnProperty(l)&&(g=d?d(l):
|
||||
l,e.push(f("(?=.{"+(g.length+3)+",})"+g+"$"),d?d(b[l]):b[l]));this.stemmer=l=e}this.a=g=(c=a.doc)?c:this.a||v.a;this.g=M(10-(this.threshold||0));this.h=u();this.b=u();if(g){this.f=u();a.doc=null;l=g.index=[];b=g.ref={};d=g.field;e=g.tag;g.id=g.id.split(":");if(e){this.w=u();e.constructor===Array||(g.tag=e=[e]);for(let a=0;a<e.length;a++)this.w[e[a]]=u(),e[a]=e[a].split(":")}if(d)for(d.constructor===Array||(g.field=d=[d]),g=0;g<d.length;g++)b[d[g]]=g,d[g]=d[g].split(":"),l[g]=new h(a),l[g].f=this.f,
|
||||
e&&(l[g].w=this.w)}this.u=!0;this.j=(this.cache=c=B(c=a.cache)?this.cache||v.cache:c)?new X(c):!1;return this};h.prototype.encode=function(a){a&&J.length&&(a=y(a,J));a&&this.l.length&&(a=y(a,this.l));a&&this.m&&(a=this.m(a));a&&this.stemmer&&(a=y(a,this.stemmer));return a};h.prototype.addMatcher=function(a){const b=this.l;for(const c in a)a.hasOwnProperty(c)&&b.push(f(c),a[c]);return this};h.prototype.add=function(a,b,c,d,e){if(this.a&&z(a))return this.o("add",a,b);if(b&&I(b)&&(a||0===a)){var g="@"+
|
||||
a;if(this.b[g]&&!d)return this.update(a,b);if(!e){if(this.async&&"function"!==typeof importScripts){let e=this;g=new Promise(function(c){setTimeout(function(){e.add(a,b,null,d,!0);e=null;c()})});if(c)g.then(c);else return g;return this}if(c)return this.add(a,b,null,d,!0),c(),this}b=this.encode(b);if(!b.length)return this;c=this.c;e=D(c)?c(b):b.split(O);const h=u();h._ctx=u();const p=this.threshold,E=this.depth,r=this.g,t=e.length,F=this.v;for(let b=0;b<t;b++){var l=e[b];if(l){var k=l.length,f=(F?
|
||||
b+1:t-b)/t,n="";switch(c){case "reverse":case "both":for(var m=k;--m;)n=l[m]+n,H(r,h,n,a,F?1:(k-m)/k,f,p);n="";case "forward":for(m=0;m<k;m++)n+=l[m],H(r,h,n,a,F?(m+1)/k:1,f,p);break;case "full":for(m=0;m<k;m++){const b=(F?m+1:k-m)/k;for(let c=k;c>m;c--)n=l.substring(m,c),H(r,h,n,a,b,f,p)}break;default:if(k=H(r,h,l,a,1,f,p),E&&1<t&&k>=p)for(k=h._ctx[l]||(h._ctx[l]=u()),l=this.h[l]||(this.h[l]=M(10-(p||0))),f=b-E,n=b+E+1,0>f&&(f=0),n>t&&(n=t);f<n;f++)f!==b&&H(l,k,e[f],a,0,10-(f<b?b-f:f-b),p)}}}this.b[g]=
|
||||
1;this.u=!1}return this};h.prototype.o=function(a,b,c){if(b.constructor===Array)for(let d=0,e=b.length;d<e;d++){if(d===e-1)return this.o(a,b[d],c);this.o(a,b[d])}else{const l=this.a.index;var d=this.a.tag,e=this.a.id;let f;for(var g=0;g<e.length;g++)f=(f||b)[e[g]];if(d)for(e=0;e<d.length;e++);if("remove"===a){delete this.f["@"+f];for(let a=0,b=l.length;a<b;a++){if(a===b-1)return l[a].remove(f,c);l[a].remove(f)}}e=this.a.field;for(let k=0,h=e.length;k<h;k++){d=e[k];let m;for(g=0;g<d.length;g++)m=(m||
|
||||
b)[d[g]];this.f["@"+f]=b;d=l[k];g="add"===a?d.add:d.update;if(k===h-1)return g.call(d,f,m,c);g.call(d,f,m)}}};h.prototype.update=function(a,b,c){if(this.a&&z(a))return this.o("update",a,b);this.b["@"+a]&&I(b)&&(this.remove(a),this.add(a,b,c,!0));return this};h.prototype.remove=function(a,b,c){if(this.a&&z(a))return this.o("remove",a,b);var d="@"+a;if(this.b[d]){if(!c){if(this.async&&"function"!==typeof importScripts){let c=this;d=new Promise(function(b){setTimeout(function(){c.remove(a,null,!0);c=
|
||||
null;b()})});if(b)d.then(b);else return d;return this}if(b)return this.remove(a,null,!0),b(),this}for(b=0;b<10-(this.threshold||0);b++)K(this.g[b],a);this.depth&&K(this.h,a);delete this.b[d];this.u=!1}return this};let x;h.prototype.search=function(a,b,c,d){if(z(b)){if(b.constructor===Array)for(var e=0;e<b.length;e++)b[e].query=a;else b.query=a;a=b;b=0}let g=a;let f,k=[];if(z(a)&&a.constructor!==Array){(c=a.callback||b)&&(g.callback=null);var h=a.boost;var n=a.where;f=a.sort;b=a.limit;var m=a.threshold;
|
||||
a=a.query}if(this.a){a=this.a.ref;m=this.a.index;if(n=g.field)g.field=null;else if(g.constructor===Array){var q=g;n=[];for(var p=0;p<g.length;p++)n[p]=g[p].field}else n=Object.keys(a);if(z(n)){n.constructor===Array||(n=[n]);p=n.length;for(var A=0;A<p;A++)q&&(g=q[A]),k[A]=m[a[n[A]]].search(g);return c?c(w(k,f)):this.async?new Promise(function(a){Promise.all(k).then(function(b){a(w(b,f))})}):w(k,f)}return m[a[n]].search(g,c)}m||(m=this.threshold||0);D(b)?(c=b,b=1E3):b||0===b||(b=1E3);if(!d){if(this.async&&
|
||||
"function"!==typeof importScripts){let d=this;a=new Promise(function(a){setTimeout(function(){a(d.search(g,b,null,!0));d=null})});if(c)a.then(c);else return a;return this}if(c)return c(this.search(g,b,null,!0)),this}if(!a||!I(a))return k;g=a;if(this.cache)if(this.u){if(c=this.j.get(a))return c}else this.j.clear(),this.u=!0;g=this.encode(g);if(!g.length)return k;c=this.c;c=D(c)?c(g):g.split(O);q=c.length;d=!0;e=[];const r=u();if(1<q)if(this.depth){p=!0;var t=c[0];r[t]=1}else c.sort(U);if(!p||(A=this.h)[t]){let a=
|
||||
0;h&&(m=(m||1)/h,0>h&&(a=m));for(h=p?1:0;h<q;h++){const b=c[h];if(b){if(!r[b]){const c=[];let g=!1,f=0;if(t=p?A[t]:this.g){let d;for(let e=a;e<10-m;e++)if(d=t[e][b])c[f++]=d,g=!0}if(g)e[e.length]=1<f?c.concat.apply([],c):c[0];else if(!this.s){d=!1;break}r[b]=1}t=b}}}else d=!1;d&&(k=W(e,b,this.f,this.s));n&&(k=this.where(n,null,b,k));f&&(k=w([k],f));this.cache&&this.j.set(a,k);return k};h.prototype.find=function(a,b){return this.where(a,b,1)[0]||null};h.prototype.where=function(a,b,c,d){const e=d||
|
||||
this.f,g=[];let f=0;var k;let h,n;if(I(a)){if("id"===a)return[e["@"+b]];var m=1;n=[a.split(":")];h=!0}else{if(D(a)){b=d||Object.keys(e);c=b.length;for(k=0;k<c;k++)m=d?d[k]:e[b[k]],a(m)&&(g[f++]=m);return g}c||(c=b);k=Object.keys(a);m=k.length;h=!1;if(1===m&&"id"===k[0])return[e["@"+a.id]];n=Array(m);for(var q=0;q<m;q++)n[q]=k[q].split(":")}q=d||Object.keys(e);const p=q.length;for(let l=0;l<p;l++){const p=d?d[l]:e[q[l]];let t=!0;for(let c=0;c<m;c++){h||(b=a[k[c]]);const d=n[c],e=d.length;let f=p;if(1<
|
||||
e)for(let a=0;a<e;a++)f=f[d[a]];else f=f[d[0]];if(f!==b){t=!1;break}}if(t&&(g[f++]=p,c&&f===c))break}return g};h.prototype.info=function(){let a;let b=0,c=0,d=0;for(var e=0;e<10-(this.threshold||0);e++){a=Object.keys(this.g[e]);for(let g=0;g<a.length;g++){var f=this.g[e][a[g]].length;b+=1*f+2*a[g].length+4;c+=f;d+=2*a[g].length}}a=Object.keys(this.b);f=a.length;for(e=0;e<f;e++)b+=2*a[e].length+2;return{id:this.id,memory:b,items:f,sequences:c,chars:d,cache:this.cache&&this.cache.i?this.cache.i.length:
|
||||
!1,matcher:J.length+(this.l?this.l.length:0),worker:this.B,threshold:this.threshold,depth:this.depth,contextual:this.depth&&"strict"===this.c}};h.prototype.clear=function(){return this.destroy().init()};h.prototype.destroy=function(){this.cache&&(this.j.clear(),this.j=null);this.g=this.h=this.b=null;if(this.a){const a=this.f.index;for(let b=0;b<a.length;b++)a.destroy();this.f=null}return this};h.prototype.export=function(){if(this.a){const a=this.a.index,b=Array(a.length+1);let c=0;for(;c<a.length;c++)b[c]=
|
||||
[a[c].g,a[c].h,a[c].b];b[c]=this.f;return JSON.stringify(b)}return JSON.stringify([this.g,this.h,this.b])};h.prototype.import=function(a){a=JSON.parse(a);if(this.a){const b=this.a.index,c=b.length;for(let d=0;d<c;d++){const e=b[d];e.g=a[d][0];e.h=a[d][1];e.b=a[d][2];e.f=a[c]}this.f=a[c]}else this.g=a[0],this.h=a[1],this.b=a[2],this.f=a[3]};const G={icase:function(a){return a.toLowerCase()},simple:function(){const a=[f("[\u00e0\u00e1\u00e2\u00e3\u00e4\u00e5]"),"a",f("[\u00e8\u00e9\u00ea\u00eb]"),"e",
|
||||
f("[\u00ec\u00ed\u00ee\u00ef]"),"i",f("[\u00f2\u00f3\u00f4\u00f5\u00f6\u0151]"),"o",f("[\u00f9\u00fa\u00fb\u00fc\u0171]"),"u",f("[\u00fd\u0177\u00ff]"),"y",f("\u00f1"),"n",f("\u00e7"),"c",f("\u00df"),"s",f(" & ")," and ",f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){b=y(b.toLowerCase(),a);return" "===b?"":b}}(),advanced:function(){const a=[f("ae"),"a",f("ai"),"ei",f("ay"),"ei",f("ey"),"ei",f("oe"),"o",f("ue"),"u",f("ie"),"i",f("sz"),"s",f("zs"),"s",f("sh"),"s",f("ck"),"k",f("cc"),
|
||||
"k",f("dt"),"t",f("ph"),"f",f("pf"),"f",f("ou"),"o",f("uo"),"u"];return function(b,c){if(!b)return b;b=this.simple(b);2<b.length&&(b=y(b,a));c||1<b.length&&(b=L(b));return b}}(),extra:function(){const a=[f("p"),"b",f("z"),"s",f("[cgq]"),"k",f("n"),"m",f("d"),"t",f("[vw]"),"f",f("[aeiouy]"),""];return function(b){if(!b)return b;b=this.advanced(b,!0);if(1<b.length){b=b.split(" ");for(let c=0;c<b.length;c++){const d=b[c];1<d.length&&(b[c]=d[0]+y(d.substring(1),a))}b=b.join(" ");b=L(b)}return b}}(),balance:function(){const a=
|
||||
[f("[-/]")," ",f("[^a-z0-9 ]"),"",f("\\s+")," "];return function(b){return L(y(b.toLowerCase(),a))}}()},X=function(){function a(a){this.clear();this.A=!0!==a&&a}a.prototype.clear=function(){this.cache=u();this.count=u();this.index=u();this.i=[]};a.prototype.set=function(a,c){if(this.A&&B(this.cache[a])){let b=this.i.length;if(b===this.A){b--;const a=this.i[b];delete this.cache[a];delete this.count[a];delete this.index[a]}this.index[a]=b;this.i[b]=a;this.count[a]=-1;this.cache[a]=c;this.get(a)}else this.cache[a]=
|
||||
c};a.prototype.get=function(a){const b=this.cache[a];if(this.A&&b){var d=++this.count[a];const b=this.index;let c=b[a];if(0<c){const f=this.i;for(var e=c;this.count[f[--c]]<=d&&-1!==c;);c++;if(c!==e){for(d=e;d>c;d--)e=f[d-1],f[d]=e,b[e]=d;f[c]=a;b[a]=c}}}return b};return a}();return h}(!1),this);
|
||||
|
307
flexsearch.js
307
flexsearch.js
@@ -1,5 +1,5 @@
|
||||
/**!
|
||||
* @preserve FlexSearch v0.4.0
|
||||
* @preserve FlexSearch v0.5.0
|
||||
* Copyright 2019 Nextapps GmbH
|
||||
* Author: Thomas Wilkerling
|
||||
* Released under the Apache 2.0 Licence
|
||||
@@ -18,6 +18,7 @@
|
||||
/** @define {boolean} */ const SUPPORT_SERIALIZE = true;
|
||||
/** @define {boolean} */ const SUPPORT_INFO = true;
|
||||
/** @define {boolean} */ const SUPPORT_DOCUMENTS = true;
|
||||
/** @define {boolean} */ const SUPPORT_WHERE = true;
|
||||
|
||||
// noinspection ThisExpressionReferencesGlobalObjectJS
|
||||
(function(){
|
||||
@@ -494,7 +495,10 @@
|
||||
|
||||
let doc;
|
||||
|
||||
if(SUPPORT_DOCUMENTS) /** @private */ this.doc = doc = (
|
||||
if(SUPPORT_DOCUMENTS) {
|
||||
|
||||
/** @private */
|
||||
this.doc = doc = (
|
||||
|
||||
(custom = options["doc"]) ?
|
||||
|
||||
@@ -502,6 +506,7 @@
|
||||
:
|
||||
this.doc || defaults.doc
|
||||
);
|
||||
}
|
||||
|
||||
// initialize primary index
|
||||
|
||||
@@ -512,28 +517,43 @@
|
||||
/** @private */
|
||||
this._ids = create_object();
|
||||
|
||||
if(SUPPORT_DOCUMENTS){
|
||||
|
||||
/** @private */
|
||||
this._doc = doc && create_object();
|
||||
}
|
||||
|
||||
/** @private */
|
||||
//this._stack = create_object();
|
||||
/** @private */
|
||||
//this._stack_keys = [];
|
||||
|
||||
if(doc){
|
||||
|
||||
this._doc = create_object();
|
||||
|
||||
options["doc"] = null;
|
||||
|
||||
const field = doc["field"];
|
||||
const index = doc["index"] = [];
|
||||
const ref = doc["ref"] = {};
|
||||
|
||||
let field = doc["field"];
|
||||
let tag = doc["tag"];
|
||||
|
||||
doc["id"] = doc["id"].split(":");
|
||||
|
||||
if(is_array(field)){
|
||||
if(SUPPORT_WHERE && tag){
|
||||
|
||||
this._tag = create_object();
|
||||
|
||||
if(!is_array(tag)){
|
||||
|
||||
doc["tag"] = tag = [tag];
|
||||
}
|
||||
|
||||
for(let i = 0; i < tag.length; i++){
|
||||
|
||||
this._tag[tag[i]] = create_object();
|
||||
|
||||
tag[i] = tag[i].split(":");
|
||||
}
|
||||
}
|
||||
|
||||
if(field){
|
||||
|
||||
if(!is_array(field)){
|
||||
|
||||
doc["field"] = field = [field];
|
||||
}
|
||||
|
||||
for(let i = 0; i < field.length; i++){
|
||||
|
||||
@@ -541,14 +561,12 @@
|
||||
field[i] = field[i].split(":");
|
||||
index[i] = new FlexSearch(options);
|
||||
index[i]._doc = this._doc;
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
ref[field] = 0;
|
||||
doc["field"] = [field.split(":")];
|
||||
index[0] = new FlexSearch(options);
|
||||
index[0]._doc = this._doc;
|
||||
if(SUPPORT_WHERE && tag){
|
||||
|
||||
index[i]._tag = this._tag;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -992,14 +1010,24 @@
|
||||
else{
|
||||
|
||||
const index = this.doc["index"];
|
||||
const tags = this.doc["tag"];
|
||||
let tree = this.doc["id"];
|
||||
let id;
|
||||
let tag;
|
||||
|
||||
for(let i = 0; i < tree.length; i++){
|
||||
|
||||
id = (id || docs)[tree[i]];
|
||||
}
|
||||
|
||||
if(tags){
|
||||
|
||||
for(let i = 0; i < tags.length; i++){
|
||||
|
||||
tag = (tag || docs)[tags[i]];
|
||||
}
|
||||
}
|
||||
|
||||
if(job === "remove"){
|
||||
|
||||
delete this._doc["@" + id];
|
||||
@@ -1197,6 +1225,37 @@
|
||||
return this;
|
||||
};
|
||||
|
||||
let field_to_sort;
|
||||
|
||||
// TODO: apply intersect here
|
||||
|
||||
function merge_and_sort(arrays, sort){
|
||||
|
||||
arrays = arrays.concat.apply([], arrays);
|
||||
|
||||
if(sort){
|
||||
|
||||
if(!is_function(sort)){
|
||||
|
||||
field_to_sort = sort.split(":");
|
||||
|
||||
if(field_to_sort.length > 1){
|
||||
|
||||
sort = sort_by_deep_field_up;
|
||||
}
|
||||
else{
|
||||
|
||||
field_to_sort = field_to_sort[0];
|
||||
sort = sort_by_field_up;
|
||||
}
|
||||
}
|
||||
|
||||
arrays.sort(sort);
|
||||
}
|
||||
|
||||
return arrays;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!string|Object|Array<Object>} query
|
||||
* @param {number|Function=} limit
|
||||
@@ -1229,6 +1288,8 @@
|
||||
let _query = query;
|
||||
let threshold;
|
||||
let boost;
|
||||
let where;
|
||||
let sort;
|
||||
let result = [];
|
||||
|
||||
if(is_object(query) && (!SUPPORT_DOCUMENTS || !is_array(query))){
|
||||
@@ -1245,9 +1306,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
if(SUPPORT_DOCUMENTS){
|
||||
|
||||
boost = query["boost"];
|
||||
where = query["where"];
|
||||
sort = query["sort"];
|
||||
}
|
||||
|
||||
limit = query["limit"];
|
||||
threshold = query["threshold"];
|
||||
boost = query["boost"];
|
||||
query = query["query"];
|
||||
}
|
||||
|
||||
@@ -1303,7 +1370,7 @@
|
||||
|
||||
if(SUPPORT_ASYNC && callback){
|
||||
|
||||
return callback(result.concat.apply([], result));
|
||||
return callback(merge_and_sort(result, sort));
|
||||
}
|
||||
else if(SUPPORT_ASYNC && this.async){
|
||||
|
||||
@@ -1311,13 +1378,13 @@
|
||||
|
||||
Promise.all(/** @type {!Iterable<Promise>} */ (result)).then(function(values){
|
||||
|
||||
resolve(values.concat.apply([], values));
|
||||
resolve(merge_and_sort(values, sort));
|
||||
});
|
||||
});
|
||||
}
|
||||
else{
|
||||
|
||||
return result.concat.apply([], result);
|
||||
return merge_and_sort(result, sort);
|
||||
}
|
||||
}
|
||||
else{
|
||||
@@ -1579,6 +1646,16 @@
|
||||
//result = intersect_3d(check, limit, this.suggest);
|
||||
}
|
||||
|
||||
if(SUPPORT_WHERE && where){
|
||||
|
||||
result = this.where(where, null, limit, result);
|
||||
}
|
||||
|
||||
if(sort){
|
||||
|
||||
result = merge_and_sort([result], sort);
|
||||
}
|
||||
|
||||
// store result to cache
|
||||
|
||||
if(SUPPORT_CACHE && this.cache){
|
||||
@@ -1594,6 +1671,137 @@
|
||||
return result;
|
||||
};
|
||||
|
||||
if(SUPPORT_DOCUMENTS && SUPPORT_WHERE){
|
||||
|
||||
/**
|
||||
* @export
|
||||
*/
|
||||
|
||||
FlexSearch.prototype.find = function(key, value){
|
||||
|
||||
return this.where(key, value, 1)[0] || null;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* @param value
|
||||
* @param limit
|
||||
* @param {Array<Object>=} result
|
||||
* @returns {Array<Object>}
|
||||
* @export
|
||||
*/
|
||||
|
||||
FlexSearch.prototype.where = function(key, value, limit, result){
|
||||
|
||||
const doc = result || this._doc;
|
||||
const results = [];
|
||||
|
||||
let count = 0;
|
||||
let keys;
|
||||
let keys_len;
|
||||
let has_value;
|
||||
let tree;
|
||||
|
||||
if(is_string(key)){
|
||||
|
||||
if(key === "id"){
|
||||
|
||||
return [doc["@" + value]];
|
||||
}
|
||||
|
||||
//keys = [key];
|
||||
keys_len = 1;
|
||||
tree = [key.split(":")];
|
||||
has_value = true;
|
||||
}
|
||||
else if(is_function(key)){
|
||||
|
||||
const ids = result || get_keys(doc);
|
||||
const length = ids.length;
|
||||
|
||||
for(let x = 0; x < length; x++){
|
||||
|
||||
const obj = result ? result[x] : doc[ids[x]];
|
||||
|
||||
if(key(obj)){
|
||||
|
||||
results[count++] = obj;
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
else{
|
||||
|
||||
limit || (limit = value);
|
||||
keys = get_keys(key);
|
||||
keys_len = keys.length;
|
||||
has_value = false;
|
||||
|
||||
if((keys_len === 1) && (keys[0] === "id")){
|
||||
|
||||
return [doc["@" + key["id"]]];
|
||||
}
|
||||
|
||||
tree = new Array(keys_len);
|
||||
|
||||
for(let i = 0; i < keys_len; i++){
|
||||
|
||||
tree[i] = keys[i].split(":");
|
||||
}
|
||||
}
|
||||
|
||||
const ids = result || get_keys(doc); // this._ids;
|
||||
const length = ids.length;
|
||||
|
||||
for(let x = 0; x < length; x++){
|
||||
|
||||
const obj = result ? result[x] : doc[ids[x]];
|
||||
let found = true;
|
||||
|
||||
for(let i = 0; i < keys_len; i++){
|
||||
|
||||
has_value || (value = key[keys[i]]);
|
||||
|
||||
const tree_cur = tree[i];
|
||||
const tree_len = tree_cur.length;
|
||||
|
||||
let ref = obj;
|
||||
|
||||
if(tree_len > 1){
|
||||
|
||||
for(let z = 0; z < tree_len; z++){
|
||||
|
||||
ref = ref[tree_cur[z]];
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
ref = ref[tree_cur[0]];
|
||||
}
|
||||
|
||||
if(ref !== value){
|
||||
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(found){
|
||||
|
||||
results[count++] = obj;
|
||||
|
||||
if(limit && (count === limit)){
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
if(SUPPORT_INFO){
|
||||
|
||||
/**
|
||||
@@ -1704,6 +1912,7 @@
|
||||
if(SUPPORT_SERIALIZE){
|
||||
|
||||
/**
|
||||
* TODO: also export settings?
|
||||
* @export
|
||||
*/
|
||||
|
||||
@@ -2592,6 +2801,51 @@
|
||||
);
|
||||
}
|
||||
|
||||
function sort_by_field_up(a, b){
|
||||
|
||||
a = a[field_to_sort];
|
||||
b = b[field_to_sort];
|
||||
|
||||
return (
|
||||
|
||||
a < b ?
|
||||
|
||||
-1
|
||||
:(
|
||||
a > b ?
|
||||
|
||||
1
|
||||
:
|
||||
0
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function sort_by_deep_field_up(a, b){
|
||||
|
||||
const field_len = field_to_sort.length;
|
||||
|
||||
for(let i = 0; i < field_len; i++){
|
||||
|
||||
a = a[field_to_sort[i]];
|
||||
b = b[field_to_sort[i]];
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
a < b ?
|
||||
|
||||
-1
|
||||
:(
|
||||
a > b ?
|
||||
|
||||
1
|
||||
:
|
||||
0
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Array<Array<number|string>>} arrays
|
||||
* @param {number=} limit
|
||||
@@ -3269,6 +3523,7 @@
|
||||
"var SUPPORT_SERIALIZE = " + (SUPPORT_SERIALIZE ? "true" : "false") + ";" +
|
||||
"var SUPPORT_INFO = " + (SUPPORT_INFO ? "true" : "false") + ";" +
|
||||
"var SUPPORT_DOCUMENTS = " + (SUPPORT_DOCUMENTS ? "true" : "false") + ";" +
|
||||
"var SUPPORT_WHERE = " + (SUPPORT_WHERE ? "true" : "false") + ";" +
|
||||
"var SUPPORT_WORKER = true;"
|
||||
|
||||
) + "(" + _worker.toString() + ")()"
|
||||
|
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "flexsearch",
|
||||
"version": "0.4.0",
|
||||
"version": "0.5.0",
|
||||
"description": "Next-Generation full text search library with zero dependencies.",
|
||||
"homepage": "https://github.com/nextapps-de/flexsearch/",
|
||||
"author": "Thomas Wilkerling",
|
||||
@@ -26,12 +26,12 @@
|
||||
"url": "https://github.com/nextapps-de/flexsearch.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node compile RELEASE=min DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENTS=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-light": "node compile RELEASE=light DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENTS=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-compact": "node compile RELEASE=compact DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=false SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENTS=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-custom": "node compile RELEASE=custom DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENTS=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-es5": "node compile RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENTS=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT",
|
||||
"build-node": "node compile RELEASE=node DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENTS=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build": "node compile RELEASE=min DEBUG=false PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENTS=true SUPPORT_WHERE=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-light": "node compile RELEASE=light DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENTS=false SUPPORT_WHERE=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-compact": "node compile RELEASE=compact DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=false SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENTS=true SUPPORT_WHERE=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-custom": "node compile RELEASE=custom DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=false SUPPORT_CACHE=false SUPPORT_ASYNC=false SUPPORT_PRESETS=false SUPPORT_SUGGESTIONS=false SUPPORT_SERIALIZE=false SUPPORT_INFO=false SUPPORT_DOCUMENTS=false SUPPORT_WHERE=false SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-es5": "node compile RELEASE=es5 DEBUG=true PROFILER=false SUPPORT_WORKER=true SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENTS=true SUPPORT_WHERE=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false LANGUAGE_OUT=ECMASCRIPT5_STRICT",
|
||||
"build-node": "node compile RELEASE=node DEBUG=false PROFILER=false SUPPORT_WORKER=false SUPPORT_ENCODER=true SUPPORT_CACHE=true SUPPORT_ASYNC=true SUPPORT_PRESETS=true SUPPORT_SUGGESTIONS=true SUPPORT_SERIALIZE=true SUPPORT_INFO=true SUPPORT_DOCUMENTS=true SUPPORT_WHERE=true SUPPORT_LANG_DE=false SUPPORT_LANG_EN=false",
|
||||
"build-lang": "node compile RELEASE=lang",
|
||||
"build-all": "npm run build && npm run build-light && npm run build-compact && npm run build-es5 && npm run build-node && npm run build-lang",
|
||||
"test-production": "nyc --reporter=html --reporter=text mocha --timeout=3000 test --exit",
|
||||
|
@@ -13,41 +13,41 @@ module.exports = function(FlexSearch, env){
|
||||
|
||||
var data = [{
|
||||
|
||||
id: 2,
|
||||
data:{
|
||||
id: 0,
|
||||
title: "Title 1",
|
||||
body: "Body 1"
|
||||
title: "Title 3",
|
||||
body: "Body 3"
|
||||
}
|
||||
},{
|
||||
data:{
|
||||
id: 1,
|
||||
data:{
|
||||
title: "Title 2",
|
||||
body: "Body 2"
|
||||
}
|
||||
},{
|
||||
id: 0,
|
||||
data:{
|
||||
id: 2,
|
||||
title: "Title 3",
|
||||
body: "Body 3"
|
||||
title: "Title 1",
|
||||
body: "Body 1"
|
||||
}
|
||||
}];
|
||||
|
||||
var update = [{
|
||||
|
||||
data:{
|
||||
id: 0,
|
||||
data:{
|
||||
title: "Foo 1",
|
||||
body: "Bar 1"
|
||||
}
|
||||
},{
|
||||
data:{
|
||||
id: 1,
|
||||
data:{
|
||||
title: "Foo 2",
|
||||
body: "Bar 2"
|
||||
}
|
||||
},{
|
||||
data:{
|
||||
id: 2,
|
||||
data:{
|
||||
title: "Foo 3",
|
||||
body: "Bar 3"
|
||||
}
|
||||
@@ -59,7 +59,7 @@ module.exports = function(FlexSearch, env){
|
||||
|
||||
doc: {
|
||||
|
||||
id: "data:id",
|
||||
id: "id",
|
||||
field: [
|
||||
"data:title",
|
||||
"data:body"
|
||||
@@ -200,7 +200,7 @@ module.exports = function(FlexSearch, env){
|
||||
async: true,
|
||||
doc: {
|
||||
|
||||
id: "data:id",
|
||||
id: "id",
|
||||
field: [
|
||||
"data:title",
|
||||
"data:body"
|
||||
@@ -246,7 +246,7 @@ module.exports = function(FlexSearch, env){
|
||||
async: true,
|
||||
doc: {
|
||||
|
||||
id: "data:id",
|
||||
id: "id",
|
||||
field: [
|
||||
"data:title",
|
||||
"data:body"
|
||||
@@ -283,6 +283,69 @@ module.exports = function(FlexSearch, env){
|
||||
expect(await index.doc.index[0].length).to.equal(0);
|
||||
expect(await index.doc.index[1].length).to.equal(0);
|
||||
});
|
||||
|
||||
it("Should have been sorted properly", function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
|
||||
doc: {
|
||||
|
||||
id: "id",
|
||||
field: [
|
||||
"data:title"
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
index.add(data);
|
||||
|
||||
var results = index.search({
|
||||
|
||||
field: "data:title",
|
||||
query: "title"
|
||||
});
|
||||
|
||||
expect(results[0]).to.equal(data[0]);
|
||||
expect(results[1]).to.equal(data[1]);
|
||||
expect(results[2]).to.equal(data[2]);
|
||||
|
||||
results = index.search({
|
||||
|
||||
query: "title",
|
||||
field: "data:title",
|
||||
sort: function(a, b){
|
||||
|
||||
const diff = a.id - b.id;
|
||||
return (diff < 0 ? -1 : (diff ? 1 : 0));
|
||||
}
|
||||
});
|
||||
|
||||
expect(results[0]).to.equal(data[2]);
|
||||
expect(results[1]).to.equal(data[1]);
|
||||
expect(results[2]).to.equal(data[0]);
|
||||
|
||||
results = index.search({
|
||||
|
||||
query: "title",
|
||||
field: "data:title",
|
||||
sort: "id"
|
||||
});
|
||||
|
||||
expect(results[0]).to.equal(data[2]);
|
||||
expect(results[1]).to.equal(data[1]);
|
||||
expect(results[2]).to.equal(data[0]);
|
||||
|
||||
results = index.search({
|
||||
|
||||
query: "title",
|
||||
field: "data:title",
|
||||
sort: "data:title"
|
||||
});
|
||||
|
||||
expect(results[0]).to.equal(data[2]);
|
||||
expect(results[1]).to.equal(data[1]);
|
||||
expect(results[2]).to.equal(data[0]);
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
75
test/test.js
75
test/test.js
@@ -1077,7 +1077,7 @@ describe("Relevance", function(){
|
||||
// Suggestion Tests
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if(env !== "light") describe("Suggestion", function(){
|
||||
if(env !== "light") describe("Suggestions", function(){
|
||||
|
||||
it("Should have been suggested properly by relevance", function(){
|
||||
|
||||
@@ -1100,11 +1100,82 @@ if(env !== "light") describe("Suggestion", function(){
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Where Clause
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if(env === "") describe("Where/Find", function(){
|
||||
|
||||
var data = [{
|
||||
id: 0,
|
||||
title: "Title 1",
|
||||
cat: "1",
|
||||
flag: false
|
||||
},{
|
||||
id: 1,
|
||||
title: "Title 2",
|
||||
cat: "2",
|
||||
flag: false
|
||||
},{
|
||||
id: 2,
|
||||
title: "Title 3",
|
||||
cat: "1",
|
||||
flag: true
|
||||
}];
|
||||
|
||||
it("Should have been found properly", function(){
|
||||
|
||||
var index = new FlexSearch({
|
||||
doc: {
|
||||
id: "id",
|
||||
field: "title",
|
||||
tag: "cat"
|
||||
}
|
||||
});
|
||||
|
||||
index.add(data);
|
||||
|
||||
//expect(index.length).to.equal(3);
|
||||
|
||||
//expect(index.find(0)).to.equal(data[0]);
|
||||
expect(index.find("id", 0)).to.equal(data[0]);
|
||||
expect(index.where("id", 0)).to.have.members([data[0]]);
|
||||
expect(index.find(function(val){return val.id === 0;})).to.equal(data[0]);
|
||||
|
||||
expect(index.find({id: 1})).to.equal(data[1]);
|
||||
expect(index.where({id: 1})).to.have.members([data[1]]);
|
||||
expect(index.where(function(val){return val.id === 1;})).to.have.members([data[1]]);
|
||||
|
||||
expect(index.find({cat: "1"})).to.equal(data[0]);
|
||||
expect(index.find({cat: "2"})).to.equal(data[1]);
|
||||
expect(index.find({cat: "2", flag: true})).to.equal(null);
|
||||
expect(index.find(data[2])).to.equal(data[2]);
|
||||
expect(index.where(data[2])).to.have.members([data[2]]);
|
||||
|
||||
expect(index.where({cat: "1"})).to.have.members([data[0], data[2]]);
|
||||
expect(index.search("title", {sort: "cat"})[1]).to.equal(data[2]);
|
||||
expect(index.search("title")).to.have.members(data);
|
||||
|
||||
expect(index.search("title", {
|
||||
where: {
|
||||
cat: "1"
|
||||
}
|
||||
})).to.have.members([data[0], data[2]]);
|
||||
|
||||
expect(index.search("title", {
|
||||
where: {
|
||||
cat: "1",
|
||||
flag: true
|
||||
}
|
||||
})).to.have.members([data[2]]);
|
||||
});
|
||||
});
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Multi-Field Documents
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if(!this._phantom){
|
||||
if((typeof require !== "undefined") && !this._phantom){
|
||||
|
||||
require("./test.es6.js")(FlexSearch, env);
|
||||
}
|
||||
|
Reference in New Issue
Block a user