From: Stanislav Malyshev Date: Fri, 19 Apr 2019 06:59:18 +0000 (-0700) Subject: Define index types as strings X-Git-Tag: 1.34.0-rc.0~1901^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/modifier.php?a=commitdiff_plain;h=9e035a229ed6550d1b7fd7ac49b8cfcf26122785;p=lhc%2Fweb%2Fwiklou.git Define index types as strings This will allow to use them easier in JSON config files. Bug: T142809 Change-Id: I4053a87fe8e53c9b506604db6fad2f98f7dba150 --- diff --git a/includes/search/SearchEngine.php b/includes/search/SearchEngine.php index a3a8abeb16..6ca10cc45c 100644 --- a/includes/search/SearchEngine.php +++ b/includes/search/SearchEngine.php @@ -813,7 +813,7 @@ abstract class SearchEngine { * Create a search field definition. * Specific search engines should override this method to create search fields. * @param string $name - * @param int $type One of the types in SearchIndexField::INDEX_TYPE_* + * @param string $type One of the types in SearchIndexField::INDEX_TYPE_* * @return SearchIndexField * @since 1.28 */ diff --git a/includes/search/SearchIndexField.php b/includes/search/SearchIndexField.php index daeb5f5148..7bc4ba5906 100644 --- a/includes/search/SearchIndexField.php +++ b/includes/search/SearchIndexField.php @@ -15,17 +15,17 @@ interface SearchIndexField { * https://wikimediafoundation.org/2018/08/07/anatomy-search-token-affection/ * https://wikimediafoundation.org/2018/09/13/anatomy-search-variation-under-nature/ */ - const INDEX_TYPE_TEXT = 0; + const INDEX_TYPE_TEXT = 'text'; /** * KEYWORD fields are indexed without any processing, so are appropriate * for e.g. URLs. The content will often consist of a single token. */ - const INDEX_TYPE_KEYWORD = 1; - const INDEX_TYPE_INTEGER = 2; - const INDEX_TYPE_NUMBER = 3; - const INDEX_TYPE_DATETIME = 4; - const INDEX_TYPE_NESTED = 5; - const INDEX_TYPE_BOOL = 6; + const INDEX_TYPE_KEYWORD = 'keyword'; + const INDEX_TYPE_INTEGER = 'integer'; + const INDEX_TYPE_NUMBER = 'number'; + const INDEX_TYPE_DATETIME = 'datetime'; + const INDEX_TYPE_NESTED = 'nested'; + const INDEX_TYPE_BOOL = 'bool'; /** * SHORT_TEXT is meant to be used with short text made of mostly ascii @@ -33,7 +33,7 @@ interface SearchIndexField { * is used and aggressive splitting to increase recall. * E.g suited for mime/type */ - const INDEX_TYPE_SHORT_TEXT = 7; + const INDEX_TYPE_SHORT_TEXT = 'short_text'; /** * Generic field flags. diff --git a/includes/search/SearchIndexFieldDefinition.php b/includes/search/SearchIndexFieldDefinition.php index a11dff9fc7..d0d2b89947 100644 --- a/includes/search/SearchIndexFieldDefinition.php +++ b/includes/search/SearchIndexFieldDefinition.php @@ -20,7 +20,7 @@ abstract class SearchIndexFieldDefinition implements SearchIndexField { /** * Type of the field, one of the constants above * - * @var int + * @var string */ protected $type; @@ -44,7 +44,7 @@ abstract class SearchIndexFieldDefinition implements SearchIndexField { /** * @param string $name Field name - * @param int $type Index type + * @param string $type Index type */ public function __construct( $name, $type ) { $this->name = $name;