Topic on Extension talk:SphinxSearch/Flow

1.35.1 Mediawiki with SphinxSearch functional

1
64.148.137.131 (talkcontribs)

diff -rupN SphinxSearch/SphinxMWSearch.php /opt/SphinxSearch/SphinxMWSearch.php

--- SphinxSearch/SphinxMWSearch.php     2020-07-14 05:23:08.000000000 -0500

+++ /opt/SphinxSearch/SphinxMWSearch.php        2021-03-05 12:51:28.199277717 -0600

@@ -73,7 +73,7 @@ class SphinxMWSearch extends SearchDatab

        }

        public static function infixSearch( $namespaces, $term, $limit, &$results, $offset = 0 ) {

-               $search_engine = new SphinxMWSearch( wfGetDB( DB_REPLICA ) );

+               $search_engine = new SphinxMWSearch( wfGetLB( DB_REPLICA ) );

                $search_engine->namespaces = $namespaces;

                $search_engine->setLimitOffset( $limit, $offset );

                $result_set = $search_engine->searchText( '@page_title: ' . $term . '*' );

diff -rupN SphinxSearch/SphinxMWSearchResult.php /opt/SphinxSearch/SphinxMWSearchResult.php

--- SphinxSearch/SphinxMWSearchResult.php       2020-07-14 05:23:08.000000000 -0500

+++ /opt/SphinxSearch/SphinxMWSearchResult.php  2021-03-05 12:46:22.049271402 -0600

@@ -15,9 +15,10 @@ class SphinxMWSearchResult extends Revis

        public $sphinx_client = null;

-       public function __construct( $row, $sphinx_client ) {

+       public function __construct( $row, $sphinx_client, $terms ) {

                $this->sphinx_client = $sphinx_client;

-               $this->initFromTitle( Title::makeTitle( $row->page_namespace, $row->page_title ) );

+        $this->initFromTitle( Title::makeTitle( $row->page_namespace, $row->page_title ) );

+        $this->terms = $terms;

        }

        /**

@@ -25,7 +26,7 @@ class SphinxMWSearchResult extends Revis

         *

         * @return string highlighted text snippet

         */

-       public function getTextSnippet( $terms ) {

+       public function getTextSnippet( $terms = [] ) {

                global $wgAdvancedSearchHighlighting, $wgSphinxSearchMWHighlighter, $wgSphinxSearch_index;

                $this->initText();

@@ -34,9 +35,9 @@ class SphinxMWSearchResult extends Revis

                if ( $wgSphinxSearchMWHighlighter ) {

                        $h = new SearchHighlighter();

                        if ( $wgAdvancedSearchHighlighting ) {

-                               return $h->highlightText( $this->mText, $terms, $contextlines, $contextchars );

+                               return $h->highlightText( $this->mText, $this->terms, $contextlines, $contextchars );

                        } else {

-                               return $h->highlightSimple( $this->mText, $terms, $contextlines, $contextchars );

+                               return $h->highlightSimple( $this->mText, $this->terms, $contextlines, $contextchars );

                        }

                }

@@ -51,7 +52,7 @@ class SphinxMWSearchResult extends Revis

                $excerpts = $this->sphinx_client->BuildExcerpts(

                        [ $this->mText ],

                        $wgSphinxSearch_index,

-                       implode( ' ', $terms ),

+                       implode( ' ', $this->terms ),

                        $excerpts_opt

                );

diff -rupN SphinxSearch/SphinxMWSearchResultSet.php /opt/SphinxSearch/SphinxMWSearchResultSet.php

--- SphinxSearch/SphinxMWSearchResultSet.php    2020-07-14 05:23:08.000000000 -0500

+++ /opt/SphinxSearch/SphinxMWSearchResultSet.php       2021-03-05 12:47:39.304272996 -0600

@@ -233,7 +233,7 @@ class SphinxMWSearchResultSet extends Se

                if ( isset( $this->mResultSet[$this->mNdx] ) ) {

                        $row = $this->mResultSet[$this->mNdx];

                        ++$this->mNdx;

-                       return new SphinxMWSearchResult( $row, $this->sphinx_client );

+                       return new SphinxMWSearchResult( $row, $this->sphinx_client, $this->mTerms );

                } else {

                        return false;

                }

Reply to "1.35.1 Mediawiki with SphinxSearch functional"