mirror of
https://github.com/nextapps-de/flexsearch.git
synced 2025-08-30 09:10:42 +02:00
improve bundle + add examples
This commit is contained in:
49
example/nodejs-document/commonjs/index.js
Normal file
49
example/nodejs-document/commonjs/index.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const { Document, Charset } = require("flexsearch");
|
||||
const fs = require("fs");
|
||||
|
||||
// loading test data
|
||||
const data = JSON.parse(fs.readFileSync(__dirname + "/../data.json", "utf8"));
|
||||
|
||||
// create the document index
|
||||
const document = new Document({
|
||||
document: {
|
||||
id: "tconst",
|
||||
store: true,
|
||||
index: [{
|
||||
field: "primaryTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
},{
|
||||
field: "originalTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
}],
|
||||
tag: [{
|
||||
field: "startYear"
|
||||
},{
|
||||
field: "genres"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// add test data
|
||||
for(let i = 0; i < data.length; i++){
|
||||
document.add(data[i]);
|
||||
}
|
||||
|
||||
// perform a query
|
||||
const result = document.search({
|
||||
query: "carmencita",
|
||||
tag: {
|
||||
"startYear": "1894",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
suggest: true,
|
||||
enrich: true,
|
||||
merge: true
|
||||
});
|
||||
|
||||
console.log(result);
|
3
example/nodejs-document/commonjs/package.json
Normal file
3
example/nodejs-document/commonjs/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
141
example/nodejs-document/data.json
Normal file
141
example/nodejs-document/data.json
Normal file
@@ -0,0 +1,141 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000003",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Pauvre Pierrot",
|
||||
"originalTitle": "Pauvre Pierrot",
|
||||
"isAdult": 0,
|
||||
"startYear": "1892",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "4",
|
||||
"genres": [
|
||||
"Animation",
|
||||
"Comedy",
|
||||
"Romance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000004",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Un bon bock",
|
||||
"originalTitle": "Un bon bock",
|
||||
"isAdult": 0,
|
||||
"startYear": "1892",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "12",
|
||||
"genres": [
|
||||
"Animation",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000005",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Blacksmith Scene",
|
||||
"originalTitle": "Blacksmith Scene",
|
||||
"isAdult": 0,
|
||||
"startYear": "1893",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Comedy",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000006",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Chinese Opium Den",
|
||||
"originalTitle": "Chinese Opium Den",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000007",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Corbett and Courtney Before the Kinetograph",
|
||||
"originalTitle": "Corbett and Courtney Before the Kinetograph",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Short",
|
||||
"Sport"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000008",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Edison Kinetoscopic Record of a Sneeze",
|
||||
"originalTitle": "Edison Kinetoscopic Record of a Sneeze",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000009",
|
||||
"titleType": "movie",
|
||||
"primaryTitle": "Miss Jerry",
|
||||
"originalTitle": "Miss Jerry",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "45",
|
||||
"genres": [
|
||||
"Romance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000010",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Leaving the Factory",
|
||||
"originalTitle": "La sortie de l'usine Lumière à Lyon",
|
||||
"isAdult": 0,
|
||||
"startYear": "1895",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
}
|
||||
]
|
50
example/nodejs-document/esm/index.js
Normal file
50
example/nodejs-document/esm/index.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import { Document, Charset } from "flexsearch/esm";
|
||||
import fs from "fs";
|
||||
|
||||
const dirname = import.meta.dirname;
|
||||
// loading test data
|
||||
const data = JSON.parse(fs.readFileSync(dirname + "/../data.json", "utf8"));
|
||||
|
||||
// create the document index
|
||||
const document = new Document({
|
||||
document: {
|
||||
id: "tconst",
|
||||
store: true,
|
||||
index: [{
|
||||
field: "primaryTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
},{
|
||||
field: "originalTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
}],
|
||||
tag: [{
|
||||
field: "startYear"
|
||||
},{
|
||||
field: "genres"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// add test data
|
||||
for(let i = 0; i < data.length; i++){
|
||||
document.add(data[i]);
|
||||
}
|
||||
|
||||
// perform a query
|
||||
const result = document.search({
|
||||
query: "carmencita",
|
||||
tag: {
|
||||
"startYear": "1894",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
suggest: true,
|
||||
enrich: true,
|
||||
merge: true
|
||||
});
|
||||
|
||||
console.log(result);
|
3
example/nodejs-document/esm/package.json
Normal file
3
example/nodejs-document/esm/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
6
example/nodejs-document/package.json
Normal file
6
example/nodejs-document/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "nodejs-document",
|
||||
"dependencies": {
|
||||
"flexsearch": "github:nextapps-de/flexsearch#v0.8-preview"
|
||||
}
|
||||
}
|
64
example/nodejs-persistent/commonjs/index.js
Normal file
64
example/nodejs-persistent/commonjs/index.js
Normal file
@@ -0,0 +1,64 @@
|
||||
const { Document, Charset } = require("flexsearch");
|
||||
const Postgres = require("flexsearch/db/postgres");
|
||||
const fs = require("fs");
|
||||
|
||||
// loading test data
|
||||
const data = JSON.parse(fs.readFileSync(__dirname + "/../data.json", "utf8"));
|
||||
|
||||
(async function(){
|
||||
|
||||
// create DB instance with namespace
|
||||
const db = new Postgres("my-store");
|
||||
|
||||
// create the document index
|
||||
const document = new Document({
|
||||
document: {
|
||||
id: "tconst",
|
||||
store: true,
|
||||
index: [{
|
||||
field: "primaryTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
},{
|
||||
field: "originalTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
}],
|
||||
tag: [{
|
||||
field: "startYear"
|
||||
},{
|
||||
field: "genres"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
await document.mount(db);
|
||||
await document.destroy();
|
||||
await document.mount(db);
|
||||
|
||||
// add test data
|
||||
for(let i = 0; i < data.length; i++){
|
||||
document.add(data[i]);
|
||||
}
|
||||
|
||||
// transfer changes (bulk)
|
||||
await document.commit();
|
||||
|
||||
// perform a query
|
||||
const result = await document.search({
|
||||
query: "carmencita",
|
||||
tag: {
|
||||
"startYear": "1894",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
suggest: true,
|
||||
enrich: true,
|
||||
merge: true
|
||||
});
|
||||
|
||||
console.log(result);
|
||||
|
||||
}());
|
3
example/nodejs-persistent/commonjs/package.json
Normal file
3
example/nodejs-persistent/commonjs/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
141
example/nodejs-persistent/data.json
Normal file
141
example/nodejs-persistent/data.json
Normal file
@@ -0,0 +1,141 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000003",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Pauvre Pierrot",
|
||||
"originalTitle": "Pauvre Pierrot",
|
||||
"isAdult": 0,
|
||||
"startYear": "1892",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "4",
|
||||
"genres": [
|
||||
"Animation",
|
||||
"Comedy",
|
||||
"Romance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000004",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Un bon bock",
|
||||
"originalTitle": "Un bon bock",
|
||||
"isAdult": 0,
|
||||
"startYear": "1892",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "12",
|
||||
"genres": [
|
||||
"Animation",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000005",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Blacksmith Scene",
|
||||
"originalTitle": "Blacksmith Scene",
|
||||
"isAdult": 0,
|
||||
"startYear": "1893",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Comedy",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000006",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Chinese Opium Den",
|
||||
"originalTitle": "Chinese Opium Den",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000007",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Corbett and Courtney Before the Kinetograph",
|
||||
"originalTitle": "Corbett and Courtney Before the Kinetograph",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Short",
|
||||
"Sport"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000008",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Edison Kinetoscopic Record of a Sneeze",
|
||||
"originalTitle": "Edison Kinetoscopic Record of a Sneeze",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000009",
|
||||
"titleType": "movie",
|
||||
"primaryTitle": "Miss Jerry",
|
||||
"originalTitle": "Miss Jerry",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "45",
|
||||
"genres": [
|
||||
"Romance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000010",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Leaving the Factory",
|
||||
"originalTitle": "La sortie de l'usine Lumière à Lyon",
|
||||
"isAdult": 0,
|
||||
"startYear": "1895",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
}
|
||||
]
|
65
example/nodejs-persistent/esm/index.js
Normal file
65
example/nodejs-persistent/esm/index.js
Normal file
@@ -0,0 +1,65 @@
|
||||
import { Document, Charset } from "flexsearch/esm";
|
||||
import Postgres from "flexsearch/esm/db/postgres";
|
||||
import fs from "fs";
|
||||
|
||||
const dirname = import.meta.dirname;
|
||||
// loading test data
|
||||
const data = JSON.parse(fs.readFileSync(dirname + "/../data.json", "utf8"));
|
||||
|
||||
(async function(){
|
||||
|
||||
// create DB instance with namespace
|
||||
const db = new Postgres("my-store");
|
||||
|
||||
// create the document index
|
||||
const document = new Document({
|
||||
document: {
|
||||
id: "tconst",
|
||||
store: true,
|
||||
index: [{
|
||||
field: "primaryTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
},{
|
||||
field: "originalTitle",
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
}],
|
||||
tag: [{
|
||||
field: "startYear"
|
||||
},{
|
||||
field: "genres"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
await document.mount(db);
|
||||
// await document.destroy();
|
||||
// await document.mount(db);
|
||||
|
||||
// add test data
|
||||
for(let i = 0; i < data.length; i++){
|
||||
document.add(data[i]);
|
||||
}
|
||||
|
||||
// transfer changes (bulk)
|
||||
await document.commit();
|
||||
|
||||
// perform a query
|
||||
const result = await document.search({
|
||||
query: "carmencita",
|
||||
tag: {
|
||||
"startYear": "1894",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
suggest: true,
|
||||
enrich: true,
|
||||
merge: true
|
||||
});
|
||||
|
||||
console.log(result);
|
||||
|
||||
}());
|
3
example/nodejs-persistent/esm/package.json
Normal file
3
example/nodejs-persistent/esm/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
240
example/nodejs-persistent/package-lock.json
generated
Normal file
240
example/nodejs-persistent/package-lock.json
generated
Normal file
@@ -0,0 +1,240 @@
|
||||
{
|
||||
"name": "nodejs-worker-persistent",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nodejs-worker-persistent",
|
||||
"dependencies": {
|
||||
"flexsearch": "github:nextapps-de/flexsearch#v0.8-preview",
|
||||
"pg-promise": "^11.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/assert-options": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/assert-options/-/assert-options-0.8.2.tgz",
|
||||
"integrity": "sha512-XaXoMxY0zuwAb0YuZjxIm8FeWvNq0aWNIbrzHhFjme8Smxw4JlPoyrAKQ6808k5UvQdhvnWqHZCphq5mXd4TDA==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/flexsearch": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "git+ssh://git@github.com/nextapps-de/flexsearch.git#a253897675cdb1361554abdc7f57305a6d52de25",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/pg": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.14.0.tgz",
|
||||
"integrity": "sha512-nXbVpyoaXVmdqlKEzToFf37qzyeeh7mbiXsnoWvstSqohj88yaa/I/Rq/HEVn2QPSZEuLIJa/jSpRDyzjEx4FQ==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"pg-connection-string": "^2.7.0",
|
||||
"pg-pool": "^3.8.0",
|
||||
"pg-protocol": "^1.8.0",
|
||||
"pg-types": "^2.1.0",
|
||||
"pgpass": "1.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"pg-cloudflare": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-native": ">=3.0.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"pg-native": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/pg-cloudflare": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz",
|
||||
"integrity": "sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/pg-connection-string": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.7.0.tgz",
|
||||
"integrity": "sha512-PI2W9mv53rXJQEOb8xNR8lH7Hr+EKa6oJa38zsK0S/ky2er16ios1wLKhZyxzD7jUReiWokc9WK5nxSnC7W1TA=="
|
||||
},
|
||||
"node_modules/pg-cursor": {
|
||||
"version": "2.13.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-cursor/-/pg-cursor-2.13.0.tgz",
|
||||
"integrity": "sha512-13jHi54EawM9aQhmf0+xRtvaL/g4kBjnx/tEXWAIPNKm4bxUofPfc5navrgt47z85AsxUDx4f40IzF1y9tUyeA==",
|
||||
"peer": true,
|
||||
"peerDependencies": {
|
||||
"pg": "^8"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-int8": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
|
||||
"integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==",
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-minify": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-minify/-/pg-minify-1.7.0.tgz",
|
||||
"integrity": "sha512-kFPxAWAhPMvOqnY7klP3scdU5R7bxpAYOm8vGExuIkcSIwuFkZYl4C4XIPQ8DtXY2NzVmAX1aFHpvFSXQ/qQmA==",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-pool": {
|
||||
"version": "3.8.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.8.0.tgz",
|
||||
"integrity": "sha512-VBw3jiVm6ZOdLBTIcXLNdSotb6Iy3uOCwDGFAksZCXmi10nyRvnP2v3jl4d+IsLYRyXf6o9hIm/ZtUzlByNUdw==",
|
||||
"peerDependencies": {
|
||||
"pg": ">=8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-promise": {
|
||||
"version": "11.11.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-11.11.0.tgz",
|
||||
"integrity": "sha512-nqtNHp9dvE1aMug2spLJBy6AazT9arorTlRqreHXu50pCArwQDpbu/R0tDUcyNYY4XP5HczwknkUzYi+ivyozQ==",
|
||||
"dependencies": {
|
||||
"assert-options": "0.8.2",
|
||||
"pg": "8.13.3",
|
||||
"pg-minify": "1.7.0",
|
||||
"spex": "3.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-query-stream": "4.7.3"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-promise/node_modules/pg": {
|
||||
"version": "8.13.3",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.13.3.tgz",
|
||||
"integrity": "sha512-P6tPt9jXbL9HVu/SSRERNYaYG++MjnscnegFh9pPHihfoBSujsrka0hyuymMzeJKFWrcG8wvCKy8rCe8e5nDUQ==",
|
||||
"dependencies": {
|
||||
"pg-connection-string": "^2.7.0",
|
||||
"pg-pool": "^3.7.1",
|
||||
"pg-protocol": "^1.7.1",
|
||||
"pg-types": "^2.1.0",
|
||||
"pgpass": "1.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"pg-cloudflare": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-native": ">=3.0.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"pg-native": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/pg-protocol": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.8.0.tgz",
|
||||
"integrity": "sha512-jvuYlEkL03NRvOoyoRktBK7+qU5kOvlAwvmrH8sr3wbLrOdVWsRxQfz8mMy9sZFsqJ1hEWNfdWKI4SAmoL+j7g=="
|
||||
},
|
||||
"node_modules/pg-query-stream": {
|
||||
"version": "4.7.3",
|
||||
"resolved": "https://registry.npmjs.org/pg-query-stream/-/pg-query-stream-4.7.3.tgz",
|
||||
"integrity": "sha512-WvsdwYXrvIXNZJflX/2MEQLjKs5TopZWeiyam1zcaFfhwQtL19ENOvGdzVsihGsbsNGdVRU5yiqg2G5p06UAbg==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"pg-cursor": "^2.12.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg": "^8"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-types": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
|
||||
"integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
|
||||
"dependencies": {
|
||||
"pg-int8": "1.0.1",
|
||||
"postgres-array": "~2.0.0",
|
||||
"postgres-bytea": "~1.0.0",
|
||||
"postgres-date": "~1.0.4",
|
||||
"postgres-interval": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/pgpass": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz",
|
||||
"integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==",
|
||||
"dependencies": {
|
||||
"split2": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-array": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
|
||||
"integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-bytea": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
|
||||
"integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-date": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
|
||||
"integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-interval": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
|
||||
"integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
|
||||
"dependencies": {
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/spex": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/spex/-/spex-3.4.0.tgz",
|
||||
"integrity": "sha512-8JeZJ7QlEBnSj1W1fKXgbB2KUPA8k4BxFMf6lZX/c1ZagU/1b9uZWZK0yD6yjfzqAIuTNG4YlRmtMpQiXuohsg==",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/split2": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
|
||||
"integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
|
||||
"engines": {
|
||||
"node": ">= 10.x"
|
||||
}
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
example/nodejs-persistent/package.json
Normal file
7
example/nodejs-persistent/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "nodejs-persistent",
|
||||
"dependencies": {
|
||||
"flexsearch": "github:nextapps-de/flexsearch#v0.8-preview",
|
||||
"pg-promise": "^11.11.0"
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
const Postgres = require("flexsearch/db/postgres");
|
||||
|
||||
module.exports = {
|
||||
db: new Postgres("my-store", {
|
||||
field: "genres"
|
||||
})
|
||||
};
|
@@ -0,0 +1,10 @@
|
||||
const Postgres = require("flexsearch/db/postgres");
|
||||
const { Charset } = require("flexsearch");
|
||||
|
||||
module.exports = {
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple,
|
||||
db: new Postgres("my-store", {
|
||||
field: "originalTitle"
|
||||
})
|
||||
};
|
@@ -0,0 +1,10 @@
|
||||
const Postgres = require("flexsearch/db/postgres");
|
||||
const { Charset } = require("flexsearch");
|
||||
|
||||
module.exports = {
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple,
|
||||
db: new Postgres("my-store", {
|
||||
field: "primaryTitle"
|
||||
})
|
||||
};
|
@@ -0,0 +1,7 @@
|
||||
const Postgres = require("flexsearch/db/postgres");
|
||||
|
||||
module.exports = {
|
||||
db: new Postgres("my-store", {
|
||||
field: "startYear"
|
||||
})
|
||||
};
|
65
example/nodejs-worker-persistent/commonjs/index.js
Normal file
65
example/nodejs-worker-persistent/commonjs/index.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const { Document } = require("flexsearch");
|
||||
const Postgres = require("flexsearch/db/postgres");
|
||||
const fs = require("fs");
|
||||
|
||||
// loading test data
|
||||
const data = JSON.parse(fs.readFileSync(__dirname + "/../data.json", "utf8"));
|
||||
|
||||
(async function(){
|
||||
|
||||
// create DB instance with namespace
|
||||
const db = new Postgres("my-store");
|
||||
|
||||
// create the document index
|
||||
const document = new Document({
|
||||
worker: true,
|
||||
document: {
|
||||
id: "tconst",
|
||||
store: true,
|
||||
index: [{
|
||||
field: "primaryTitle",
|
||||
config: __dirname + "/config.primaryTitle.js"
|
||||
},{
|
||||
field: "originalTitle",
|
||||
config: __dirname + "/config.originalTitle.js"
|
||||
}],
|
||||
tag: [{
|
||||
field: "startYear",
|
||||
config: __dirname + "/config.startYear.js"
|
||||
},{
|
||||
field: "genres",
|
||||
config: __dirname + "/config.genres.js"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
await document.mount(db);
|
||||
// await document.destroy();
|
||||
// await document.mount(db);
|
||||
|
||||
// add test data
|
||||
for(let i = 0; i < data.length; i++){
|
||||
document.add(data[i]);
|
||||
}
|
||||
|
||||
// transfer changes (bulk)
|
||||
await document.commit();
|
||||
|
||||
// perform a query
|
||||
const result = await document.search({
|
||||
query: "carmen",
|
||||
tag: {
|
||||
"startYear": "1894",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
suggest: true,
|
||||
enrich: true,
|
||||
merge: true
|
||||
});
|
||||
|
||||
console.log(result);
|
||||
|
||||
}());
|
3
example/nodejs-worker-persistent/commonjs/package.json
Normal file
3
example/nodejs-worker-persistent/commonjs/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
141
example/nodejs-worker-persistent/data.json
Normal file
141
example/nodejs-worker-persistent/data.json
Normal file
@@ -0,0 +1,141 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000003",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Pauvre Pierrot",
|
||||
"originalTitle": "Pauvre Pierrot",
|
||||
"isAdult": 0,
|
||||
"startYear": "1892",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "4",
|
||||
"genres": [
|
||||
"Animation",
|
||||
"Comedy",
|
||||
"Romance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000004",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Un bon bock",
|
||||
"originalTitle": "Un bon bock",
|
||||
"isAdult": 0,
|
||||
"startYear": "1892",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "12",
|
||||
"genres": [
|
||||
"Animation",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000005",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Blacksmith Scene",
|
||||
"originalTitle": "Blacksmith Scene",
|
||||
"isAdult": 0,
|
||||
"startYear": "1893",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Comedy",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000006",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Chinese Opium Den",
|
||||
"originalTitle": "Chinese Opium Den",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000007",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Corbett and Courtney Before the Kinetograph",
|
||||
"originalTitle": "Corbett and Courtney Before the Kinetograph",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Short",
|
||||
"Sport"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000008",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Edison Kinetoscopic Record of a Sneeze",
|
||||
"originalTitle": "Edison Kinetoscopic Record of a Sneeze",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000009",
|
||||
"titleType": "movie",
|
||||
"primaryTitle": "Miss Jerry",
|
||||
"originalTitle": "Miss Jerry",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "45",
|
||||
"genres": [
|
||||
"Romance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000010",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Leaving the Factory",
|
||||
"originalTitle": "La sortie de l'usine Lumière à Lyon",
|
||||
"isAdult": 0,
|
||||
"startYear": "1895",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
}
|
||||
]
|
7
example/nodejs-worker-persistent/esm/config.genres.js
Normal file
7
example/nodejs-worker-persistent/esm/config.genres.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import Postgres from "flexsearch/db/postgres";
|
||||
|
||||
export default {
|
||||
db: new Postgres("my-store", {
|
||||
field: "genres"
|
||||
})
|
||||
};
|
10
example/nodejs-worker-persistent/esm/config.originalTitle.js
Normal file
10
example/nodejs-worker-persistent/esm/config.originalTitle.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import Postgres from "flexsearch/esm/db/postgres";
|
||||
import { Charset } from "flexsearch/esm";
|
||||
|
||||
export default {
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple,
|
||||
db: new Postgres("my-store", {
|
||||
field: "originalTitle"
|
||||
})
|
||||
};
|
10
example/nodejs-worker-persistent/esm/config.primaryTitle.js
Normal file
10
example/nodejs-worker-persistent/esm/config.primaryTitle.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import Postgres from "flexsearch/esm/db/postgres";
|
||||
import { Charset } from "flexsearch/esm";
|
||||
|
||||
export default {
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple,
|
||||
db: new Postgres("my-store", {
|
||||
field: "primaryTitle"
|
||||
})
|
||||
};
|
7
example/nodejs-worker-persistent/esm/config.startYear.js
Normal file
7
example/nodejs-worker-persistent/esm/config.startYear.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import Postgres from "flexsearch/db/postgres";
|
||||
|
||||
export default {
|
||||
db: new Postgres("my-store", {
|
||||
field: "startYear"
|
||||
})
|
||||
};
|
66
example/nodejs-worker-persistent/esm/index.js
Normal file
66
example/nodejs-worker-persistent/esm/index.js
Normal file
@@ -0,0 +1,66 @@
|
||||
import { Document } from "flexsearch/esm";
|
||||
import Postgres from "flexsearch/esm/db/postgres";
|
||||
import fs from "fs";
|
||||
|
||||
const dirname = import.meta.dirname;
|
||||
// loading test data
|
||||
const data = JSON.parse(fs.readFileSync(dirname + "/../data.json", "utf8"));
|
||||
|
||||
(async function(){
|
||||
|
||||
// create DB instance with namespace
|
||||
const db = new Postgres("my-store");
|
||||
|
||||
// create the document index
|
||||
const document = new Document({
|
||||
worker: true,
|
||||
document: {
|
||||
id: "tconst",
|
||||
store: true,
|
||||
index: [{
|
||||
field: "primaryTitle",
|
||||
config: dirname + "/config.primaryTitle.js"
|
||||
},{
|
||||
field: "originalTitle",
|
||||
config: dirname + "/config.originalTitle.js"
|
||||
}],
|
||||
tag: [{
|
||||
field: "startYear",
|
||||
config: dirname + "/config.startYear.js"
|
||||
},{
|
||||
field: "genres",
|
||||
config: dirname + "/config.genres.js"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
await document.mount(db);
|
||||
// await document.destroy();
|
||||
// await document.mount(db);
|
||||
|
||||
// add test data
|
||||
for(let i = 0; i < data.length; i++){
|
||||
document.add(data[i]);
|
||||
}
|
||||
|
||||
// transfer changes (bulk)
|
||||
await document.commit();
|
||||
|
||||
// perform a query
|
||||
const result = await document.search({
|
||||
query: "carmen",
|
||||
tag: {
|
||||
"startYear": "1894",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
suggest: true,
|
||||
enrich: true,
|
||||
merge: true
|
||||
});
|
||||
|
||||
console.log(result);
|
||||
|
||||
}());
|
3
example/nodejs-worker-persistent/esm/package.json
Normal file
3
example/nodejs-worker-persistent/esm/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
240
example/nodejs-worker-persistent/package-lock.json
generated
Normal file
240
example/nodejs-worker-persistent/package-lock.json
generated
Normal file
@@ -0,0 +1,240 @@
|
||||
{
|
||||
"name": "nodejs-worker-persistent",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nodejs-worker-persistent",
|
||||
"dependencies": {
|
||||
"flexsearch": "github:nextapps-de/flexsearch#v0.8-preview",
|
||||
"pg-promise": "^11.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/assert-options": {
|
||||
"version": "0.8.2",
|
||||
"resolved": "https://registry.npmjs.org/assert-options/-/assert-options-0.8.2.tgz",
|
||||
"integrity": "sha512-XaXoMxY0zuwAb0YuZjxIm8FeWvNq0aWNIbrzHhFjme8Smxw4JlPoyrAKQ6808k5UvQdhvnWqHZCphq5mXd4TDA==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/flexsearch": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "git+ssh://git@github.com/nextapps-de/flexsearch.git#a253897675cdb1361554abdc7f57305a6d52de25",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/pg": {
|
||||
"version": "8.14.0",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.14.0.tgz",
|
||||
"integrity": "sha512-nXbVpyoaXVmdqlKEzToFf37qzyeeh7mbiXsnoWvstSqohj88yaa/I/Rq/HEVn2QPSZEuLIJa/jSpRDyzjEx4FQ==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"pg-connection-string": "^2.7.0",
|
||||
"pg-pool": "^3.8.0",
|
||||
"pg-protocol": "^1.8.0",
|
||||
"pg-types": "^2.1.0",
|
||||
"pgpass": "1.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"pg-cloudflare": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-native": ">=3.0.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"pg-native": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/pg-cloudflare": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz",
|
||||
"integrity": "sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/pg-connection-string": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.7.0.tgz",
|
||||
"integrity": "sha512-PI2W9mv53rXJQEOb8xNR8lH7Hr+EKa6oJa38zsK0S/ky2er16ios1wLKhZyxzD7jUReiWokc9WK5nxSnC7W1TA=="
|
||||
},
|
||||
"node_modules/pg-cursor": {
|
||||
"version": "2.13.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-cursor/-/pg-cursor-2.13.0.tgz",
|
||||
"integrity": "sha512-13jHi54EawM9aQhmf0+xRtvaL/g4kBjnx/tEXWAIPNKm4bxUofPfc5navrgt47z85AsxUDx4f40IzF1y9tUyeA==",
|
||||
"peer": true,
|
||||
"peerDependencies": {
|
||||
"pg": "^8"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-int8": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz",
|
||||
"integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==",
|
||||
"engines": {
|
||||
"node": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-minify": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-minify/-/pg-minify-1.7.0.tgz",
|
||||
"integrity": "sha512-kFPxAWAhPMvOqnY7klP3scdU5R7bxpAYOm8vGExuIkcSIwuFkZYl4C4XIPQ8DtXY2NzVmAX1aFHpvFSXQ/qQmA==",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-pool": {
|
||||
"version": "3.8.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.8.0.tgz",
|
||||
"integrity": "sha512-VBw3jiVm6ZOdLBTIcXLNdSotb6Iy3uOCwDGFAksZCXmi10nyRvnP2v3jl4d+IsLYRyXf6o9hIm/ZtUzlByNUdw==",
|
||||
"peerDependencies": {
|
||||
"pg": ">=8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-promise": {
|
||||
"version": "11.11.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-promise/-/pg-promise-11.11.0.tgz",
|
||||
"integrity": "sha512-nqtNHp9dvE1aMug2spLJBy6AazT9arorTlRqreHXu50pCArwQDpbu/R0tDUcyNYY4XP5HczwknkUzYi+ivyozQ==",
|
||||
"dependencies": {
|
||||
"assert-options": "0.8.2",
|
||||
"pg": "8.13.3",
|
||||
"pg-minify": "1.7.0",
|
||||
"spex": "3.4.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-query-stream": "4.7.3"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-promise/node_modules/pg": {
|
||||
"version": "8.13.3",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.13.3.tgz",
|
||||
"integrity": "sha512-P6tPt9jXbL9HVu/SSRERNYaYG++MjnscnegFh9pPHihfoBSujsrka0hyuymMzeJKFWrcG8wvCKy8rCe8e5nDUQ==",
|
||||
"dependencies": {
|
||||
"pg-connection-string": "^2.7.0",
|
||||
"pg-pool": "^3.7.1",
|
||||
"pg-protocol": "^1.7.1",
|
||||
"pg-types": "^2.1.0",
|
||||
"pgpass": "1.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"pg-cloudflare": "^1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-native": ">=3.0.1"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"pg-native": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/pg-protocol": {
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.8.0.tgz",
|
||||
"integrity": "sha512-jvuYlEkL03NRvOoyoRktBK7+qU5kOvlAwvmrH8sr3wbLrOdVWsRxQfz8mMy9sZFsqJ1hEWNfdWKI4SAmoL+j7g=="
|
||||
},
|
||||
"node_modules/pg-query-stream": {
|
||||
"version": "4.7.3",
|
||||
"resolved": "https://registry.npmjs.org/pg-query-stream/-/pg-query-stream-4.7.3.tgz",
|
||||
"integrity": "sha512-WvsdwYXrvIXNZJflX/2MEQLjKs5TopZWeiyam1zcaFfhwQtL19ENOvGdzVsihGsbsNGdVRU5yiqg2G5p06UAbg==",
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"pg-cursor": "^2.12.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg": "^8"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-types": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
|
||||
"integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
|
||||
"dependencies": {
|
||||
"pg-int8": "1.0.1",
|
||||
"postgres-array": "~2.0.0",
|
||||
"postgres-bytea": "~1.0.0",
|
||||
"postgres-date": "~1.0.4",
|
||||
"postgres-interval": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/pgpass": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz",
|
||||
"integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==",
|
||||
"dependencies": {
|
||||
"split2": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-array": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
|
||||
"integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-bytea": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
|
||||
"integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-date": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
|
||||
"integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-interval": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
|
||||
"integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
|
||||
"dependencies": {
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/spex": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/spex/-/spex-3.4.0.tgz",
|
||||
"integrity": "sha512-8JeZJ7QlEBnSj1W1fKXgbB2KUPA8k4BxFMf6lZX/c1ZagU/1b9uZWZK0yD6yjfzqAIuTNG4YlRmtMpQiXuohsg==",
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/split2": {
|
||||
"version": "4.2.0",
|
||||
"resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz",
|
||||
"integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==",
|
||||
"engines": {
|
||||
"node": ">= 10.x"
|
||||
}
|
||||
},
|
||||
"node_modules/xtend": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
|
||||
"integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
|
||||
"engines": {
|
||||
"node": ">=0.4"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
7
example/nodejs-worker-persistent/package.json
Normal file
7
example/nodejs-worker-persistent/package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "nodejs-worker-persistent",
|
||||
"dependencies": {
|
||||
"flexsearch": "github:nextapps-de/flexsearch#v0.8-preview",
|
||||
"pg-promise": "^11.11.0"
|
||||
}
|
||||
}
|
6
example/nodejs-worker/commonjs/config.originalTitle.js
Normal file
6
example/nodejs-worker/commonjs/config.originalTitle.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const { Charset } = require("flexsearch");
|
||||
|
||||
module.exports = {
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
};
|
6
example/nodejs-worker/commonjs/config.primaryTitle.js
Normal file
6
example/nodejs-worker/commonjs/config.primaryTitle.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const { Charset } = require("flexsearch");
|
||||
|
||||
module.exports = {
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
};
|
52
example/nodejs-worker/commonjs/index.js
Normal file
52
example/nodejs-worker/commonjs/index.js
Normal file
@@ -0,0 +1,52 @@
|
||||
const { Document } = require("flexsearch");
|
||||
const fs = require("fs");
|
||||
|
||||
// loading test data
|
||||
const data = JSON.parse(fs.readFileSync(__dirname + "/../data.json", "utf8"));
|
||||
|
||||
(async function(){
|
||||
|
||||
// create the document index
|
||||
const document = new Document({
|
||||
worker: true,
|
||||
document: {
|
||||
id: "tconst",
|
||||
store: true,
|
||||
index: [{
|
||||
field: "primaryTitle",
|
||||
config: __dirname + "/config.primaryTitle.js"
|
||||
},{
|
||||
field: "originalTitle",
|
||||
config: __dirname + "/config.originalTitle.js"
|
||||
}],
|
||||
tag: [{
|
||||
field: "startYear"
|
||||
},{
|
||||
field: "genres"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// add test data
|
||||
for(let i = 0; i < data.length; i++){
|
||||
await document.add(data[i]);
|
||||
}
|
||||
|
||||
// perform a query
|
||||
const result = await document.search({
|
||||
query: "carmen",
|
||||
tag: {
|
||||
"startYear": "1894",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
suggest: true,
|
||||
enrich: true,
|
||||
merge: true
|
||||
});
|
||||
|
||||
console.log(result);
|
||||
|
||||
}());
|
3
example/nodejs-worker/commonjs/package.json
Normal file
3
example/nodejs-worker/commonjs/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "commonjs"
|
||||
}
|
141
example/nodejs-worker/data.json
Normal file
141
example/nodejs-worker/data.json
Normal file
@@ -0,0 +1,141 @@
|
||||
[
|
||||
{
|
||||
"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"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000003",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Pauvre Pierrot",
|
||||
"originalTitle": "Pauvre Pierrot",
|
||||
"isAdult": 0,
|
||||
"startYear": "1892",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "4",
|
||||
"genres": [
|
||||
"Animation",
|
||||
"Comedy",
|
||||
"Romance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000004",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Un bon bock",
|
||||
"originalTitle": "Un bon bock",
|
||||
"isAdult": 0,
|
||||
"startYear": "1892",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "12",
|
||||
"genres": [
|
||||
"Animation",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000005",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Blacksmith Scene",
|
||||
"originalTitle": "Blacksmith Scene",
|
||||
"isAdult": 0,
|
||||
"startYear": "1893",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Comedy",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000006",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Chinese Opium Den",
|
||||
"originalTitle": "Chinese Opium Den",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000007",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Corbett and Courtney Before the Kinetograph",
|
||||
"originalTitle": "Corbett and Courtney Before the Kinetograph",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Short",
|
||||
"Sport"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000008",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Edison Kinetoscopic Record of a Sneeze",
|
||||
"originalTitle": "Edison Kinetoscopic Record of a Sneeze",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000009",
|
||||
"titleType": "movie",
|
||||
"primaryTitle": "Miss Jerry",
|
||||
"originalTitle": "Miss Jerry",
|
||||
"isAdult": 0,
|
||||
"startYear": "1894",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "45",
|
||||
"genres": [
|
||||
"Romance"
|
||||
]
|
||||
},
|
||||
{
|
||||
"tconst": "tt0000010",
|
||||
"titleType": "short",
|
||||
"primaryTitle": "Leaving the Factory",
|
||||
"originalTitle": "La sortie de l'usine Lumière à Lyon",
|
||||
"isAdult": 0,
|
||||
"startYear": "1895",
|
||||
"endYear": "",
|
||||
"runtimeMinutes": "1",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
}
|
||||
]
|
6
example/nodejs-worker/esm/config.originalTitle.js
Normal file
6
example/nodejs-worker/esm/config.originalTitle.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Charset } from "flexsearch/esm";
|
||||
|
||||
export default {
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
};
|
6
example/nodejs-worker/esm/config.primaryTitle.js
Normal file
6
example/nodejs-worker/esm/config.primaryTitle.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Charset } from "flexsearch/esm";
|
||||
|
||||
export default {
|
||||
tokenize: "forward",
|
||||
encoder: Charset.LatinSimple
|
||||
};
|
53
example/nodejs-worker/esm/index.js
Normal file
53
example/nodejs-worker/esm/index.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Document } from "flexsearch/esm";
|
||||
import fs from "fs";
|
||||
|
||||
const dirname = import.meta.dirname;
|
||||
// loading test data
|
||||
const data = JSON.parse(fs.readFileSync(dirname + "/../data.json", "utf8"));
|
||||
|
||||
(async function(){
|
||||
|
||||
// create the document
|
||||
const document = new Document({
|
||||
worker: true,
|
||||
document: {
|
||||
id: "tconst",
|
||||
store: true,
|
||||
index: [{
|
||||
field: "primaryTitle",
|
||||
config: dirname + "/config.primaryTitle.js"
|
||||
},{
|
||||
field: "originalTitle",
|
||||
config: dirname + "/config.originalTitle.js"
|
||||
}],
|
||||
tag: [{
|
||||
field: "startYear"
|
||||
},{
|
||||
field: "genres"
|
||||
}]
|
||||
}
|
||||
});
|
||||
|
||||
// add test data
|
||||
for(let i = 0; i < data.length; i++){
|
||||
await document.add(data[i]);
|
||||
}
|
||||
|
||||
// perform a query
|
||||
const result = await document.search({
|
||||
query: "carmen",
|
||||
tag: {
|
||||
"startYear": "1894",
|
||||
"genres": [
|
||||
"Documentary",
|
||||
"Short"
|
||||
]
|
||||
},
|
||||
suggest: true,
|
||||
enrich: true,
|
||||
merge: true
|
||||
});
|
||||
|
||||
console.log(result);
|
||||
|
||||
}());
|
3
example/nodejs-worker/esm/package.json
Normal file
3
example/nodejs-worker/esm/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"type": "module"
|
||||
}
|
18
example/nodejs-worker/package-lock.json
generated
Normal file
18
example/nodejs-worker/package-lock.json
generated
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "nodejs-worker-persistent",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "nodejs-worker-persistent",
|
||||
"dependencies": {
|
||||
"flexsearch": "github:nextapps-de/flexsearch#v0.8-preview"
|
||||
}
|
||||
},
|
||||
"node_modules/flexsearch": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "git+ssh://git@github.com/nextapps-de/flexsearch.git#a253897675cdb1361554abdc7f57305a6d52de25",
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
}
|
||||
}
|
6
example/nodejs-worker/package.json
Normal file
6
example/nodejs-worker/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "nodejs-worker",
|
||||
"dependencies": {
|
||||
"flexsearch": "github:nextapps-de/flexsearch#v0.8-preview"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user