-
-
Notifications
You must be signed in to change notification settings - Fork 495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Importing exported indexes doesn't populate store (#249) #384
Comments
I've also noticed that for some reason one of the saved files is But I don't know if this plays any role in my problem. |
I'm also experiencing this. JSFiddle Example: https://jsfiddle.net/tnx5qLzd/ |
Chiming in with the same issue. My setup looks something like: // Exporting
import flexsearch from 'flexsearch'
const docIndex = new flexsearch.Document({
document: {
id: 'id',
index: ['title', 'description', 'source', 'tags', 'body'],
store: ['title', 'description', 'tags'],
},
});
documents.forEach((doc) => {
docIndex.add(doc.slug, {
title: doc.title,
description: doc.description,
source: doc.source,
tags: doc.tags,
body: doc.body,
})
})
docIndex.export((key, data) => {
// Line-delimited JSON-objects, plays nicely with the async-ish nature of export
stdout.write(JSON.stringify({key, data}) + '\n')
})
}) // Importing
import { Document } from 'flexsearch'
const docIndex = new Document({
document: {
id: 'id',
index: ['title', 'description', 'source', 'tags', 'body'],
store: ['title', 'description', 'tags'],
},
}) as Document<Post, string[]>;
await readByLines('/flexsearch.json', (line: string) => {
const imp = JSON.parse(line)
docIndex.import(imp.key, imp.data);
})
const searchResults = docIndex.search({
query: 'the query',
enrich: true,
});
// searchResults[].result[].doc is undefined |
I’m running into the same bug. This remains a problem with version |
I'm running into the same bug. like: for(let i = 0, key; i < keys.length; i++){
} but i find it fix when running like this: for(let i = 0, key; i < keys.length; i++){
} adding JSON.parse(data); is OK ,have a try |
I've been having some trouble implementing exporting and then importing those same indexes...
I found this issue #249 . Although it says it should have been fixed, I still have the same problem.
I followed this linked Stackoverflow issue and exported my indexes like so;:
And later I try to import them like so:
And finally I can search like so
Everything works fine up to this point and I get the results I wanted, but the doc object is undefined...
However, when I try to do the same, but only create the indexes like in the first code example, then everything works as expected:
Does this mean #254 is not fixed yet or am I doing something wrong? Do I need to handle the data object while importing in a special way instead of just importing the whole data?
The text was updated successfully, but these errors were encountered: