| eBay SDK for Java | |
| Attributes & Catalogs > Searching for Pre-filled Item Information > Searching for Catalog Products | |
| < Back | Next > |
Searching for Catalog Products
In order to list an item based on a stock catalog product, you first need to find the stock product. We offer a number of ways to search for stock product content (see Calls You Use to List with Pre-filled Item Information).
This section describes how to search for catalog products by using GetProductSearchResultsCall.
Searching with a Single-Attribute Search Page
Searching with a Sell-Side Product Finder
Searching with Plain-Text Keywords
Configuring and Retrieving Product Search Results
Searching with a Single-Attribute Search Page
This section summarizes how to use GetProductSearchResultsCall when you want to perform a single-attribute search (based on search attributes retrieved from GetProductSearchPageCall).
To search for stock product information by using a product search page-based search:
- The seller selects a category for a listing.
- Your application determines that the category is catalog-enabled and supports single-attribute searches (see Retrieving Category-to-Meta-Data Mappings).
- Your application retrieves the product search page meta-data for the category from your local data store. This is the search page data you stored after executing GetProductSearchPageCall (see Retrieving Product Search Page Meta-Data).
- Your application presents the search attributes (ProductSearchPage.SearchCharacteristicsSet) property and data elements (ProductSearchPage.DataElements property) to the user.
Each search and sort attribute includes a display sequence (Characteristic.DisplaySequence), which is the suggested order in which the attribute should be presented to the user (e.g., in a drop-down list). Use of the display sequence information is optional. That is, your application is not required to present sort keys to users in the same order as eBay does. Similarly, you can present the search attributes in any order.
The first sort attribute (i.e., the one with the lowest display sequence value) is also used as the default sort key to sort the products returned by GetProductSearchResultsCall, if you do not specify a sort attribute in the GetProductSearchResultsCall request.
- (Optional) The user chooses the sort order for the results. (Alternatively, just use the default sort order or specify an initial sort order without prompting the user.)
- The user selects the search criteria they want to use, such as Title, and enters a string to search on, such as "Harry Potter" (without the quotes).
- Based on the seller's selections, your application creates a
ProductSearchTypeobject.- Your application executes GetProductSearchResultsCall, passing the
ProductSearchTypeobject in the ProductSearch property of the request. See Configuring and Retrieving Product Search Results.Product Search Considerations when Listing in Two Categories
A listing can only include one set of Pre-filled Item Information. If the seller is listing an item in two categories, there are some rules that govern which category the product will be associated with.
Basically, if the primary category is catalog-enabled, the Pre-filled Item Information must be associated with that category. If the secondary category is catalog-enabled, the Pre-filled Item Information can be associated with that category only if the primary category is not also catalog-enabled.
More formally, use the following rules to determine which characteristic set to search in (and, therefore, which search meta-data to retrieve from your local data store):
- When both categories are catalog-enabled, Pre-filled Item Information will be associated with (and must be valid for) the primary category.
- If (in your application) the seller has specified that they want to list in two catalog-enabled categories that are mapped to different characteristic sets, retrieve only the search criteria that is mapped to the primary category.
- If the user specified two catalog-enabled categories that are mapped to the same characteristic set, retrieve the search criteria associated with that characteristic set from your local data store. However, be sure that when you present the search and sort criteria to the user, your application makes it clear that the user should search for and select a product that makes sense for the primary category.
- When only the primary category is catalog-enabled, the listing's Pre-filled Item Information will be associated with that category.
- When only the secondary category is catalog-enabled, the listing's Pre-filled Item Information will be associated with that category.
Searching with a Sell-Side Product Finder
This section summarizes how to use GetProductSearchResultsCall when you want to search for products in an eBay catalog (a sell-side search) based on search attributes from GetProductFinderCall or a data-source provider that implements
IProductFinderXmlProvider). Specifically, it focuses on using a product finder in the Sell Your Item use case. Note:For information about using a product finder to search for listed items (a buy-side search), see Searching by Item Specifics (Buy-Side Product Finder).
To search for stock product information by using a product finder:
- The seller selects a category for a listing.
- Your application determines that the category is catalog-enabled and has a product finder available (see Retrieving Category-to-Meta-Data Mappings).
- Your application retrieves the product finder meta-data for the category from your local data store. This is the product finder data you stored after executing GetProductFinderCall or your data-source provider class (see Retrieving Product Finder Meta-Data).
- Your application presents the product finder to the user.
If your application uses a graphical user interface, we recommend that you use the Product Finder XSL stylesheet to render the product finder. See Retrieving the Product Finder XSL Stylesheet and Working with the Product Finder XSL Stylesheet.
- The seller selects the search criteria they want to use, such as a particular Brand and Resolution.
- Based on the seller's selections, your application creates a
ProductSearchTypeobject.If you do not specify a sort attribute when you send the GetProductSearchResultsCall request, the first sort attribute is used as the default sort key to sort the products returned by GetProductSearchResultsCall. The first sort attribute is the sort attribute with the lowest display sequence value as returned from GetProductFinderCall or a data-source provider that implements
IProductFinderXmlProvider) .- Your application executes GetProductSearchResultsCall, passing the
ProductSearchTypeobject in the ProductSearch property of the request. See Searching for Catalog Products.Searching with Plain-Text Keywords
You can search on a particular keyword that appears in a product's title or Item Specifics. For this, you use GetProductSearchResultsCall and and pass in one or more text strings (with optional wildcards) in the QueryKeywords property.
When you use a keyword query, the search criteria are not restricted to the results of a product search page or product finder, so the criteria are not tied to a particular characteristic set. This means you can search across multiple characteristic sets using the same query. This is useful when the user wants to broaden their search across multiple categories. For example, a seller who sells Jazz books, Jazz CDs, and Jazz movies may want to search for "Bird" across multiple categories. Specify the characteristic set IDs of interest in the CharacteristicSetIDs field of the ProductSearch object.
This section summarizes how to use GetProductSearchResultsCall when you want to perform a plain-text keyword search.
To search for stock product information by using simple keywords:
- The seller selects one or more categories in which to search. Alternatively, the seller can search across all categories.
- If specific categories are selected, your application determines that the categories are catalog- enabled and identifies the characteristic sets to which they are mapped (see Retrieving Category-to-Meta-Data Mappings).
- The seller specifies the search criteria they want to use by entering a search string. See Searching by Keywords for a list of applicable wildcards.
- Based on the seller's selections, your application creates a
ProductSearchTypeobject.- Your application executes GetProductSearchResultsCall, passing the
ProductSearchTypeobject in the ProductSearch property of the request. See Searching for Catalog Products.Configuring and Retrieving Product Search Results
Execute GetProductSearchResultsCall to return a list of catalog products that match a user's query. As catalog content can be quite large, you cannot store product information locally in order to perform searches against the data locally. You need to execute GetProductSearchResultsCall each time you want to perform a search.
This section describes the following process:
Step 1: Define the Basic Search Criteria
Step 2: Limit the Quantity of Products Returned Per Family
Step 3: Specify the Product Sort Criteria
Step 4: Specify Pagination Properties
Step 6: Retrieve More Pages (If Necessary)
Prerequisites
- Your application's locally stored search page data is up to date (see Retrieving Product Search Page Meta-Data).
- The seller is listing in a catalog-enabled category for which the ProductSearchPageAvailable flag has a value of
true(see Retrieving Category-to-Meta-Data Mappings).- The seller has chosen to perform a single-attribute search and they have filled in a value for the attribute they want to search on.
Step 1: Define the Basic Search Criteria
To search for Pre-filled Item Information, you need to configure a query and pass it in the GetProductSearchResultsCall request.
To create a query, you create a
ProductSearchTypeobject and assign to it one or more search attributes with values that the user has selected, or specify a search string:
- When you base a search on a product search page, you specify a simple query consisting of only one attribute/value list pair.
- When you base a search on a product finder, you specify a complex query consisting of multiple attribute/value pairs. In this case, the search engine applies "AND" logic to the query.
- In either of the above cases, if an attribute can have multiple values, the search engine applies "OR" logic to the values (i.e., at least one of the specified values must match).
GetProductSearchPageCall and GetProductFinderCall return the list of attributes that can be used as search criteria (these vary per characteristic set).
For each search attribute in a product search page or product finder query, use the attribute's ValueList.ValueLiteral field(s) to specify the search strings to match. The catalog search engine is not case-sensitive, and it ignores articles (e.g., "the"), prepositions (e.g., "of"), and punctuation (e.g., ":") in the keyword string. It performs exact matches on alphanumeric strings (i.e., strings bounded by white space). This means it does not support regular expressions and other search patterns. However, you can use an asterisk (e.g., *) as a wildcard. For example, "s" would not return "My Favorite Movie: The Sequel", but "Favorite" or "Favorite Movie" or "sequel" or "seq*" would. This also means dates, ISBN values, and 12-digit Universal Product Code (UPC) values should be specified completely. The product search page and product finder meta-data for a given category often return data elements that contain useful instructions and links that your application can use to help users enter values correctly.
Note: The search engine may match on UPC values that are missing the first and/or last digit. However, eBay recommends that users specify the complete 12-digit value.
The ProductSearch property of the GetProductSearchResultsCall object takes an array of
ProductSearchTypeobjects. This lets you perform multiple queries (a batch query) in the same call. Batch queries may be useful for sellers who are listing several different items at the same time.In each query, you also specify the characteristic set in which you are searching, plus other filters and pagination instructions (see additional steps below). If you are performing a product finder-style search, also specify the ID of the product finder you are using. For keyword queries, the characteristic set IDs are optional.
GetProductSearchResults describes the properties you can set when configuring a GetProductSearchResultsCall request. The input for GetProductFamilyMembersCall is nearly identical.
The example below shows one way to configure a product search query object for a single-attribute search.
In this example, the
selCatsarray contains the category that the user selected. The search is being conducted in the DVDs & Movies characteristic set. The search attribute is the DVD title (attribute ID 183) with "Harry Potter Secrets" as the search string. The results should return approximately 50 products per page. In this case, the default maximum quantity of products per family will be used. The sort attribute is the film director (attribute ID 25080).
In this example, the
searchCatvariable specifies the category the user selected. The query specifies a maximum of 50 products per page, with a maximum of 5 products per family. The search attributes are retrieved from aMapobject that contains the data the user selected. TheProductFinderMasterclass includes a number of useful methods that make it easier to work with the attributes the user selected. For example, thenameValuesToAttributeSets( )method parses the attributes the user selected and converts the data to an array ofSearchAttributeSetobjects (if you rendered the product finder using the Product Finder XSL stylesheet). If you choose not to use theProductFinderMasterclass or if you create your own implementation ofIProductFinderMasterinterface, you would need to write additional code in order to work with the Product Finder XML and XSL stylesheet.
Step 2: Limit the Quantity of Products Returned Per Family
This step describes how to use the MaxChildrenPerFamily input filter on the ProductSearch object. In order to understand how to use this filter, you first need to understand how the search results are organized in the response.
Sometimes several versions (or editions) of a product may be available. All versions of the same product are considered to be part of the same product family. Some product families may contain only one product; others may contain many products.
If a particular product has more than one version, the versions are grouped under a header row that summarizes some common attributes that all products in the same family share. In the figure below, three product families are returned. One contains three products (versions), one contains only one product, and one contains too many products to show on the current page. A product can also have a stock photo. On the eBay Web site, the stock photo appears adjacent to the product, and it also appears in the header row.
Figure 21-1 A List of Product Search Results on the eBay Web SiteEach product in the response contains a list of attributes. If the product family members are grouped under a header row, the header contains a subset of attributes that are common to all the products in the family. The combination of attributes in the header can vary for each characteristic set, and it is based on the attributes returned in the product header rows on the eBay Web site.
In the API, the header is modeled as a ProductFamilies.ParentProduct object, and each product is a ProductFamilies.FamilyMembers object.
As some queries may return many products, you may want to retrieve one product or a few representative products per family initially. This lets the user quickly discern whether a particular group of products matches the item to be listed. Use the MaxChildrenPerFamily input filter to limit the number of members returned per family. The default is to return no more than five (5) members per family. As this call supports batch searches, each ProductSearch object can specify a different value for MaxChildrenPerFamily.
On the eBay Web site, if a product family contains only one product, no header row is shown. However, in the GetProductSearchResultCall response, the ProductFamilies.ParentProduct header object is always returned for each ProductSearchResult.AttributeSet object in the response, even if only zero or one product is returned in the ProductFamilies.FamilyMembers object.
Conversely, if a product family is large, only the header is shown on the eBay Web site (with no products). In this case, the user can click a View Versions button to view all products in that family (see Figure 21-1). Similarly, in the GetProductSearchResultCall response, if the quantity of products in the family is greater than the value of MaxChildrenPerFamily, only the product family header (the ParentProduct node) is returned, and none of the family member products are returned. In this case, the ProductFamily.hasMoreChildren flag returns a value of
trueto indicate that there are products available. You can try calling GetProductSearchResults again with a higher value in MaxChildrenPerFamily, or you can execute GetProductFamilyMembersCall to return all products in the family in paginated form (see below and see Retrieving All Members of a Product Family).If the actual quantity of products in the family is less than the value of MaxChildrenPerFamily, all product family members are returned. The ProductFamily.hasMoreChildren flag returns a value of
falsein this case.For example, suppose you pass a value of 5 in MaxChildrenPerFamily in a query. In the corresponding response:
- If the product family contains 7 products, FamilyMembers returns empty and hasMoreChildren is set to
true. Execute GetProductFamilyMembersCall to retrieve all the products in the family.- If the product family contains 1 to 5 products, FamilyMembers returns all the products and hasMoreChildren is set to
false.The maximum value you can pass in MaxChildrenPerFamily is 20000.
Step 3: Specify the Product Sort Criteria
If you want to specify the attribute by which the products will be sorted, use the SortAttributeID property of the query object. GetProductSearchPageCall and GetProductFinderCall retrieve the list of attributes that can be used as sort keys (these vary per characteristic set). If you do not specify a sort key, the default is the sort attribute that GetProductSearchPageCall or GetProductFinderCall returned with the lowest DisplaySequence value.
The sorting takes precedence over the product family groupings. This means products in the same family can be split into separate ProductFamily objects. For example, suppose you specify the title "My Favorite" as the search criterion, and you specify the Publication Year attribute as the sort key. The results would be sorted first by publication year, and related products with the same title would be grouped into a ProductFamily object. For example, several editions of "My Favorite Movie: The Sequel" released in 1999 might be returned in one ProductFamily object, and several editions of "My Favorite Movie: The Sequel" published in 2002 might be returned in another ProductFamily object. On the other hand, if the same query were sorted by title, all editions of "My Favorite Movie: The Sequel" might be returned in the same ProductFamily object.
Figure 21-2 shows a search response (on an eBay Web site) that returns six (6) products sorted by Title. Four of the products have the same title and are grouped under one product family header.
Figure 21-2 Product Search Results Sorted by TitleFigure 21-3 shows a search response that returns the same six (6) products sorted by publication year. Four products have the same title, but this time two of the products with the same title are grouped under one product family header (for the year 2000), and the other two with the same title are grouped under another header (for the year 1996).
Figure 21-3 Product Search Results Sorted by Publication YearStep 4: Specify Pagination Properties
Like other calls that support pagination, GetProductSearchResultsCall lets you control how much data to return per page.
In a product search result, each product (in the ProductFamilies.FamilyMembers array) counts as an entry. Each header (ProductFamilies.ParentProduct) also contains a set of attributes that can be considered collectively as a single row of data. Thus, each ParentProduct node can also count as an entry, unless the family contains only one product (see Specifying the Entries Per Family and Per Page).
If the current search result does not represent the last page of results (relative to the sort order), the ProductSearchResult.HasMore flag returns a value of
true.The ProductSearchResults.ApproximatePages property roughly indicates how many more pages of matching results exist. For the initial query, assign a value of 0 (zero) to the PageNumber property (to retrieve the first page). If more pages exist, call GetProductSearchResults again and increment the PageNumber value to retrieve additional pages. See Retrieve More Pages (If Necessary) for a more detailed discussion of how to retrieve additional pages.
Specifying the Entries Per Family and Per Page
These are the rules for determining the entries per product family:
- One (1) product family header with no family members present (ProductFamily.FamilyMembers is null) counts as one (1) entry.
This case would occur when the quantity of products that exist within the family exceeds MaxChildrenPerFamily (see Limit the Quantity of Products Returned Per Family).
- One (1) product family header with one (1) family member present counts as one (1) entry. Essentially, when a family contains only one product, the header and product are rolled up and treated simply as a single product. However, the API still returns separate data in the ParentProduct object and each product object (ProductFamily.FamilyMembers).
- One (1) product family header with two (2) family members present count as three (3) entries.
- There is no case in which one (1) product family header with any family members present counts as two (2) entries.
Typically, multiple product families are returned per page (depending on the size of the page, the MaxChildrenPerFamily value, and the actual quantity of products found). Use the Pagination.EntriesPerPage property to specify the approximate number of entries to retrieve per search response (i.e., per page). The actual number of entries that are returned could exceed the value by up to the value you specify in MaxChildrenPerFamily, depending on the size of the last product family returned for the page (i.e., EntriesPerPage should be considered an approximate value). If the last product family returned contains MaxChildrenPerFamily products or fewer, the extra family members are also returned to save you another call.
For example, suppose that EntriesPerPage is 50, a product family header is returned as line 49, and that product family contains eight (8) members:
- In this example, if MaxChildrenPerFamily is 8, all of this family's members are returned, and the actual entry count is 57. In this case, this family would be the last family returned for the page.
- In this example, if MaxChildrenPerFamily is a lower value like 5, then none of this family's members are returned (see Limit the Quantity of Products Returned Per Family). In this case, this product family would not be the last family returned for the page.
The maximum value you can pass in Pagination.EntriesPerPage is 50000.
Step 5: Make the API Call
Making the API call entails declaring an array of ProductSearchResult objects (to hold the return data), invoking the
getProductSearchResults( )method on GetProductSearchResultsCall, and storing thegetProductSearchResults( )return value into the previously declared array of ProductSearchResult objects.The example below shows retrieving product search results by using GetProductSearchResultsCall (the
psrcvariable). After the call is executed, the results are printed to standard output.
If no match is found or too many matches are found for a particular query, a warning is returned and the TooManyMatchesFound flag returns a value of
true. Separate errors are returned for each query passed in this batch call.If you did not specify a sort attribute in the request, the products in the response are sorted according to the sort attribute with the lowest display sequence value (0). This is the DisplaySequence that was returned in the SearchPage.SortCharacteristics object of the GetProductSearchPageCall response. For example, when you search for a book, the default sort attribute is usually Title.
Within each product (ProductSearchResult.AttributeSet.ProductFamilies.FamilyMembers) object returned from GetProductSearchResultsCall, the order of the individual attributes is indicated in the CharacteristicsSet.Characteristics.DisplaySequence property. For example, for any given book, the Title attribute is shown first, followed by the Author attribute. The order of the individual attributes shown for a given product is not affected by the sort attribute you specify in the request. The sort attribute only affects the order in which the products (and product families) are sorted.
Each product is associated with detailed information, such as film credits or information from the publisher. On the eBay site, the user clicks a View Details link to view this supplemental information. You cannot retrieve this information directly through the API. Instead, each product object returns a URL (DetailsURL) for the eBay site page that contains the information.
Figure 21-4 Additional Details for a Product on the eBay Web SiteThe response contains the results of a query, one for each query specified in the request.
See GetProductSearchResults for a summary of the fields that are returned by eBay.
Step 6: Retrieve More Pages (If Necessary)
If the current search response does not represent the last page of results (relative to the sort order), the ProductSearchResult.AttributeSet.HasMore flag returns a value of
true.
The ProductSearchResult.AttributeSet.ApproximatePages property roughly indicates how many more pages of matching results exist. The value is calculated by dividing the total quantity of products found (ProductSearchResults.AttributeSet.TotalProducts) by the median quantity of products per page examined so far (given the entry count logic described above and assuming subsequent requests will specify the same EntriesPerPage and other filters). This optimization helps to shorten this batch call's response time.
For the initial query, you specified PageNumber = 0 (the first page). If more pages exist, call GetProductSearchResults again and increment the PageNumber value to retrieve additional pages. You can retrieve additional pages as a batch query in a single call or in separate calls. For example, suppose a query would return 200 entries and each product family happens to contain no more than 4 children. If you want to retrieve about 20 entries per page (with a EntriesPerPage of 20 and a MaxChildrenPerFamily of 4), you could:
- Execute GetProductSearchResultsCall once with a list of ten ProductSearch objects, specifying identical SearchAttributes objects in each one. Increment the value of PageNumber for each ProductSearch.Pagination object.
- Execute GetProductSearchResultsCall ten times, each with one ProductSearch object specifying the SearchAttributes object, and increment the value of PageNumber in each call. (This might be desirable if you are performing several different kinds of queries in the same call.)
- Use some combination of both approaches.
The response does not return the current page number. Therefore, your application should keep track of the PageNumber value that was specified in the search request.
Step 7: Identify Products That Have Been Used to List Items
Search results can include several very similar products. If you want to determine which products other sellers have used to pre-fill their listings, examine the Product.NumItems, Product.MinPrice, and Product.MaxPrice properties for non-zero values.
The number of items is the number of active (not ended) items that were pre-filled from the product. The minimum and maximum prices are the lowest and highest prices of active and ended listings that were pre-filled from the product. Note that because the value of NumItems only represents active listings, it may have a value of 0 even though the MinPrice and MaxPrice properties have positive values. If the seller is interested in analyzing prices in order to choose a start price or reserve price, it may also be useful to use GetItemRecommendationsCall to retrieve the average start prices and average sold prices of similar items that have been sold successfully.
To retrieve details about the listed items that have been pre-filled based on a product, use GetSearchResults and pass in the product's ID. See Searching by Product ID.
Step 8: Next Steps
Each product in the response has a product ID (ProductFamily.FamilyMembers.productID). Once the seller has selected a product, use that product's ID as input to GetProductSellingPagesCall to retrieve the product's Item Specifics and other information (see Retrieving a Product's Item Specifics).
The header is not a product, so it returns the ID of one of its product children as a representative product ID. If the product family is large and only the header is returned, you can pass this ID as input to GetProductFamilyMembersCall to retrieve all products in the family. See Retrieving All Members of a Product Family. The seller can then select a product, and you can use that product's ID as input to GetProductSellingPagesCall to retrieve the product's Item Specifics and other information (see Retrieving a Product's Item Specifics).
| < Back | Next > |
| Attributes & Catalogs > Searching for Pre-filled Item Information > Searching for Catalog Products | |
| © 2005–2007 eBay Inc. All rights reserved. | |