jenkins-bot has submitted this change and it was merged.

Change subject: Extend output of runSearch.php
......................................................................


Extend output of runSearch.php

Adds page id, title text and snippets information to give
relevance lab more information to work with

Bug: T116869
Change-Id: I5d5f872a7ef540bf16f973fa7f93925d957a16f7
---
M maintenance/runSearch.php
1 file changed, 27 insertions(+), 2 deletions(-)

Approvals:
  Smalyshev: Looks good to me, but someone else must approve
  Cindy-the-browser-test-bot: Looks good to me, but someone else must approve
  DCausse: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/maintenance/runSearch.php b/maintenance/runSearch.php
index 8618f4b..44a211a 100644
--- a/maintenance/runSearch.php
+++ b/maintenance/runSearch.php
@@ -103,9 +103,34 @@
                if ( $status->isOK() ) {
                        $value = $status->getValue();
                        if ( $value instanceof ResultSet ) {
-                               $data['rows'] = $value->numRows();
+                               // these are prefix or full text results
+                               $data['totalHits'] = $value->getTotalHits();
+                               $data['rows'] = array();
+                               $result = $value->next();
+                               while ( $result ) {
+                                       $data['rows'][] = array(
+                                               'pageId' => 
$result->getTitle()->getArticleId(),
+                                               'title' => 
$result->getTitle()->getPrefixedText(),
+                                               'snippets' => array(
+                                                       'text' => 
$result->getTextSnippet( $query ),
+                                                       'title' => 
$result->getTitleSnippet(),
+                                                       'redirect' => 
$result->getRedirectSnippet(),
+                                                       'section' => 
$result->getSectionSnippet(),
+                                                       'category' => 
$result->getCategorySnippet(),
+                                               ),
+                                       );
+                                       $result = $value->next();
+                               }
                        } elseif ( is_array ($value ) ) {
-                               $data['rows'] = count( $value );
+                               // these are suggestion results
+                               $data['totalHits'] = count( $value );
+                               foreach ( $value as $row ) {
+                                       $data['rows'][] = array(
+                                               'pageId' => $row['pageId'],
+                                               'title' => 
$row['title']->getPrefixedText(),
+                                               'snippets' => array(),
+                                       );
+                               }
                        }
                } else {
                        $data['error'] = $status->getMessage()->text();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I5d5f872a7ef540bf16f973fa7f93925d957a16f7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CirrusSearch
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: Chad <[email protected]>
Gerrit-Reviewer: Cindy-the-browser-test-bot <[email protected]>
Gerrit-Reviewer: DCausse <[email protected]>
Gerrit-Reviewer: Manybubbles <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: Tjones <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to