public function MySql::preprocessIndexValue in Search API 8
Determines the canonical base form of a value.
For example, when the table is case-insensitive, the value should always be lowercased (or always uppercased) to arrive at the canonical base form.
If tables of the given type use binary comparison in this database, the value should not be changed.
Parameters
string $value: A string to be indexed or searched for.
string $type: (optional) The type of table. One of "index" (for the denormalized table for an entire index), "text" (for an index's fulltext data table) and "field" (for field-specific tables).
Return value
string The value in its canonical base form, which won't clash with any other canonical base form when inserted into a table of the given type.
Overrides GenericDatabase::preprocessIndexValue
File
- modules/
search_api_db/ src/ DatabaseCompatibility/ MySql.php, line 43
Class
- MySql
- Represents a MySQL-based database.
Namespace
Drupal\search_api_db\DatabaseCompatibilityCode
public function preprocessIndexValue($value, $type = 'text') {
$value = parent::preprocessIndexValue($value, $type);
// As MySQL removes trailing whitespace when computing primary keys, we need
// to do the same or pseudo-duplicates could cause an exception ("Integrity
// constraint violation: Duplicate entry") during indexing.
if ($type !== 'text') {
$value = rtrim($value);
}
return $value;
}