Skip to main content

Facets & Filters

Request

Method: POST

Endpoint: /v1.4/search

Any fields returned in the results can be used for Aggregation (facets) and Range (filter min and max). For the fields you specify for aggregation and range, you will get the associated document count (for the aggregation) and min & max range (for the range) as part of your results, which will help you display the information (count & range) in the F/E.

Aggregation: Any text field can be used for "Aggregation" (in the results, the fields that have double quotes around the value are the "text" fields). For example - "search_category": "Televisions".

Range: Any number field can be used for "Range" (in the results, the fields that do NOT have the double quotes around the value are the "number" fields). For example - "org_price": 1.0.

Fields

FieldTypeRequiredDefaultDescription
customer_idStringYesRandom unique customer id generate by PA tracker
website_idStringYesClient unique website id provided by PA
qStringYesInput search query string
clientStringYesUnique client shortcode provided by PA
startIntegerYesDefines the offset from the first result you want to fetch
sizeIntegerNo20The max number of results you want returned with your query
scopeObjectNoSearch results will be filtered based on what you put in the scope.

Examples

Example 1 - Scope for aggregation/text (facet filtering)

Send a request to get search results filtered by values of Type product OR Type article

curl --location 'https://SEARCH_DOMAIN_URL/v1.4/search' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer cGFTZXXXXXXXXXXXXXXXA==' \
--data '{
"customer_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"website_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"q": "SEARCH STRING",
"client": "CLIENT SHORTCODE",
"start": 0,
"size": 1,
"scope": {
"Type": ["product", "article"]}
}'

Example 2 - Scope for range/number

Send a request to get search results filtered by a range of height.

curl --location 'https://SEARCH_DOMAIN_URL/v1.4/search' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer cGFTZXXXXXXXXXXXXXXXA==' \
--data '{
"customer_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"website_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"q": "SEARCH STRING",
"client": "CLIENT SHORTCODE",
"start": 0,
"size": 1,
"scope": {
"height": {
"min": 10,
"max": 1000}}
}'

Example 3 - Scope using a combination of text & number and multiple filters.

Send a request to get search results filtered by values of Type product AND Brand LG AND a range of height.

curl --location 'https://SEARCH_DOMAIN_URL/v1.4/search' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer cGFTZXXXXXXXXXXXXXXXA==' \
--data '{
"customer_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"website_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"q": "SEARCH STRING",
"client": "CLIENT SHORTCODE",
"start": 0,
"size": 1,
"scope": {
"Type": ["product"],
"brand": ["LG"],
"height": {
"min": 10,
"max": 1000}}
}'