Skip to content

Commit

Permalink
Change the way how we detect min_infix_len in table to support fuzzy …
Browse files Browse the repository at this point in the history
…search in plain indexes
  • Loading branch information
donhardman committed Dec 12, 2024
1 parent 358c002 commit 403b1cd
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/ManticoreSearch/TableValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,23 @@ public function hasMinInfixLen(string $table): bool {
if ($this->cache->has($cacheKey)) {
return true;
}

/** @var array{error?:string} */
$result = $this->client->sendRequest('SHOW CREATE TABLE ' . $table)->getResult();
$result = $this->client->sendRequest("SHOW TABLE $table SETTINGS")->getResult();
if (isset($result['error'])) {
TableValidationError::throw($result['error']);
}

/** @var array{0:array{data:array<array{'Create Table':string}>}} $result */
$schema = $result[0]['data'][0]['Create Table'];
if (false === str_contains($schema, 'min_infix_len')) {
return false;
/** @var array{0:array{data:array<array{'Variable_name':string,'Value':string}>}} $result */
$variables = $result[0]['data'];
foreach ($variables as $variable) {
$name = $variable['Variable_name'];
$value = $variable['Value'];
if ($name === 'settings' && str_contains($value, 'min_infix_len')) {
$this->cache->set($cacheKey, true, $this->ttl);
return true;
}
}
$this->cache->set($cacheKey, true, $this->ttl);
return true;
return false;
}
}

0 comments on commit 403b1cd

Please sign in to comment.