Skip to content

Value Conditions

Value conditions help specify how and when an operator, such as a filter or a merchandising rule, takes effect.

Relewise operates with the following value conditions:

  • EqualsCondition
  • LessThanCondition
  • GreaterThanCondition
  • ContainsCondition
  • DistinctCondition
  • RelativeDateTimeCondition
  • HasValueCondition

EqualsCondition

The Equals Condition looks for an exact match within a datakey. This is typically used for Boolean operators, where the condition must be either true or false.

Use case Example

json
{
  "$type": "Relewise.Client.Requests.Filters.ProductDataFilter, Relewise.Client",
  "Key": "InStock",
  "FilterOutIfKeyIsNotFound": true,
  "MustMatchAllConditions": true,
  "Conditions": {
    "Items": [
      {
        "$type": "Relewise.Client.Requests.Conditions.EqualsCondition, Relewise.Client",
        "Value": {
          "Type": "Boolean",
          "Value": true,
          "IsCollection": false
        },
        "TypeName": "EqualsCondition",
        "Negated": false
      }
    ]
  },
  "TypeName": "ProductDataFilter",
  "Negated": false
}

This filter specifies that the datakey `Instock` must Equal `true`.

LessThanCondition

The Less Than Condition specifies that a Double value must be less than the specified value. This cannot be used with non-Double datakeys, as the Value Condition looks for a numerical value to test against.

Use case Example

json
{
  "$type": "Relewise.Client.Requests.Filters.ProductDataFilter, Relewise.Client",
  "Key": "stockCount",
  "FilterOutIfKeyIsNotFound": true,
  "MustMatchAllConditions": true,
  "Conditions": {
    "Items": [
      {
        "$type": "Relewise.Client.Requests.Conditions.LessThanCondition, Relewise.Client",
        "Value": 5.0,
        "TypeName": "LessThanCondition",
        "Negated": false
      }
    ]
  },
  "TypeName": "ProductDataFilter",
  "Negated": false
}

This filter specifies that the value of the `stockCount` datakey must be less than `5`.

GreaterThanCondition

The Greater Than Condition specifies that a Double value must be Greater than the specified value. This cannot be used with non-Double datakeys, as the Value Condition looks for a numerical value to test against.

Use case Example

json
{
  "$type": "Relewise.Client.Requests.Filters.ProductDataFilter, Relewise.Client",
  "Key": "stockCount",
  "FilterOutIfKeyIsNotFound": true,
  "MustMatchAllConditions": true,
  "Conditions": {
    "Items": [
      {
        "$type": "Relewise.Client.Requests.Conditions.GreaterThanCondition, Relewise.Client",
        "Value": 5.0,
        "TypeName": "GreaterThanCondition",
        "Negated": false
      }
    ]
  },
  "TypeName": "ProductDataFilter",
  "Negated": false
}

This filter specifies that the value of the `stockCount` datakey must be greater than `5`.

ContainsCondition

The Contains Condition specifies that a datakey must contain, in part or in full, the specified value. This condition can be applied to string data, multilingual data, or double data, and checks to see if the specified value is somewhere within the datakey; if it is, the condition is met.

Use case Example

json
{
  "$type": "Relewise.Client.Requests.Filters.ProductDataFilter, Relewise.Client",
  "Key": "tags",
  "FilterOutIfKeyIsNotFound": true,
  "MustMatchAllConditions": true,
  "Conditions": {
    "Items": [
      {
        "$type": "Relewise.Client.Requests.Conditions.ContainsCondition, Relewise.Client",
        "Value": {
          "Type": "String",
          "Value": "denim",
          "IsCollection": false
        },
        "ValueCollectionEvaluationMode": "All",
        "TypeName": "ContainsCondition",
        "Negated": false
      }
    ]
  },
  "TypeName": "ProductDataFilter",
  "Negated": false
}

This filter specifies that the datakey `tags` must contain the string `denim`.

DistinctCondition

