Export Incorrectly Lists 0 index fields as null instead of false or empty array
Author: lgtmakCreated Aug 7, 2025Updated Sep 7, 2025
// config
{
document: {
id: "id",
store: true,
index: [
{ field: "title", tokenize: "forward" },
],
tag: [ { field: "scoredValue", custom: (data) => Number(data.score) > 1 ? ">1" : false } ]
}
}
// sample docs
[
{
"id": 1,
"title": "One",
"score": null,
},
{
"id": 2,
"title": "Two",
"score": null,
},
]When exporting the database it will produce an index json like this:
{
...
"1.tag": "[[\"scoredValue\", null],[...],[...]]
}When I attempt to import I get this error on the 1.tag key:
TypeError: Cannot read properties of null (reading 'length')
Import code:
const docIndex = new Document(name, myConfig);
// where key is `1.tag` from index export
for (const key in blobData.indexes) {
docIndex.import(key, blobData.indexes[key]);
}Source: nextapps-de/flexsearch