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

View File

@@ -1,4 +1,4 @@
import { Index } from "flexsearch";
import { Index, Resolver } from "flexsearch";
// create a simple index which can store id-content-pairs
const index = new Index({
@@ -7,8 +7,8 @@ const index = new Index({
// some test data
const data = [
'cats abcd efgh ijkl mnop qrst uvwx cute',
'cats abcd efgh ijkl mnop qrst cute',
'cats abcd efgh ijkl dogs pigs rats cute',
'cats abcd efgh ijkl dogs pigs cute',
'cats abcd efgh ijkl dogs cute',
'cats abcd efgh ijkl cute',
'cats abcd efgh cute',
@@ -22,10 +22,26 @@ data.forEach((item, id) => {
});
// perform query
const result = index.search({
query: "black dog or cute cat",
suggest: true
});
const result = new Resolver({
index: index,
query: "black"
})
.or({
index: index,
query: "cute"
})
.and([{
index: index,
query: "dog"
},{
index: index,
query: "cat"
}])
.not({
index: index,
query: "rat"
})
.resolve();
// display results
result.forEach(i => {

View File

@@ -2,6 +2,6 @@
"name": "nodejs-esm-basic-resolver",
"type": "module",
"dependencies": {
"flexsearch": "^0.8.105"
"flexsearch": "^0.8.200"
}
}