From: David Causse Date: Tue, 20 Jun 2017 13:43:28 +0000 (+0200) Subject: Add SearchIndexField::getEngineHints() X-Git-Tag: 1.31.0-rc.0~2850^2 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=b5aecfabd96dee76031193b53790dcbcb7c33b7d;p=lhc%2Fweb%2Fwiklou.git Add SearchIndexField::getEngineHints() Allows search engine clients that implement custom definitions to pass engine hints used at index time. Hints are a way to fine tune the behavior of the search engine when handling a particular field. As of now this is introduced for CirrusSearch to let SearchIndexField implementations to control how the noop script is configured. The noop hint with CirrusSearch allows to (for example): - ignore an update if a numeric value does not change for more than X% - control the merge strategy of complex fields Bug: T166589 Change-Id: Ia560e41d33013c30ac47e5a60543f8cb133e61fb --- diff --git a/includes/search/NullIndexField.php b/includes/search/NullIndexField.php index 933e0ad332..852e1d5a1b 100644 --- a/includes/search/NullIndexField.php +++ b/includes/search/NullIndexField.php @@ -42,4 +42,11 @@ class NullIndexField implements SearchIndexField { public function merge( SearchIndexField $that ) { return $that; } + + /** + * {@inheritDoc} + */ + public function getEngineHints( SearchEngine $engine ) { + return []; + } } diff --git a/includes/search/SearchIndexField.php b/includes/search/SearchIndexField.php index 6b5316f009..a348d6dc9a 100644 --- a/includes/search/SearchIndexField.php +++ b/includes/search/SearchIndexField.php @@ -72,4 +72,21 @@ interface SearchIndexField { * @return SearchIndexField|false New definition or false if not mergeable. */ public function merge( SearchIndexField $that ); + + /** + * A list of search engine hints for this field. + * Hints are usually specific to a search engine implementation + * and allow to fine control how the search engine will handle this + * particular field. + * + * For example some search engine permits some optimizations + * at index time by ignoring an update if the updated value + * does not change by more than X% on a numeric value. + * + * @param SearchEngine $engine + * @return array an array of hints generally indexed by hint name. The type of + * values is search engine specific + * @since 1.30 + */ + public function getEngineHints( SearchEngine $engine ); } diff --git a/includes/search/SearchIndexFieldDefinition.php b/includes/search/SearchIndexFieldDefinition.php index 04344fdadd..e3e01e8b60 100644 --- a/includes/search/SearchIndexFieldDefinition.php +++ b/includes/search/SearchIndexFieldDefinition.php @@ -140,4 +140,11 @@ abstract class SearchIndexFieldDefinition implements SearchIndexField { public function setMergeCallback( $callback ) { $this->mergeCallback = $callback; } + + /** + * {@inheritDoc} + */ + public function getEngineHints( SearchEngine $engine ) { + return []; + } }