From 20034dfe000aa31a0824aafdbba9286827dff965 Mon Sep 17 00:00:00 2001 From: Steve Taylor Date: Wed, 5 Apr 2017 14:54:13 -0700 Subject: [PATCH] Change Search API DB to pull regex from Search API Search API DB had the problematic regex hardcoded. Here we set it to pull from the existing Search API configuration. --- service.inc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/service.inc b/service.inc index 609e5d4..314915f 100644 --- a/service.inc +++ b/service.inc @@ -1055,7 +1055,8 @@ class SearchApiDbService extends SearchApiAbstractService { $score = $v['score']; $v = $v['value']; if (drupal_strlen($v) > 50) { - $words = preg_split('/[^\p{L}\p{N}]+/u', $v, -1, PREG_SPLIT_NO_EMPTY); + $spaces_regex = ma_search_api_get_whitespace_tokenizer_regex(); + $words = preg_split('/' . $spaces_regex . '+/u', $v, -1, PREG_SPLIT_NO_EMPTY); if (count($words) > 1 && max(array_map('drupal_strlen', $words)) <= 50) { // Overlong token is due to bad tokenizing. // Check for "Tokenizer" preprocessor on index. @@ -1398,7 +1399,8 @@ class SearchApiDbService extends SearchApiAbstractService { $this->ignored[$keys] = 1; return NULL; } - $words = preg_split('/[^\p{L}\p{N}]+/u', $proc, -1, PREG_SPLIT_NO_EMPTY); + $spaces_regex = ma_search_api_get_whitespace_tokenizer_regex(); + $words = preg_split('/' . $spaces_regex . '+/u', $proc, -1, PREG_SPLIT_NO_EMPTY); if (count($words) > 1) { $proc = $this->splitKeys($words); if ($proc) { @@ -2104,7 +2106,8 @@ class SearchApiDbService extends SearchApiAbstractService { // Also collect all keywords already contained in the query so we don't // suggest them. - $keys = drupal_map_assoc(preg_split('/[^\p{L}\p{N}]+/u', $user_input, -1, PREG_SPLIT_NO_EMPTY)); + $spaces_regex = ma_search_api_get_whitespace_tokenizer_regex(); + $keys = drupal_map_assoc(preg_split('/' . $spaces_regex . '+/u', $user_input, -1, PREG_SPLIT_NO_EMPTY)); if ($incomplete_key) { $keys[$incomplete_key] = $incomplete_key; } -- 1.9.1