Search API reference
Learn how to make a Search API request to run a search query and retrieve the search results with Frosmo Search.
Requests
URL
The URL for Search API requests is https://<platform_instance>/search
, where <platform_instance>
is the domain name of your Frosmo Platform instance.
To get the URL for your Frosmo Platform instance:
-
In the header, click your username, and select API Access.
-
In the Search API section, copy the URL.
Authentication
The Search API does not require authentication.
Methods
The Search API supports the GET HTTP method for running search queries and retrieving the search results.
Syntax
To run a search query and retrieve the search results, make the following GET request:
GET https://<platform_instance>/search?origin=<site_origin>&
q=<search_query>&
filter=<filter_query>&
sortBy=<list_of_sort_fields>
Parameters
Parameter | Description | Type | Role | Example |
---|---|---|---|---|
| To find out your site's origin, see Getting your site origin. | String | Required |
|
| Frosmo ID of the visitor who triggered the search query and for whom you want to personalize the search results. The platform uses the ID to sort the search results based on the visitor's affinities. To get the ID, see Getting a visitor's Frosmo ID. note This parameter is required if the results are sorted by affinity. Sorting by affinity can be defined using the | String | Optional |
|
| Search results page to return. This is the number of the page. If the total number of search results exceeds the Page numbering starts at The default is note The number of results returned for a single page depends on the value of the UsageIf you need to get more results than fits on the first page, make multiple requests as follows:
For example, if your search query matches 600 results, and your page size is 250, the results are spread over three pages (250 + 250 + 100) and you therefore need to make there requests, for pages 1, 2, and 3. | Number | Optional |
|
| Number of results to return. note This value is both per search results page and per request since a single API request returns the results from a single page. The maximum number of results depends on the
If you need to get more results than the maximum, make multiple requests where you incrementally paginate over the results using the The default is | Number | Optional |
|
| The search returns all items that have an attribute whose value matches the search term. The match can be exact, partial, approximate ("fuzzy"), or synonym-based. The match ignores case. note The attributes that the search checks for matches depend on the target attributes defined for the site. UsageThe basic syntax is:
If you omit this parameter, the search returns all items. tip To apply filtering on all items, omit | String | Optional |
|
| Filter for refining the search results based on the value of an item attribute. The API applies the filter on the results returned by the search term ( note The attributes that you can use for filtering depend on the site's basic search setup. UsageThe basic syntax is:
The filter returns all items that have an attribute whose value matches the target value. The match can be exact or partial. The match ignores case. For example, note To filter by item ID, use
The value can be a single word or phrase. If the value contains one or more commas or other reserved characters, wrap the value in backtick characters (
The filter supports the following use cases: Match a single valueTo filter by a single value, define the value as is:
Examples
Match multiple valuesTo filter by multiple values, define the values as an array:
The filter returns all items that have an attribute whose value matches one of the target values. The match can be exact or partial. The match ignores case. Examples
Match an exact valueTo filter by an exact value, use the equality operator (
Examples
Match by negationTo filter by NOT matching a value, use the inequality operator (
Examples
note Negative filtering is only valid for faceted attributes. Faceting is defined in the site's basic search setup. Match numeric valuesTo filter by numeric values, use a standard comparison operator (
You can also combine the range operator with multiple values to match any value in a number range or an exact numeric value:
Examples
Match in arraysTo filter by a value in an array attribute, use the equality operator (
The filter returns all items that have an array attribute with a value that matches the defined value or one of the defined values. The match can be exact or partial. The match ignores case. Examples
note Array filtering is only valid for array attributes. Match multiple conditionsTo filter by multiple conditions, use the
You can use all the value operators described above to define the different conditions. Examples
| String | Optional | See the use case examples in the parameter description. |
| List of fields and their respective sort orders for sorting the search results. The default sorting rules depend on the site's basic search setup. If you define the UsageThe basic syntax is:
You can define up to three fields to sort by. Separate multiple fields with a comma. By default, you can use the following fields for sorting search results.
The possible sort order values are:
The following example sorts the search results first by affinity, then by text match score, and finally by total item boosting score (as the API automatically adds Example
How the sorting worksThe API uses the sorting fields as tiebreakers:
| String | Optional |
|
| List of item attributes whose data to include in the search results. The API returns the attribute data by item in the note If you define this field, the note To include IDs in the item data, use
info The API always returns matching item IDs in the UsageThe basic syntax is:
You can return any item attribute indexed by the search engine. The indexed attributes are defined in the site's basic search setup. You can return multiple attributes, up to all the attributes indexed for the site. Separate multiple attributes with a comma. If you omit this parameter, the search returns only item IDs. | String | Optional |
|
Request examples
GET https://inpref.com/search?origin=shop_company_com&
q=boots
GET https://inpref.com/search?origin=shop_company_com&
q=boots&
filter=brand:Lumberland
GET https://inpref.com/search?origin=shop_company_com&
filter=brand:Lumberland||type:shoes
GET https://inpref.com/search?origin=shop_company_com&
cookieId=dsr77t.kstzihlx&
q=boots&
sortBy=frosmo_affinity:desc
GET https://inpref.com/search?origin=shop_company_com&
q=boots&
includeFields=name,brand
# Page 1
GET https://inpref.com/search?origin=shop_company_com&
page=1&
perPage=2000&
q=boots
# Page 2
GET https://inpref.com/search?origin=shop_company_com&
page=2&
perPage=2000&
q=boots
# Page 3
GET https://inpref.com/search?origin=shop_company_com&
page=3&
perPage=2000&
q=boots
# ...
Responses
Success
On a success, the Search API returns the search results in a JSON object. The response status code is 200
.
The response object contains the following properties:
-
found
: Total number of matching items. This can be greater thanperPage
. -
ids
: Array of matching item IDs. -
documents
: Array of matching items. Each item is an object that contains the item attributes defined in theincludeFields
parameter. If theincludeFields
parameter is empty or undefined, the array is empty.
The results (ids
and documents
) are sorted using the logic defined in the sortBy
parameter or, if the parameter is empty or undefined, using the default sorting rules defined in the site's basic search setup. The number of results is limited by perPage.
GET https://inpref.com/search?origin=shop_company_com&
q=boots&
includeFields=:_id,name
{
"found": 283,
"ids": [
"58585",
"13277",
"31981",
...
],
"documents": [
{
"_id": "58585",
"name": "Casual Engineer Boots"
},
{
"_id": "13277",
"name": "Comfort Logger Boots"
},
{
"_id": "31981",
"name": "Lace-up Leather Boots"
},
...
]
}
Error
On an error, the Search API returns the response status code 400
and an error message.
Error message | Description | Solution |
---|---|---|
| The | Make sure the |
| The value of the | Provide a valid site origin as the value of the To find out your site's origin, see Getting your site origin. |
| The value of the | Provide a positive integer as the value for the |
| The value of the | Provide a positive integer that respects the minimum and maximum values for the |
|
| Provide the name of an attribute that can be used for filtering the search results. Make sure the name is correctly spelled. note The attributes that you can use for filtering depend on the site's basic search setup. |
| The value of the | Make sure the value of the |
|
| Provide the name of field that can be used for sorting the search results. Make sure the name is correctly spelled. |
| The sort order value for the | Use one of the allowed sort order values:
|