lucaong / minisearch

Tiny and powerful JavaScript full-text search engine for browser and Node
https://lucaong.github.io/minisearch/
MIT License
4.64k stars 133 forks source link

searchTokenize(...).flatMap #226

Closed drfussel closed 1 year ago

drfussel commented 1 year ago

When i try Minisearch.search on my Electron App i get the following Error:

(node:31124) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): TypeError: searchTokenize(...).flatMap is not a function

Thats my package.json { "name": "eftoverlay", "version": "0.0.1", "description": "Ingame Overlay for further Informations for the game EFT", "main": "main.js", "scripts": { "start": "electron . --enable-logging", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Kvin", "license": "ISC", "devDependencies": { "electron": "^2.0.2" }, "dependencies": { "electron-fetch": "^1.9.1", "minisearch": "^6.1.0", "node-fetch": "^3.3.2", "request": "^2.88.2", "request-promise": "^4.2.6" } }

An Example of the Json which i store in the minisearch is: { "data": { "items": [ { "id": "544fb45d4bdc2dee738b4568", "name": "Salewa first aid kit", "shortName": "Salewa", "basePrice": 18863, "normalizedName": "salewa-first-aid-kit", "types": [ "meds", "provisions" ], "width": 1, "height": 2, "avg24hPrice": 39748, "wikiLink": "https://escapefromtarkov.fandom.com/wiki/Salewa_first_aid_kit", "changeLast48h": -2290, "low24hPrice": 30000, "high24hPrice": 96420, "lastLowPrice": 36999, "gridImageLink": "https://assets.tarkov.dev/544fb45d4bdc2dee738b4568-grid-image.webp", "iconLink": "https://assets.tarkov.dev/544fb45d4bdc2dee738b4568-icon.webp", "traderPrices": [ { "price": 9431, "trader": { "name": "Prapor" } }, { "price": 11883, "trader": { "name": "Therapist" } }, { "price": 7545, "trader": { "name": "Fence" } }, { "price": 11317, "trader": { "name": "Jaeger" } } ], "sellFor": [ { "source": "prapor", "price": 9431, "vendor": { "name": "Prapor" }, "requirements": [], "currency": "RUB" }, { "source": "therapist", "price": 11883, "vendor": { "name": "Therapist" }, "requirements": [], "currency": "RUB" }, { "source": "fence", "price": 7545, "vendor": { "name": "Fence" }, "requirements": [], "currency": "RUB" }, { "source": "jaeger", "price": 11317, "vendor": { "name": "Jaeger" }, "requirements": [], "currency": "RUB" }, { "source": "fleaMarket", "price": 36999, "vendor": { "name": "Flea Market" }, "requirements": [ { "type": "playerLevel", "value": 15 } ], "currency": "RUB" } ], "buyFor": [ { "source": "therapist", "price": 37061, "currency": "RUB", "requirements": [ { "type": "loyaltyLevel", "value": 2 }, { "type": "questCompleted", "value": 178 } ] }, { "source": "fleaMarket", "price": 39748, "currency": "RUB", "requirements": [ { "type": "playerLevel", "value": 15 } ] } ], "containsItems": [] } ] } }

And this is my Minisearch initialitation db = new MiniSearch({ fields: ['name', 'shortName'], // fields to index for full-text search storeFields: ['name', 'shortName', 'avg24hPrice', 'sellFor', 'basePrice','price','vendor'], // fields to return with search results searchOptions: { fuzzy: 0.2, prefix: true, boost: { 'shortName': 1.5 } } })

drfussel commented 1 year ago

` // A collection of documents for our examples const documents = [ { id: 1, title: 'Moby Dick', text: 'Call me Ishmael. Some years ago...', category: 'fiction' }, { id: 2, title: 'Zen and the Art of Motorcycle Maintenance', text: 'I can see by my watch...', category: 'fiction' }, { id: 3, title: 'Neuromancer', text: 'The sky above the port was...', category: 'fiction' }, { id: 4, title: 'Zen and the Art of Archery', text: 'At first sight it must seem...', category: 'non-fiction' }, // ...and more ]

let miniSearch = new MiniSearch({ fields: ['title', 'text'], // fields to index for full-text search storeFields: ['title', 'category'] // fields to return with search results })

// Index all documents miniSearch.addAll(documents) console.log("Searching") // Search with default options let results = miniSearch.autoSuggest('zen art motorcycle') // => [ // { id: 2, title: 'Zen and the Art of Motorcycle Maintenance', category: 'fiction', score: 2.77258, match: { ... } }, // { id: 4, title: 'Zen and the Art of Archery', category: 'non-fiction', score: 1.38629, match: { ... } } // ]`

Even with the given Example i got the same Error