beautypg.com

Google Commerce Search Deployment Guide User Manual

Page 18

background image

one country in one language and one
currency per request.


There are two other parameters, alt and q, that are not required, but are typically passed in all
API requests. The alt parameter specifies the result format either

alt=atom

or

alt=json

can

be specified to return results in either XML (atom) or JSON format. The q parameter is used for
full text search--terms in the q parameter are matched against all properties of all items in your
feed.

Verify that the above URL works with your CX and API Key, and that you get results back from
your product feed. Now we’ll look at some of the other parameters used in API requests--try
some of these parameters with your own data to familiarize yourself with how the parameters
are specified and how they affect the returned results.

Result size and pagination
The maxResults parameter controls how many results are returned by the request. This
number can range from 0 to 1000. The default (if parameter is omitted from the request) is 25.
Depending on your site, you’ll probably want to customize this--anywhere from 20 to 100 results
are common.

The option to return 1000 results should typically not be used on all search pages. Returning
a large number of results is most often used on “View All” pages, when you want to allow the
user to see all search results on a single page, rather than clicking through page after page of
results. There is no way to return more than 1000 results.

Pagination is accomplished with the startIndex parameter and the totalItems and
itemsPerPage

elements returned in the result set. With these values you know how many

items there are in the response, and you can page through them based on how many items
per page you wish to display. The response also include the nextLink and previousLink
elements which can be used for easy next/previous navigation.

Sorting
By default, results are returned sorted by relevancy. There are a few ways you can affect
sorting: If you want to still use Google’s ranking algorithm, but bias some items higher or
lower you can use the Ranking Rules functionality in the control panel. This is useful when you
want to just bias the results, but not do a “hard-sort.” Examples include promoting best sellers,
popular brands, or demoting out-of-stock items.

Relevancy sorting is usually the best default sort option. Then you can also provide options for
users to sort their results on other fields (price, rating, size, and so on). This is accomplished
with the rankBy parameter.

Content modules
The Shopping API has several “content modules,” which enable different features in the result
set. Currently there are five content modules available:

Categories

Facets

Promotions

18