Problem/Motivation
We're working on indexing field types not in the current version of the module. Our example is a geopoint, which means the value we're indexing is an array. See documentation: https://typesense.org/docs/0.25.1/api/geosearch.html#searching-within-a-...
I came across this bug/mistake in the code causing this error:
TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in count() (line 367 of modules/contrib/search_api_typesense/src/Api/SearchApiTypesenseService.php).
Code causing error:
public function prepareItemValue($value, $type) {
if (is_array($value) && count($value <= 1)) {
$value = reset($value);
}
Steps to reproduce
Clone any of the data_type plugins and return an array. Could be as simple as:
return (string) [$value, $value];
Proposed resolution
Easy to fix by moving the closing parentheses so it's "count($value) <= 1" instead of "count($value <= 1)".
Remaining tasks
Test patch
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Comments
Comment #2
khaled.zaidan commentedAttaching patch for suggested fix.
Comment #3
khaled.zaidan commentedComment #4
keshavv commentedConfirmed that there is an issue and the #2 patch works well. This is a minor mistake. So we can merge it.
Comment #5
lussolucaMerged in #3426937: Prepare for the first release.
Thanks!