You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding an fts field if the field is optional in the collection, fts will fail on insert, this will cause the insert to fail and stop at the last item inserted.
for example, let's say I have an Item collection and I want to be able to search in the field group but this field is optional, i.e sometimes it has a value, sometimes null
When fts tokenizes the field it will try to split it by whitespaces
If a field value is not present, that is null or undefined, skip.
Maybe even check for more types and throw/convert to a string?
Number => toString ? throw invalid type error? expected string got X
Minimal reproduction of the problem with instructions
Something like this should work:
//Initialize DBFullTextSearch.register()IndexedStorage.register()constlokiDb=newLoki('notAMimic')// initialize collectiondb.addCollection<T>(collectionName,{fullTextSearch: [{field: 'name'},{field: 'group'},{field: 'category'},],})// add datacollection.value.insert([{name: 'Sword of madness',group: 'sword',category: 'Martial'},{name: 'Club',group:'club',category: 'simple'},{name: 'Shield of awesome',group: null,category: 'to lazy to come up with something'}// Cry here])
The text was updated successfully, but these errors were encountered:
[X ] Bug report
Hya again ^^
When adding an fts field if the field is optional in the collection, fts will fail on insert, this will cause the insert to fail and stop at the last item inserted.
for example, let's say I have an Item collection and I want to be able to search in the field
group
but this field is optional, i.e sometimes it has a value, sometimesnull
When fts tokenizes the field it will try to split it by whitespaces
LokiDB/packages/full-text-search/src/analyzer/tokenizer.ts
Line 12 in 8b99821
and fails, as
null.split
is not a functionEdit:
After testing for 1 more minute 🤦
I found the offending line:
LokiDB/packages/full-text-search/src/full_text_search.ts
Line 49 in 8b99821
Changing this to
fixes the issue
Expected behavior
If a field value is not present, that is null or undefined, skip.
Maybe even check for more types and throw/convert to a string?
Number => toString ? throw invalid type error? expected string got X
Minimal reproduction of the problem with instructions
Something like this should work:
The text was updated successfully, but these errors were encountered: