Skip to content

Value Conditions

Value conditions help specify how and when an operator, such a 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.

Usecase 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
}

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.

Usecase 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
}

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.

Usecase 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
}

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.

Usecase 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
}

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.

Usecase 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
}

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 conditions to function: Unit, Comparison, and Current Time Offset.

Unit

This specifies the unit of the timestamp. Can be set as either UnixMilliseconds, UnixSeconds, or UnixMinutes.

Current Time Offset

This specifies the value, given in Units, to be considered for the value comparison. This can be entered as a positive or a negative integer.

A positive value means that the rule will be evaluated with a starting point somewhere in the future. E.g., a value (in seconds) of 172800 means that the rule will begin to evaluate from a point 7 days ahead of the current time.

A negative value means that the rule will be evaluated with a starting point somewhere in the past. E.g., a value (in seconds) of -172800 means that the rule will begin to evaluate from a point 7 days in the past.

Comparison

This specifies if the Relative Date Time condition should compare the the datakey to before or after the Current Time Offset. If this value is 0, the condition will evaluate on the basis of the current time.

Should I use Before or After?

It can be confusing trying to work with the Before and After values. To better understand when to use which option, consider the following:

Before and After denote the "direction" in which the data is being evaluated. Put simply:
Before looks backwards in time, After looks ahead.

Before and after

 

When combined with a Current Time Offset, the Relative Date Time Condition can be used to evaluate, e.g., any product with a createdDate two weeks or less in the past, or a launchDate a month or less into the future.

Before and after

Usecase 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
}

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

Usecase 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
}

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