GET Items

Search items by given user search query.

GET#

https://api.altoshift.com/v1/search

Permission: all

Example Usage#

GET /v1/search?query=phone&token=5cd3f3042cd48000372c64fd-1557394180073-88706995&skip=0&limit=20
GET /v1/search?query=phone&token=5cd3f3042cd48000372c64fd-1557394180073-88706995&geo={"filter": true,"order": "desc", "distance": "100000km","location":{"lat":-8.6830749,"lon": 115.1770584}}

Parameter#

FieldTypeDescription
queryStringSearch query given by user
tokenStringEngine's token
categoryIds optionalString[]Filter products by category ids
internalCallAuthorized optionalStringToken from requests from client panel
timeZone optionalStringuser's time zone (for stats)
sessionId optionalStringuser's session id (for stats)
type optionalStringavailable value - popular, in this case only popular products will be returned and 'query' param will be ignored. Allowed values: "popular"
skip optionalIntegerNumber of items to skip (for pagination)
limit optionalIntegerNumber of max in response (for pagination)
method optionalStringSearch method. Allowed values: "strict", "soft", "fuzzy", "all"
method_start optionalStringSearch method, start from. Allowed values: "strict", "soft", "fuzzy"
filter optionalString[]filter in url-encoded JSON, ex. filter={"term":{"brand":["LENOVO","TUCANO"]}}&filter={"range":{"price":{"gte":8452399}}}&filter={"range":{"price":{"lte":17022070}}}
sort optionalString[]sort in url-encoded JSON, ex. sort={"price": {"order": "asc"}}
agg_term_limit optionalIntegerSet custom aggregation limit, set limit of filters
min_score optionalFloatmin_score exclude results where score < min_score
collapse optionalStringGroup the products base on specific fields. The use case is for a client that want to show the search result is group by merchant when the search engine is base on product. Ex: collapse={"field":"profileId","inner_hits":{"name":"services","size":100}}
preference optionalStringParameter to make sure the same user served by same shard (effective for collapse). Usually the value is sessionId
geo optionalObjectParameter to use geolocation feature
geo.filter optionalBooleanFilter the result by provided distance, Ex: true, false
geo.distance optionalStringDistance to filter, Ex: "1km"
geo.location optionalObjectLocation of the request, Ex: {"geo": { "location": { "lat": "40.12", "lon": "-71.34" }
geo.order optionalStringSort by distance, Ex: "asc", "desc"

Success Response#

FieldTypeDescription
methodStringquery which returned the result (possible values: strict, fuzzy)
categoryProductsCountObjectKey value map, key - category id, value - number of products found by this search query in this category
searchIdStringGenerated id of the search
productsObject[]array of products found by user's query
    itemIdStringElastic product id
    image_linkStringURL of product image
    priceStringProduct current price
    availabilityStringIndicates if product is in stock or it is not
    titleStringProduct Name
    linkStringProduct link on website
    productIdStringProduct's id
    categoryIdsString[]Array of product category ids
promotedObject[]array of promoted products, same structure as for products
totalIntegerTotal number of products found by the user's query
totalCollapseIntegerTotal number of products found by the user's collapse query

Success Response Example#

{
"method": "strict",
"products": [
{
"itemId": "5be1ae37e27faf57333463d6-5be1af71a1f02f5783587a48-549",
"image_link": "https://shop02.altoshift.com/wp-content/uploads/2018/10/Polar-M600Black-1.jpg",
"price": 3927600,
"availability": true,
"title": "Polar M600 Black Heart Rate Monitor Integrated",
"link": "https://shop02.altoshift.com/product/polar-m600-black-heart-rate-monitor-integrated/",
"productId": "549",
"categoryIds": [
"15"
]
}
],
"promoted": [],
"searchId": "6b8b7e10d833beacf04651c0d2befac4",
"total": 1
}

Error Response Example#

HTTP/1.1 422 Unprocessable Entity
{
"errors": [
"query param is required"
]
}