DCausse has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/281964

Change subject: Remove usage of field_value_factor_with_default
......................................................................

Remove usage of field_value_factor_with_default

The patch to upstream has been merged a long time ago and we don't
need to use the custom version in the extra plugin.

Bug: T131944
Change-Id: I1614ed5fa40cbef1e9bb4de200477ace96539dcb
---
M CirrusSearch.php
M includes/Search/RescoreBuilders.php
M includes/Search/SearchContext.php
M tests/jenkins/FullyFeaturedConfig.php
M tests/unit/RescoreBuilderTest.php
5 files changed, 7 insertions(+), 41 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CirrusSearch 
refs/changes/64/281964/1

diff --git a/CirrusSearch.php b/CirrusSearch.php
index d01b3fe..0cc219f 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -152,9 +152,6 @@
 // This turns on noop-detection for updates and is compatible with
 // wikimedia-extra versions 1.3.1, 1.4.2, and 1.5.0:
 // $wgCirrusSearchWikimediaExtraPlugin[ 'super_detect_noop' ] = true;
-// This turns on field_value_factors for rankings and is compatible with
-// wikimedia-extra versions 1.3.1, 1.4.2, and 1.5.0:
-// $wgCirrusSearchWikimediaExtraPlugin[ 'field_value_factor_with_default' ] = 
true;
 // This allows forking on reindexing and is compatible with wikimedia-extra
 // versions 1.3.1, 1.4.2, and 1.5.0
 // $wgCirrusSearchWikimediaExtraPlugin[ 'id_hash_mod_filter' ] = true;
diff --git a/includes/Search/RescoreBuilders.php 
b/includes/Search/RescoreBuilders.php
index e53f927..5ef4643 100644
--- a/includes/Search/RescoreBuilders.php
+++ b/includes/Search/RescoreBuilders.php
@@ -521,16 +521,11 @@
                if( !$this->context->isBoostLinks() ) {
                        return;
                }
-               if( $this->context->isUseFieldValueFactorWithDefault() ) {
-                       $functionScore->addFunction( 
'field_value_factor_with_default', array(
-                               'field' => 'incoming_links',
-                               'modifier' => 'log2p',
-                               'missing' => 0,
-                       ) );
-               } else {
-                       $scoreBoostExpression = 
"log10(doc['incoming_links'].value + 2)";
-                       $functionScore->addScriptScoreFunction( new 
\Elastica\Script( $scoreBoostExpression, null, 'expression' ), null, 
$this->weight );
-               }
+               $functionScore->addFunction( 'field_value_factor', array(
+                       'field' => 'incoming_links',
+                       'modifier' => 'log2p',
+                       'missing' => 0,
+               ) );
        }
 }
 
diff --git a/includes/Search/SearchContext.php 
b/includes/Search/SearchContext.php
index f0785ef..7d90170 100644
--- a/includes/Search/SearchContext.php
+++ b/includes/Search/SearchContext.php
@@ -131,14 +131,6 @@
        }
 
        /**
-        * @return boolean true  if we can use the function score 
field_value_factor_with_default provided
-        * by the wikimedia extra plugin
-        */
-       public function isUseFieldValueFactorWithDefault() {
-               return !is_null( $this->config->getElement( 
'CirrusSearchWikimediaExtraPlugin', 'field_value_factor_with_default' ) );
-       }
-
-       /**
         * @param string $query
         * @param boolean $isRescore
         * @return \Elastica\Query\Simple
diff --git a/tests/jenkins/FullyFeaturedConfig.php 
b/tests/jenkins/FullyFeaturedConfig.php
index cebff3a..3f51632 100644
--- a/tests/jenkins/FullyFeaturedConfig.php
+++ b/tests/jenkins/FullyFeaturedConfig.php
@@ -34,7 +34,6 @@
 
 $wgCirrusSearchQueryStringMaxDeterminizedStates = 500;
 $wgCirrusSearchWikimediaExtraPlugin[ 'super_detect_noop' ] = true;
-$wgCirrusSearchWikimediaExtraPlugin[ 'field_value_factor_with_default' ] = 
true;
 $wgCirrusSearchWikimediaExtraPlugin[ 'id_hash_mod_filter' ] = true;
 
 $wgCirrusSearchUseCompletionSuggester = 'yes';
diff --git a/tests/unit/RescoreBuilderTest.php 
b/tests/unit/RescoreBuilderTest.php
index ceaff1a..5d89086 100644
--- a/tests/unit/RescoreBuilderTest.php
+++ b/tests/unit/RescoreBuilderTest.php
@@ -141,9 +141,7 @@
        }
 
        public function testBoostLinks() {
-               $settings = array(
-                       'CirrusSearchWikimediaExtraPlugin' => array ( 
'field_value_factor_with_default' => true )
-               );
+               $settings = array();
                $config = new HashSearchConfig( $settings );
                $context = new SearchContext( $config, null );
                $context->setBoostLinks( true );
@@ -155,27 +153,12 @@
                $array = $fScore->toArray();
                $this->assertTrue( isset( 
$array['function_score']['functions'][0] ) );
                $array = $array['function_score']['functions'][0];
-               $this->assertTrue( isset( 
$array['field_value_factor_with_default'] ) );
+               $this->assertTrue( isset( $array['field_value_factor'] ) );
 
                $context->setBoostLinks( false );
                $fScore = new FunctionScoreDecorator();
                $builder->append( $fScore );
                $this->assertTrue( $fScore->isEmptyFunction() );
-
-               // test without wikimedia extra plugin
-               $settings = array();
-               $config = new HashSearchConfig( array() );
-               $context = new SearchContext( $config, null );
-               $builder = new IncomingLinksFunctionScoreBuilder( $context, 1 );
-               $context->setBoostLinks( true );
-
-               $builder->append( $fScore );
-               $this->assertFalse( $fScore->isEmptyFunction() );
-
-               $array = $fScore->toArray();
-               $this->assertTrue( isset( 
$array['function_score']['functions'][0] ) );
-               $array = $array['function_score']['functions'][0];
-               $this->assertTrue( isset( $array['script_score'] ) );
        }
 
        public function testNamespacesBoost() {

-- 
To view, visit https://gerrit.wikimedia.org/r/281964
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1614ed5fa40cbef1e9bb4de200477ace96539dcb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: DCausse <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to