Understanding search results
As you've seen, you have a choice between XML and JSON when it comes to search results. Whichever format you choose, the results provide the data needed to construct a search application. For example, you could use the following excerpted JSON data:
to construct a search results pagination widget (as on this website's search results page):
Then, you would iterate through each of the objects in the results array:
to produce the contents of your search results page:
In addition to the document's score, URI, etc., each result includes a matches array which contains one object for each matching area of text:
And within each match is a match-text array, which is a list of strings which may or may not be highlighted (highlighted when they contain the actual matching term or terms):
The XML version of the results is generally isomorphic to the JSON version. In place of the results, matches, and match-text arrays are the <search:result>, <search:snippet>/<search:match>, and <search:highlight> elements, respectively:
The above excerpt of XML results corresponds to the same data as the JSON results we saw.
Basic Search
Custom search