EBernhardson has uploaded a new change for review.

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

Change subject: Report ES doc id in RunSearch rather than the title page id
......................................................................

Report ES doc id in RunSearch rather than the title page id

On our test instances when we import an elasticsearch dump we
typically only load ES, and not the mysql database. Due to this
all titles report an id of 0. Instead report the doc id from
elasticsearch. Within CirrusSearch the doc id of a page is always
it's page id.

Change-Id: Ia7d2b92a1720cc5fedab4ba0bc2dd9875c9aba4a
---
M includes/Search/Result.php
M maintenance/runSearch.php
2 files changed, 9 insertions(+), 1 deletion(-)


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

diff --git a/includes/Search/Result.php b/includes/Search/Result.php
index 04b1bdb..ad41365 100644
--- a/includes/Search/Result.php
+++ b/includes/Search/Result.php
@@ -38,6 +38,7 @@
        private $wordCount;
        private $byteSize;
        private $timestamp;
+       private $docId;
 
        /**
         * Build the result.
@@ -50,6 +51,7 @@
                if ( $interwiki ) {
                        $this->setInterwiki( $result, $interwiki );
                }
+               $this->docId = $result->getParam('_id');
                $this->mTitle = Title::makeTitle( $result->namespace, 
$result->title, '', $this->interwiki );
                if ( $this->getTitle()->getNamespace() == NS_FILE ) {
                        $this->mImage = wfFindFile( $this->mTitle );
@@ -273,4 +275,8 @@
        public function getInterwikiNamespaceText() {
                return $this->interwikiNamespace;
        }
+
+       public function getDocId() {
+               return $this->docId;
+       }
 }
diff --git a/maintenance/runSearch.php b/maintenance/runSearch.php
index 44a211a..53ae5ff 100644
--- a/maintenance/runSearch.php
+++ b/maintenance/runSearch.php
@@ -109,7 +109,9 @@
                                $result = $value->next();
                                while ( $result ) {
                                        $data['rows'][] = array(
-                                               'pageId' => 
$result->getTitle()->getArticleId(),
+                                               // use getDocId() rather than 
asking the title to allow this script
+                                               // to work when a production 
index has been imported to a test es instance
+                                               'pageId' => $result->getDocId(),
                                                'title' => 
$result->getTitle()->getPrefixedText(),
                                                'snippets' => array(
                                                        'text' => 
$result->getTextSnippet( $query ),

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

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

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

Reply via email to