The Distinct Condition specifies that the value of a datakey can only be present a certain amount of times in the request response. This can be used to ensure that a response is varied between product or variant types; for instance, it can be used to ensure that a search request for dresses only returns a few of the same color or material, to diversify the results.

This condition only takes one setting, NumberOfOccurrencesAllowedWithTheSameValue. This is the number of times a given value is allowed to exist within the datakey specified in the filter.

Use case Example

json
{
  "$type": "Relewise.Client.Requests.Filters.ProductDataFilter, Relewise.Client",
  "Key": "color",
  "FilterOutIfKeyIsNotFound": true,
  "MustMatchAllConditions": true,
  "Conditions": {
    "Items": [
      {
        "$type": "Relewise.Client.Requests.Conditions.DistinctCondition, Relewise.Client",
        "NumberOfOccurrencesAllowedWithTheSameValue": 1,
        "TypeName": "DistinctCondition",
        "Negated": false
      }
    ]
  },
  "TypeName": "ProductDataFilter",
  "Negated": false
}

This filter specifies that any given value for the datakey `color` on products returned in the request, may only occur once.
This means, for instance, that only one occurrence of `red`, `blue`, or `green` is permitted.

RelativeDateTimeCondition

The Relative Date Time Condition looks at a double data value (that should be formatted as a 🔗unix timestamp), and compares it with the current date and time according to the specifications of the condition. This can be used to, for instance, boost a product that has been created recently to increase its visibility in search and recommendation results.

This condition takes several configurations: Timestamp Unit, Comparison, Direction, and Duration/Duration Unit

Unit

Denotes whether the Unix timestamp in your Data Key uses UnixMilliseconds, UnixSeconds, or UnixMinutes.

Comparison

This specifies if the Relative Date Time condition should compare the datakey to Earlier Than or Later Than the Direction.

Direction

This specifies the baseline for comparison; Now, Ago, or From Now. Used together with Comparison to identify what way in time the filter should apply.

Duration/Duration Unit

Used with the Directions Ago and From Now to specify the relative time period used for comparison. Can be set to Miliseconds, Seconds, Minutes, Hours, or Days.

Relative Date condition in use

An example of a Relative Date condition in use in a Merchandising Rule.

Use case Example

json
{
  "$type": "Relewise.Client.Requests.Filters.ProductDataFilter, Relewise.Client",
  "Key": "createdDate",
  "FilterOutIfKeyIsNotFound": true,
  "MustMatchAllConditions": true,
  "Conditions": {
    "Items": [
      {
        "$type": "Relewise.Client.Requests.Conditions.RelativeDateTimeCondition, Relewise.Client",
        "Comparison": "After",
        "Unit": "UnixSeconds",
        "CurrentTimeOffset": -604800,
        "TypeName": "RelativeDateTimeCondition",
        "Negated": false
      }
    ]
  },
  "TypeName": "ProductDataFilter",
  "Negated": false
}

This filter specifies that products must have a `createdDate` timestamp that is 7 days old or less.

HasValueCondition

This condition checks if a datakey has a value at all. A datakey is considered to have no value if one or more of the following conditions is met:

  • The value is null
  • The value is a list but the list is empty
  • The value is a DataObject but the object is empty

Use case Example

json
{
  "$type": "Relewise.Client.Requests.Filters.ProductDataFilter, Relewise.Client",
  "Key": "stockCount",
  "FilterOutIfKeyIsNotFound": true,
  "MustMatchAllConditions": true,
  "Conditions": {
    "Items": [
      {
        "$type": "Relewise.Client.Requests.Conditions.HasValueCondition, Relewise.Client",
        "TypeName": "HasValueCondition",
        "Negated": false
      }
    ]
  },
  "TypeName": "ProductDataFilter",
  "Negated": false
}

This filter specifies that products must have a given value for the datakey `stockCount`.

Don't know us? Don't worry - you can find more information about us, by visiting our main page www.relewise.com