r53905 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53904‎ | r53905 | r53906 >
Date:21:30, 28 July 2009
Author:brion
Status:ok
Tags:
Comment:
Merge r52854, r53904 to deployment -- API search enhancements
Modified paths:
  • /branches/wmf-deployment/RELEASE-NOTES (modified) (history)
  • /branches/wmf-deployment/includes/api/ApiQuerySearch.php (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/includes/api/ApiQuerySearch.php
@@ -48,7 +48,7 @@
4949 }
5050
5151 private function run($resultPageSet = null) {
52 -
 52+ global $wgContLang;
5353 $params = $this->extractRequestParams();
5454
5555 $limit = $params['limit'];
@@ -86,7 +86,17 @@
8787 if (is_null($matches))
8888 $this->dieUsage("{$what} search is disabled",
8989 "search-{$what}-disabled");
 90+
 91+ $totalhits = $matches->getTotalHits();
 92+ if( $totalhits !== null ) {
 93+ $this->getResult()->addValue( array( 'query', 'searchinfo' ), 'totalhits', $totalhits );
 94+ }
 95+ if( $matches->hasSuggestion() ) {
 96+ $this->getResult()->addValue( array( 'query', 'searchinfo' ), 'suggestion',
 97+ $matches->getSuggestionQuery() );
 98+ }
9099
 100+ $terms = $wgContLang->convertForSearchResult($matches->termMatches());
91101 $titles = array ();
92102 $count = 0;
93103 while( $result = $matches->next() ) {
@@ -104,6 +114,10 @@
105115 if (is_null($resultPageSet)) {
106116 $vals = array();
107117 ApiQueryBase::addTitleInfo($vals, $title);
 118+ $vals['snippet'] = $result->getTextSnippet($terms);
 119+ $vals['size'] = $result->getByteSize();
 120+ $vals['wordcount'] = $result->getWordCount();
 121+ $vals['timestamp'] = wfTimestamp( TS_ISO_8601, $result->getTimestamp() );
108122 $fit = $this->getResult()->addValue(array('query', $this->getModuleName()), null, $vals);
109123 if(!$fit)
110124 {
Index: branches/wmf-deployment/RELEASE-NOTES
@@ -228,6 +228,9 @@
229229 * Made deleting file description pages without files possible
230230 * (bug 18773) Add content flag to siprop=namespaces output
231231 * (bug 18785) Add siprop=languages to meta=siteinfo
 232+* Added fields to list=search output: size, wordcount, timestamp, snippet
 233+* Where supported by backend, list=search adds a 'searchinfo' element with
 234+ optional info: 'totalhits' count and 'suggestion' alternate query term
232235
233236 === Languages updated in 1.16 ===
234237

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r52854API: Add snippet field to list=search outputcatrope20:17, 7 July 2009
r53904* Added fields to list=search output: size, wordcount, timestamp, snippet...brion21:13, 28 July 2009

Status & tagging log