pedroborges / kirby-fuzzy-search

⬢ Fuzzy-search plugin for Kirby.
43 stars 2 forks source link

"Undefined offset: -1" when searching with fields that do not exist in all pages #1

Closed neildaniels closed 6 years ago

neildaniels commented 6 years ago

In cases where a fuseSearch is performed on pages that do not all have the specified field, an Exception of Undefined offset: -1 occurs.

For example, assume $haystack contains Pages that do not have a foo-bar field.

$results = $haystack->fuseSearch($searchQuery, [
    'keys' => ['title', 'foo-bar'],
]);

This will cause site/plugins/fuse-search/vendor/loilo/fuse/src/Bitap/matched_indices.php to have an undefined offset of -1 on line 24.

screen shot 2017-11-25 at 7 33 41 pm
pedroborges commented 6 years ago

That error was thrown by the library the plugin depended on. I have replaced it by another library which is simpler and finds better matches in my testings.