Index: branches/wmf-deployment/includes/api/ApiQuerySearch.php |
— | — | @@ -48,7 +48,7 @@ |
49 | 49 | } |
50 | 50 | |
51 | 51 | private function run($resultPageSet = null) { |
52 | | - |
| 52 | + global $wgContLang; |
53 | 53 | $params = $this->extractRequestParams(); |
54 | 54 | |
55 | 55 | $limit = $params['limit']; |
— | — | @@ -86,7 +86,17 @@ |
87 | 87 | if (is_null($matches)) |
88 | 88 | $this->dieUsage("{$what} search is disabled", |
89 | 89 | "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 | + } |
90 | 99 | |
| 100 | + $terms = $wgContLang->convertForSearchResult($matches->termMatches()); |
91 | 101 | $titles = array (); |
92 | 102 | $count = 0; |
93 | 103 | while( $result = $matches->next() ) { |
— | — | @@ -104,6 +114,10 @@ |
105 | 115 | if (is_null($resultPageSet)) { |
106 | 116 | $vals = array(); |
107 | 117 | 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() ); |
108 | 122 | $fit = $this->getResult()->addValue(array('query', $this->getModuleName()), null, $vals); |
109 | 123 | if(!$fit) |
110 | 124 | { |
Index: branches/wmf-deployment/RELEASE-NOTES |
— | — | @@ -228,6 +228,9 @@ |
229 | 229 | * Made deleting file description pages without files possible |
230 | 230 | * (bug 18773) Add content flag to siprop=namespaces output |
231 | 231 | * (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 |
232 | 235 | |
233 | 236 | === Languages updated in 1.16 === |
234 | 237 | |