Breadcrumbs

Offer search - Filters

On the following filters

  • an AND operator is applied between filters

  • an OR operator is applied in the filter

For instance: &query=nike air max&filterBy=color:red blue&filterBy=brandId:12352&filterLowerThan=price:100 means that we want some nike air max and the (color red or color blue) and a specific brand and the price lower than 100.

Filter by a full text search on the offer

The full text search is mainly applied on title and description fields within the offers.

Parameter

Type

Domain

Default

Description

Example

query

string

Less than 50 characters


Full text search by a query.

query=air max 98

queryMatchStrength

string

{'all', 'some', 'any'}

'some'

Query match strength allows to restrict the offers matching the query. all means all terms must match (AND operator between terms). some means at least some of the terms must match. any means at least one of the terms must match (OR operator between terms).

queryMatchStrength=any

Filter on specific fields

Filter target

An offer have fields, those fields

  • are in a specific distribution (discrete or continuous)

  • have a type (string, date, float, long, boolean...)

  • have possible actions, one of those actions is canFilter

To know the details on fields, there are several possibilities:

  • on the coding phase you can see possible actions and distribution in the model details

  • on runtime this information is available

    • on fields metadata in the response

    • on facets in the response when requested

Filter syntax

The syntax is the following to filter on a specific field:

<filterOperator>=<filterKey>:<firstValue> <secondValue>

  • The filterKey is provided by the facet.

  • The filterOperator depends on the field distribution also provided by the facet.

The API apply an OR operator between each value of a filter.

Warning:

  • the client should wrapp all the filter values with the " character so that all values with a space (values separator in the syntax) or a character : (separator between filterKey and values in the syntax) are properly handled.

  • the client should be consistent in the way is wrapping or not the values: either all the values are wrapped or none.

So for instance on the facet ethicalType,

  • The filterKey is ethicalType

  • The filterOperator is filterBy.

We can use it this way:

Example

Syntax

Action done

Only one value

filterBy=ethicalType:Organic

Return offers with ethicalType equals Organic

Only one value wrapped by "

filterBy=ethicalType:"Making:Handmade"

Return offers with ethicalType equals Making:Handmade


filterBy=ethicalType:"Environmental Friendly"

Return offers with ethicalType equals Environmental Friendly

Or between two values

filterBy=ethicalType:Organic Vegan

Return offers with ethicalType equals Organic or Vegan


filterBy=ethicalType:"Organic" "Vegan"

Return offers with ethicalType equals Organic or Vegan

More values

filterBy=ethicalType:"Environmental Friendly" "Organic" "Making:Handmade" "Recycled material"

Return offers with ethicalType equals Environmental Friendly or Organic or Making:Handmade or Recycled material

You can use several filters on a request. The API apply an AND operator between each filter.

Filter error cases

  • The client should make sure the field exists.

  • The client should make sure the field can be filtered.

  • The client should respect the field type.

  • The client should respect the field domain.

  • The client should respect the field distribution.

  • The client should use only once a filterKey, otherwise it doesn't make sense: fields are not multivalued.

Examples:

Example

Syntax

Error

Misspelled field

filterBy=EthicalType:Organic

Returned by the API: Unknown field: EthicalType. It is not in camelCase. Please check the 'Offer search > Model' documentation section to get more details.

Field that cannot be filtered

filterBy=description:Organic

Returned by the API: Field(s) 'description' cannot be filtered. Please check the 'Offer search > Request > Meta > Filters' documentation section to get more details.

Do not provide the right type

filterGreaterThan=price:100EURO

Returned by the API: Invalid values [100EURO] for filter on field 'price'

Provide a value not in the domain

filterBy=categoryId:9999999

Returned by the API: Unknown values [9999999] for filter on field 'categoryId'

Use a filterOperator not allowed

filterGreaterThan=ethicalType:"Environmental Friendly"

Returned by the API: Filter FilterGreaterThan should be applied to a field with a continuous distribution. On discrete distributions such as 'ethicalType' use filterBy. Please check the 'Offer search > Request > Meta' documentation section to get more details.

Use twice the same filterKey

filterBy=ethicalType:Organic&filterBy=ethicalType:"Environmental Friendly"

Returned by the API: Provided parameters are inconsistent: 'ethicalType' must be present at most once. Please check the 'Offer search > Request > Filter on discrete distribution' documentation section to get more details.

Filter on discrete distribution

Fields can have discrete values. For instance: offerId, merchantId, brandId, categoryId, codeEan... To know which field has a discrete distribution, use fieldsMeta parameters and check the canFilter and distribution property.

A filter is usually used after a facet. This one expose the distribution of the field. See the facets usage.

If the distribution of a field is discrete, the available filterOperator is filterBy only.

Filter Criteria

Type

Description

Example

filterBy=[filterKey]

string

Filter on a field. The value should come from the facet related to the field. Several values can be provided: use a space ' ' between them. The operator OR will be applied between the different values.

filterBy=type:"athletism" "hiking"

filterBy=categoryId

string

Filter on a categoryId. Categories that are descendants of the specified category are implicitly included.

&filterBy=categoryId:124901

filterBy=merchantId

string

Filter on a merchantId.

&filterBy=merchantId:25234

filterBy=offerId

string

Filter on a offerId.

&filterBy=offerId:"7701b65469b409bcba9272e6be514c6d"

filterBy=codeEan

string

Filter on a ean.

&filterBy=codeEan:53255452354 25234

filterBy=brandId

string

Filter on a brandId.

&filterBy=brandId:53255452354 25234

Each separated filterBy parameter is interpreted as an AND. Thus, if by mistake you put in your query something similar to &filterBy=merchantId:77&filterBy=merchantId:88 then you will get an error, as the same offer can't have two merchantId values. On the other hand, to retrieve, for example, offers from two merchants in the same request, your query should be similar to &filterBy=merchantId:77 88, as the space ' ' is interpreted as OR

If you are filtering by categoryId, please read the offers by category guide.

Filter on continuous distribution

Fields can have continuous values. For instance: price, totalPrice, rebatePercentage...
To know which field has a continuous distribution, use fieldsMeta parameters and check the canFilter and distribution property.

A filter is usually used after a facet. This one expose the distribution of the field. See the facets usage.

If the distribution of a field is continuous, the available filterOperator are the following:

Parameter

Type

Description

Example

filterGreaterThan=[filterKey]:

number

Filter on the [filterKey] '>', returns offer with all values strictly greater than the given value

filterGreaterThan=rebatePercentage:12.5

filterGreaterThanEqual=[filterKey]:

number

Filter on the [filterKey] '>=', returns offer with all values strictly greater than or equal the given value

filterGreaterThanEqual=totalPrice:150

filterLowerThan=[filterKey]:

number

Filter on the [filterKey] '<', returns offer with all values strictly lower than the given value

filterLowerThan=price:500

filterLowerThanEqual=[filterKey]:

number

Filter on the [filterKey] '<=', returns offer with all values strictly greater than or equal the given value

filterLowerThanEqual=totalPrice:500

Note: The given value should be a number: for instance 150, 12.5...

Filter on the availability of a field

Filter offers based on the existence of a field. Can be applied on a field that

  • have the filter action available

  • is optional

Check in the meta to see which field is eligible.

Filter Criteria

Type

Description

Example

filterValueExists=[field]:[boolean]

string

Filter the result based on the existence of a field.

filterValueExists=deliveryCost:true

  • For instance filterValueExists=deliveryCost:true : return only offers with a delivery cost

  • For instance filterValueExists=deliveryCost:false : return only offers with no delivery cost

  • Note : if you need both, do not use the filter