* Added fields to list=search output: size, wordcount, timestamp, snippet
authorBrion Vibber <brion@users.mediawiki.org>
Tue, 28 Jul 2009 21:13:48 +0000 (21:13 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Tue, 28 Jul 2009 21:13:48 +0000 (21:13 +0000)
commit27158189860fe721bf206e54325c3b536d36082c
treed885151b8f8700de9ed8031121301d01ab1dacad
parent5622644fd64c31f8466fb6204fc5ba9f37d37274
* Added fields to list=search output: size, wordcount, timestamp, snippet
* Where supported by backend, list=search adds a 'searchinfo' element with
  optional info: 'totalhits' count and 'suggestion' alternate query term

Snippets added to result items earlier by Roan; extended this with the other
byte size, word count, and timestamp available on the result items and exposed
through the regular UI.

Had to work out a backwards-compatible method for the search meta-information
with Roan; added a second 'searchinfo' element since adding attributes to
'search' would break compatibility for JSON output (despite being safe in XML).

'searchinfo' is present only if the backend supports the extra info and has
something available; 'totalhits' with a total hit count and 'suggestion' for
an alternate query suggestion (exposed as "Did you mean X?" link in UI).

Note that total hit counts can be enabled for MySQL backend now by setting
the experimental option $wgSearchMySQLTotalHits, but did-you-mean suggestions
are not yet supported and need to be tested with a hack or another backend.

Sample XML and JSON output with the new searchinfo items (which can be
present whether or not there are any result items):

<?xml version="1.0"?>
<api>
  <query>
    <searchinfo totalhits="0" suggestion="joe momma" />
    <search />
  </query>
</api>

{
"query": {
"searchinfo": {
"totalhits": 0,
"suggestion": "joe momma"
},
"search": [

]
}
}

The suggestion value is suitable for plugging back in as a search term,
if present.
RELEASE-NOTES
includes/api/ApiQuerySearch.php