Faceted Search
The combination of the /shop/v1/{product}/meta endpoint and the base /shop/v1/{product} search endpoint is designed to
facilitate faceted search.
Faceted search means that the user's applied filters impact both the search results and the remaining available filter options.
If you wish to implement this feature, each time a user changes their selections,
you must send a request to /shop/v1/{product}/meta.
The response to this will only include options that still will result in a non-zero number of search results should they be selected.
Expressed as a linear flow:
- A request is made to
/shop/v1/cruise/metawith an empty request body. This returns both Royal Caribbean as a vendor and Antarctica as a destination. - The user chooses Royal Caribbean.
- A request is made to
/shop/v1/cruisewith"vendors": ["RC"]. This returns a list of Royal Caribbean cruises. - A request is simultaneously made to
/shop/v1/cruise/metawith"vendors": ["RC"].This no longer returns Antarctica as a destination, since Royal Caribbean does not sail there. - The page is refreshed with both the new results, and the available destinations.
- By removing Antarctica from the list dynamically, we save the user the friction of choosing it and ending up on a blank page.
Multiple Filters In Search
When filtering your search request, the logic depends on whether you are sending values for a single field or across multiple fields:
- Same Field (OR logic): If you provide multiple values inside a single field, the API returns results matching any of those values.
- Different Fields (AND logic): If you send values across multiple fields, the API returns results that match all of those fields.
Example Request
If you make a call to /shop/v1/cruise with the following JSON:
{
"vendors": ["RC", "CV"],
"origins": [
{ "type": "named", "name": "Seattle, Washington" },
{ "type": "named", "name": "Boston, Massachusetts" }
]
}
The API evaluates this as:
(Vendor = RC OR CV) AND (Origin = Seattle OR Boston)
This returns cruises that meet any of these four combinations:
- Royal Caribbean sailing from Seattle
- Royal Caribbean sailing from Boston
- Carnival sailing from Seattle
- Carnival sailing from Boston
Dynamic Filter Options (/meta)
When you pass filter values to the /shop/v1/{product}/meta endpoint, a field's selected values do not restrict its own allowedValues in the response.
They only constrain other fields. This ensures multi-select dropdowns remain populated so users can select additional options.
Example 1: Filtering by a Single Field
If you call /shop/v1/cruise/meta with a single vendors filter:
curl https://connect-dev.tstllc.net/shop/v1/cruise/meta \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "vendors": ["RC"] }'
The endpoint returns:
{
"parameters": [
{
"name": "vendors",
"label": "Cruise Line",
"kind": "enum",
"multiSelect": true,
"allowedValues": [
{ "value": "CV", "label": "Carnival" },
{ "value": "RC", "label": "Royal Caribbean" }
// ... All other vendors
]
}
],
"productSpecificFilters": [
{
"name": "ships",
"label": "Ship",
"kind": "enum",
"multiSelect": true,
"allowedValues": [
{ "value": "RC:AD", "label": "Adventure of the Seas" },
{ "value": "RC:AL", "label": "Allure of the Seas" },
{ "value": "RC:AN", "label": "Anthem of the Seas" },
{ "value": "RC:BR", "label": "Brilliance of the Seas" },
{ "value": "RC:EN", "label": "Enchantment of the Seas" },
{ "value": "RC:EX", "label": "Explorer of the Seas" }
// ... Only other Royal Caribbean ships
]
}
]
}
vendors(Unfiltered by itself): Still returns all cruise lines. Ifvendorsfiltered itself down toRC, the user wouldn't be able to add a second cruise line to their search.ships(Filtered byvendors): Restricted to only Royal Caribbean ships.
Example 2: Cross-Filtering Across Multiple Fields
If you filter by both vendors and ships in the same request:
{
"vendors": ["RC"],
"productSpecificFilters": {
"ships": ["RC:AD"]
}
}
The endpoint returns:
{
"parameters": [
{
"name": "vendors",
"label": "Cruise Line",
"kind": "enum",
"multiSelect": true,
"allowedValues": [
{ "value": "RC", "label": "Royal Caribbean" }
]
}
],
"productSpecificFilters": [
{
"name": "ships",
"label": "Ship",
"kind": "enum",
"multiSelect": true,
"allowedValues": [
{ "value": "RC:AD", "label": "Adventure of the Seas" },
{ "value": "RC:AL", "label": "Allure of the Seas" },
{ "value": "RC:AN", "label": "Anthem of the Seas" },
{ "value": "RC:BR", "label": "Brilliance of the Seas" },
{ "value": "RC:EN", "label": "Enchantment of the Seas" },
{ "value": "RC:EX", "label": "Explorer of the Seas" }
// ... Only other Royal Caribbean ships
]
}
]
}
Because each field filters every other field, the constraints now work in both directions:
vendorsis limited byships: Returns onlyRC, since Royal Caribbean is the only vendor that operates Adventure of the Seas (RC:AD).shipsis limited byvendors: Still returns all Royal Caribbean ships, allowing the user to select additionalRCships.- All other parameters (e.g.,
destinations): Limited by bothvendorsandships.