Smalyshev has uploaded a new change for review. https://gerrit.wikimedia.org/r/232828
Change subject: Implement David's suggestions on more detailed config ...................................................................... Implement David's suggestions on more detailed config Change-Id: I864e5d51e6d176239dd7ae94aa90f29d94d55172 --- M CirrusSearch.php M includes/Searcher.php 2 files changed, 24 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch refs/changes/28/232828/1 diff --git a/CirrusSearch.php b/CirrusSearch.php index 4caf7ce..a17d76c 100644 --- a/CirrusSearch.php +++ b/CirrusSearch.php @@ -788,17 +788,31 @@ /** * Settings for completion suggestion options. * See CirrusSearch\BuildDocument\SuggestBuilder and CirrusSearch\Searcher - * fields - set of suggestion fields to use - * fuzzy - fuzziness configuration (false for no fuzziness) * See also: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-suggesters-completion.html */ $wgCirrusSearchCompletionSettings = array( - "fields" => array( - "suggest", "suggest-stop" + 'plain' => array( + 'field' => 'suggest', + 'min_query_len' => 0, + 'discount' => 1.0, ), - "fuzzy" => array( - "fuzziness" => 2 + 'plain_stop' => array( + 'field' => 'suggest-stop', + 'min_query_len' => 0, + 'discount' => 0.3, ), + 'plain_fuzzy' => array( + 'field' => 'suggest', + 'min_query_len' => 3, // We may not want to fire a fuzzy request if the query is too short. + 'discount' => 0.2, + 'fuzzy' => true, + ), + 'plain_stop_fuzzy' => array( + 'field' => 'suggest-stop', + 'min_query_len' => 3, + 'discount' => 0.1, + 'fuzzy' => true, + ) ); $includes = __DIR__ . "/includes/"; diff --git a/includes/Searcher.php b/includes/Searcher.php index 76583da..8f715ab 100644 --- a/includes/Searcher.php +++ b/includes/Searcher.php @@ -794,26 +794,15 @@ $this->term = $text; $suggest = array( 'text' => $text ); - foreach ( $wgCirrusSearchCompletionSettings[ 'fields' ] as $field ) { + foreach ( $wgCirrusSearchCompletionSettings as $field => $config ) { $suggest[$field] = array( - 'completion' => array( - 'field' => $field, - ) + 'completion' => $config ); if ( $context ) { $suggest[$field]['completion']['context'] = $context; } - - if( is_array( $wgCirrusSearchCompletionSettings[ 'fuzzy' ] ) ) { - $suggest[$field."-fuzzy"] = array( - 'completion' => array( - 'field' => $field, - 'fuzzy' => $wgCirrusSearchCompletionSettings[ 'fuzzy' ], - ) - ); - if ( $context ) { - $suggest[$field."-fuzzy"]['completion']['context'] = $context; - } + if ( $this->limit ) { + $suggest[$field]['completion']['size'] = $this->limit; } } -- To view, visit https://gerrit.wikimedia.org/r/232828 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I864e5d51e6d176239dd7ae94aa90f29d94d55172 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/CirrusSearch Gerrit-Branch: master Gerrit-Owner: Smalyshev <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
