1. @sitecore-cloudsdk/search/browser

ComparisonFilter

Version:

Type

Class

Extends

BaseFilter

Import path

@sitecore-cloudsdk/search/browser

A filter with relation conditions. Used for filtering search results by comparing the entity's attribute to a certain value.

Examples:

  • Return only those search results where title is equal to "Introduction".

  • Return only those search results where the number of words is less than 1000.

Constructor

ComparisonFilter(
  attributeName: string,
  operator: ComparisonOperators,
  value: unknown
)

Parameters

Name

Type

Description

attributeName

string

The entity's attribute to be compared with the value.

Example: "title", "numOfWords"

operator

ComparisonOperators

The operator used for comparing the attribute with the value.

Accepted values:

  • "eq" - equal to

  • "gt" - greater than

  • "gte" - greater than or equal to

  • "lt" - less than

  • "lte" - less than or equal to

value

unknown

The value to compare the entity's attribute with.

Example: "Introduction", 1000

Properties

Name

Type

Description

_attributeName

string

Required.

The entity's attribute to be compared with the value.

Example: "title", "numOfWords"

Methods

toDTO

Maps the ComparisonFilter instance to its DTO (data transfer object) format.

Signature

toDTO(): ComparisonFilterDTO

Return value

Returns the ComparisonFilter instance in a standardized DTO format.

If you have suggestions for improving this article, let us know!