mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-08-23 14:13:04 +02:00
v0.8.2
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<body style="white-space: pre">
|
||||
<script type="module">
|
||||
|
||||
import { Index, IndexedDB } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.bundle.module.min.js";
|
||||
import { Index, IndexedDB } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.min.js";
|
||||
|
||||
// create DB instance with namespace
|
||||
const db = new IndexedDB("my-store");
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<body style="white-space: pre">
|
||||
<script type="module">
|
||||
|
||||
import { Index, Resolver } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.bundle.module.min.js";
|
||||
import { Index, Resolver } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.min.js";
|
||||
|
||||
// create a simple index which can store id-content-pairs
|
||||
const index = new Index({
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<body style="white-space: pre">
|
||||
<script type="module">
|
||||
|
||||
import { Index } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.light.module.min.js";
|
||||
import { Index } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.module.min.js";
|
||||
|
||||
// create a simple index which can store id-content-pairs
|
||||
const index = new Index({
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Encoder } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.bundle.module.min.js";
|
||||
import { Encoder } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.min.js";
|
||||
|
||||
export default {
|
||||
tokenize: "forward",
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<body style="white-space: pre">
|
||||
<script type="module">
|
||||
|
||||
//import { Index } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.light.module.min.js";
|
||||
//import { Index } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.light.module.min.js";
|
||||
import Index from "../../../src/index.js";
|
||||
import Resolver from "../../../src/resolver.js";
|
||||
import Encoder from "../../../src/encoder.js";
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<body style="white-space: pre">
|
||||
<script type="module">
|
||||
|
||||
import { Document, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.compact.module.min.js";
|
||||
import { Document, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.module.min.js";
|
||||
|
||||
// some test data
|
||||
const data = [{
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<body style="white-space: pre">
|
||||
<script type="module">
|
||||
|
||||
import { Document, Charset, IndexedDB } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.bundle.module.min.js";
|
||||
import { Document, Charset, IndexedDB } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.min.js";
|
||||
|
||||
// some test data
|
||||
const data = [{
|
||||
|
100
example/browser-module/document-resolver/index.html
Normal file
100
example/browser-module/document-resolver/index.html
Normal file
@@ -0,0 +1,100 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, height=device-height">
|
||||
<title>Example: browser-module-document-resolver</title>
|
||||
</head>
|
||||
<body style="white-space: pre">
|
||||
<script type="module">
|
||||
|
||||
import { Document, Charset, Resolver } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.module.min.js";
|
||||
|
||||
// some test data
|
||||
const data = [{
|
||||
"tconst": "tt0000001",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Carmencita",
|
||||
"originalTitle": "Carmencita",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},{
|
||||
"tconst": "tt0000002",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Le clown et ses chiens",
|
||||
"originalTitle": "Le clown et ses chiens",
|
||||
"isAdult": 0,
|
||||
"startYear": "1892",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "5",
|
||||
"genres": [
|
||||
"Animation",
|
||||
"Short"
|
||||
]
|
||||
}];
|
||||
|
||||
// create the document index
|
||||
const index = new Document({
|
||||
document: {
|
||||
id: "tconst",
|
||||
store: true,
|
||||
index: [{
|
||||
field: "primaryTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinBalance
|
||||
},{
|
||||
field: "originalTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinBalance
|
||||
}],
|
||||
tag: [{
|
||||
field: "startYear"
|
||||
},{
|
||||
field: "genres"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// add test data
|
||||
for(let i = 0; i < data.length; i++){
|
||||
index.add(data[i]);
|
||||
}
|
||||
|
||||
// perform a complex query + enrich results
|
||||
let result = new Resolver({
|
||||
index: index,
|
||||
query: "karmen",
|
||||
pluck: "primaryTitle"
|
||||
}).or({
|
||||
query: "clown",
|
||||
pluck: "primaryTitle"
|
||||
}).and({
|
||||
query: "not found",
|
||||
field: "originalTitle",
|
||||
suggest: true
|
||||
}).not({
|
||||
query: "clown",
|
||||
pluck: "primaryTitle"
|
||||
}).resolve({
|
||||
enrich: true
|
||||
});
|
||||
|
||||
// display results
|
||||
console.log(result);
|
||||
log(JSON.stringify(result, null, 2));
|
||||
log("\n-------------------------------------\n");
|
||||
|
||||
function log(str){
|
||||
document.body.appendChild(
|
||||
document.createTextNode(str + "\n")
|
||||
);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@@ -1,5 +1,5 @@
|
||||
import { Encoder, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.bundle.module.min.js";
|
||||
import EnglishPreset from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/module/lang/en.js";
|
||||
import { Encoder, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.min.js";
|
||||
import EnglishPreset from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/module/lang/en.js";
|
||||
|
||||
export default {
|
||||
tokenize: "forward",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { Encoder, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.bundle.module.min.js";
|
||||
import EnglishPreset from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/module/lang/en.js";
|
||||
import { Encoder, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.bundle.module.min.js";
|
||||
import EnglishPreset from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/module/lang/en.js";
|
||||
|
||||
export default {
|
||||
tokenize: "forward",
|
||||
|
@@ -8,7 +8,7 @@
|
||||
<body style="white-space: pre">
|
||||
<script type="module">
|
||||
|
||||
import { Document, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.compact.module.min.js";
|
||||
import { Document, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.module.min.js";
|
||||
|
||||
// some test data
|
||||
const data = [{
|
||||
|
@@ -8,8 +8,8 @@
|
||||
<body style="white-space: pre">
|
||||
<script type="module">
|
||||
|
||||
import { Index, Encoder, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/flexsearch.compact.module.min.js";
|
||||
import EnglishPreset from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.1/dist/module/lang/en.js";
|
||||
import { Index, Encoder, Charset } from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/flexsearch.compact.module.min.js";
|
||||
import EnglishPreset from "https://cdn.jsdelivr.net/gh/nextapps-de/flexsearch@0.8.2/dist/module/lang/en.js";
|
||||
|
||||
const encoder = new Encoder(
|
||||
Charset.LatinSimple,
|
||||
|
Reference in New Issue
Block a user