Search

The search endpoint is the heart of the Makaira Marketing Suite when it comes to searching for products in a classic shop scenario.
It is used for your autosuggest and search results as well as for listing products on category or manufacturer pages.

Executes a search request and returns ranked results across products, categories, manufacturers, and suggestions. Authenticate with HMAC using an API key that includes search permissions, or with a Bearer JWT.

Request

POST /search/

Headers

HeaderValue
AuthorizationBearer <token>
Content-Typeapplication/json
X-Makaira-InstanceYour Makaira instance identifier

Request Body

FieldTypeRequiredDescription
isSearchbooleanYesSet to true for full-text search (e.g. autosuggest), false for listing pages (e.g. category or manufacturer pages).
searchPhrasestringYesThe search term entered by the user. Use an empty string for listing-page requests.
enableAggregationsbooleanYesSet to true to include filter aggregations in the response.
aggregationsobjectYesActive filter selections. Pass an empty object or array when no filters are applied.
sortingobjectYesSorting configuration. Pass an empty object or array to use the default relevance sort. Example: {"price": "asc"}.
countintegerYesNumber of items to return per page.
offsetintegerYesPagination offset (0-based).
constraintsobjectYesQuery constraints. See table below.
fieldsarrayNoList of document fields to include in the response. An empty array returns all available fields.
apiVersionstringNoAPI version string (e.g. 2018.6).
enableHookbooleanNoSet to false to bypass any configured search query hooks. Defaults to true.

Constraints

ConstraintTypeRequiredDescription
query.shop_idstringYesFilters results to a specific shop. Only relevant in multi-shop setups.
query.languagestringYesLanguage identifier for the search index (e.g. de, en).
query.use_stockstringNoWhen set to "true", excludes out-of-stock products.
query.variant_countintegerNoMaximum number of variants to return per product. Must be an integer ≥ 1. Values exceeding the server-configured maximum are clamped to that maximum. Omitting this field returns up to the server-configured maximum. Invalid values (non-integer, zero, or negative) return a 400 Bad Request error.
query.variant_sortingobjectNoSort variants within each product group by a specific field. Example: {"price": "asc"}.
query.use_child_attribute_sortingbooleanNoWhen true, sorts product groups by the aggregated value of a specific variant attribute. Use together with query.attribute_id, query.attribute_type, query.attribute_sort_order, and query.attribute_aggregation_mode.
query.attribute_idstringNoThe ID of the attribute to sort by. Required when query.use_child_attribute_sorting is true.
query.attribute_typestringNoThe attribute type (e.g. attributeInt, attributeStr, attributeFloat). Required when query.use_child_attribute_sorting is true.
query.attribute_sort_orderstringNoSort direction: asc or desc. Defaults to desc. Used with query.use_child_attribute_sorting.
query.attribute_aggregation_modestringNoAggregation mode across variant values: max, min, avg, or sum. Defaults to max. Used with query.use_child_attribute_sorting.
oi.user.agentstringNoUser agent string. Required for personalization.
oi.user.ipstringNoUser IP address. Required for personalization.

Example Request

{
  "searchPhrase": "kite",
  "constraints": {
    "query.shop_id": 1,
    "query.language": "de",
    "query.use_stock": true
  },
  "enableAggregations": true,
  "isSearch": true,
  "aggregations": [],
  "sorting": [],
  "fields": ["title"],
  "count": 50,
  "offset": 0,
  "apiVersion": "2018.6"
}

Example Request — Attribute-based variant sorting

Sorts product groups by the minimum price of their variants:

{
  "searchPhrase": "jacket",
  "constraints": {
    "query.shop_id": 1,
    "query.language": "de",
    "query.use_child_attribute_sorting": true,
    "query.attribute_id": "attribute-price-id",
    "query.attribute_type": "attributeFloat",
    "query.attribute_sort_order": "asc",
    "query.attribute_aggregation_mode": "min"
  },
  "enableAggregations": true,
  "isSearch": true,
  "aggregations": [],
  "sorting": [],
  "count": 50,
  "offset": 0
}

Response

Returns a JSON object containing result buckets for each document type.

Response Body

FieldTypeDescription
productobjectProduct search results. Contains items, count, total, and aggregations.
categoryobjectCategory results. Contains items, count, and total.
manufacturerobjectManufacturer results. Contains items, count, and total.
suggestionobjectAutosuggest results. Contains items, count, and total.

Each result bucket item has:

FieldTypeDescription
idstringDocument ID.
fieldsobjectDocument fields as requested.
Body Params
boolean
required

Set this to true when the request is an actual search request (e.g. autosuggest) and to false when you want to perform a request for products on a category or manufacturer page.

string
required

The term to search for.

boolean
required

Set this to true when you want aggregations to be included in the response, otherwhise false.

aggregations
object
required

List of selected values to filter for.

sorting
object
required
fields
array

List of additional fields to be included in the response. When the value is an empty array, the response will include all available fields for each item.

fields
string
required

Number of products to be returned in the response.

string
required

The offset to start returning products from. In combination with the "count" property this is used for paginating the search results.

constraints
object
required
string
boolean

If set to false, the search query hook will be disabled. Default value is true(if not specify)

Headers
string
required

Makaira Instance ID

Response

Language
Credentials
Bearer
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json