DCausse has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/347824 )

Change subject: Fix problem when using the default similarity
......................................................................

Fix problem when using the default similarity

'default' is no longer a similarity provided by elastic
and cannot be used directly.
Cirrus will now throw an error if the similarity for a
specific field cannot be determined.
Fix and deprecated the default profile and set it to classic.
Add a new "classic" profile and make it the default.

Bug: T160301
Change-Id: I3ae80c142f1d14dc54e782319bdf10cd653dc2c1
---
M CirrusSearch.php
M docs/settings.txt
M includes/Search/TextIndexField.php
M profiles/SimilarityProfiles.php
4 files changed, 20 insertions(+), 7 deletions(-)


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

diff --git a/CirrusSearch.php b/CirrusSearch.php
index 31ef36c..6792629 100644
--- a/CirrusSearch.php
+++ b/CirrusSearch.php
@@ -365,7 +365,7 @@
 
 // Configure the similarity module
 // see profile/SimilarityProfiles.php for more details
-$wgCirrusSearchSimilarityProfile = 'default';
+$wgCirrusSearchSimilarityProfile = 'classic';
 
 // Weight of fields.  Must be integers not decimals.  If 
$wgCirrusSearchAllFields['use']
 // is false this can be changed on the fly.  If it is true then changes to 
this require
diff --git a/docs/settings.txt b/docs/settings.txt
index 6902115..1968ffc 100644
--- a/docs/settings.txt
+++ b/docs/settings.txt
@@ -503,7 +503,7 @@
 ; $wgCirrusSearchSimilarityProfile
 
 Default:
-    $wgCirrusSearchSimilarityProfile = 'default';
+    $wgCirrusSearchSimilarityProfile = 'classic';
 
 Configure the similarity module.
 See profile/SimilarityProfiles.php for more details.
@@ -1487,4 +1487,4 @@
     $wgCirrusSearchIndexDeletes = false;
 
 Whether deletes are indexed for archive search when page is deleted. Note that 
searching
-for archived pages can be done by manually indexing them too.
\ No newline at end of file
+for archived pages can be done by manually indexing them too.
diff --git a/includes/Search/TextIndexField.php 
b/includes/Search/TextIndexField.php
index d13a46c..a059a08 100644
--- a/includes/Search/TextIndexField.php
+++ b/includes/Search/TextIndexField.php
@@ -221,7 +221,7 @@
                        'CirrusSearchSimilarityProfiles',
                        $config->get( 'CirrusSearchSimilarityProfile' )
                );
-               $fieldSimilarity = 'default';
+               $fieldSimilarity = null;
                if ( isset( $similarity['fields'] ) ) {
                        if( isset( $similarity['fields'][$field] ) ) {
                                $fieldSimilarity = 
$similarity['fields'][$field];
@@ -233,6 +233,9 @@
                                $fieldSimilarity = 
$similarity['fields']["$field.$analyzer"];
                        }
                }
+               if ( is_null ( $fieldSimilarity ) ) {
+                       throw new \RuntimeException( "Invalid similarity 
profile, unable to infer the similarity for the field $field, (defining a 
__default__ field might solve the issue" );
+               }
                return $fieldSimilarity;
        }
 }
diff --git a/profiles/SimilarityProfiles.php b/profiles/SimilarityProfiles.php
index 234deaf..13d96ed 100644
--- a/profiles/SimilarityProfiles.php
+++ b/profiles/SimilarityProfiles.php
@@ -26,9 +26,19 @@
  */
 
 $wgCirrusSearchSimilarityProfiles = [
-       // default profile, uses the classic TF/IDF from Lucene. With ES5
-       // this will become BM25.
-       'default' => [],
+       // default profile, uses the classic TF/IDF from Lucene.
+       // deprecated the use of the name default is confusing
+       'default' => [
+               'fields' => [
+                       '__default__' => 'classic'
+               ]
+       ],
+       // classic profile, uses the classic TF/IDF from Lucene.
+       'classic' => [
+               'fields' => [
+                       '__default__' => 'classic'
+               ]
+       ],
        // BM25 with default values for k and a for all fields
        'bm25_with_defaults' => [
                'similarity' => [

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ae80c142f1d14dc54e782319bdf10cd653dc2c1
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