---
title: "Filter"
slug: "filter"
abstract: "List of objects offered by Sitecore Search JavaScript SDK for React."
---
# Filter

This topic lists the various filter object definitions included in Sitecore Search JavaScript SDK for React.

A filter object that contains the attribute name, the value, and how to compare the two.

## FilterEqual

Creates a filter object that checks if an item's attribute exactly matches the value provided.

| Property | Type | Description |
| --- | --- | --- |
| `attribute` | string | Required.<br><br>Name of attribute. |
| `value` | any | Required.<br><br>The value to compare against. |

```js
query.getRequest().setSearchFilter( new FilterEqual( 'category', 'bags') );
```

```js
query.getRequest().setSearchFilter( new FilterEqual( 'type', 'blog') );
```

## FilterLessThan

Creates a filter object that checks if an item's attribute is less than the value provided.

| Property | Type | Description |
| --- | --- | --- |
| `attribute` | string | Required.<br><br>Name of attribute. |
| `value` | any | Required.<br><br>The value to compare against. |

```js
query.getRequest().setSearchFilter( new FilterLessThan( 'price', '10') );
```

## FilterGreaterThan

Creates a filter object that checks if an item's attribute is greater than the value provided.

| Property | Type | Description |
| --- | --- | --- |
| `attribute` | string | Required.<br><br>Name of attribute. |
| `value` | any | Required.<br><br>The value to compare against. |

```js
query.getRequest().setSearchFilter( new FilterGreaterThan( 'unitsAvailable', '20') );
```

## FilterLessOrEqualThan

Creates a filter object that checks if an item's attribute is less than or exactly matches the value provided.

| Property | Type | Description |
| --- | --- | --- |
| `attribute` | string | Required.<br><br>Name of attribute. |
| `value` | any | Required.<br><br>The value to compare against. |

```js
query.getRequest().setSearchFilter( new FilterLessOrEqualThan( 'price', '4') );
```

## FilterGreaterOrEqualThan

Creates a filter object that checks if an item's attribute is greater than or exactly matches the value provided.

| Property | Type | Description |
| --- | --- | --- |
| `attribute` | string | Required.<br><br>Name of attribute. |
| `value` | any | Required.<br><br>The value to compare against. |

```js
query.getRequest().setSearchFilter( new FilterGreaterOrEqualThan( 'unitsAvailable', '10') );
```

## FilterGeo

Creates a filter object that checks if an item's attribute exactly matches the value provided.

| Property | Type | Description |
| --- | --- | --- |
| `attribute` | string | Required.<br><br>Name of attribute. |
| `radius` | string | Required.<br><br>The value to compare against must include a number and the unit. See the example request below for reference.<br><br>Units accepted include "in", "ft", "yd", "mi", "nmi", "km", "m", "cm", and "mm". |
| `lat` | float | Latitude of location in decimal degrees (DD) format. Don't use spaces. For example, 23.928666 |
| `lon` | float | Longitude of location in decimal degrees (DD) format. Don't use spaces. For example, -50.928666 |

```js
query.getRequest().setSearchFilter(new FilterGeo('location', '2000km', { lat: -8.1319026, lon: -34.9022836 }));
```

## FilterAnyOf

Creates a filter object that checks if an item's attribute exactly matches any of the values in the array.

| Property | Type | Description |
| --- | --- | --- |
| `attribute` | string | Required.<br><br>Name of attribute. |
| `array` | array | Required.<br><br>The array of values to compare against. |

```js
query.getRequest().setSearchFilter( new FilterAnyOf('type', ['blog', 'webinar'] ) );
```

## FilterAnd

Creates a filter object that includes an item when it matches all the filter objects in the provided array.

| Property | Type | Description |
| --- | --- | --- |
| `array` | array | Required.<br><br>The array of filter objects to compare against. |

```js
query.getRequest().setSearchFilter( new FilterAnd ( [ new FilterEqual( 'type', 'blog'), new FilterEqual( 'category', 'movies') ] ) );
```

## FilterOr

Creates a filter object that includes an item when it matches any of the filter objects in the provided array.

| Property | Type | Description |
| --- | --- | --- |
| `array` | array | Required.<br><br>The array of filter objects to compare against. |

```js
query.getRequest().setSearchFilter( new FilterOr ( [ new FilterEqual( 'type', 'blog'), new FilterEqual( 'category', 'ezine') ] ) );
```

## FilterNot

Creates a filter object that excludes an item if its attribute matches the filter objects in the provided array.

| Property | Type | Description |
| --- | --- | --- |
| `array` | array | Required.<br><br>The array of filter objects to compare against. |

```js
query.getRequest().setSearchFilter( new FilterNot ( [ new FilterEqual( 'type', 'blog'), new FilterEqual( 'category', 'ezine') ] ) );
```

## FilterGeoWithin

Creates a filter object that excludes items outside the polygon created by an array of coordinates, known as a `point` object.

| Property | Type | Description |
| --- | --- | --- |
| `name` | string | Name or reference of location. |
| `array` | Array<Point> | Required.<br><br>Array of `point` objects |

The `point` object contains latitude and longitude coordinates. See the example request below for reference.

| Property | Type | Description |
| --- | --- | --- |
| `lat` | float | Required.<br><br>Latitude of location in decimal degrees (DD) format. Don't use spaces. For example: -28.281932 |
| `lon` | float | Required.<br><br>Longitude of location in decimal degrees (DD) format. Don't use spaces. For example: -50.928666 |

```ts
const coordinates = [
  {
    lat: -28.281932,
    lon: -55.573635,
  },
  {
    lat: -31.254713,
    lon: -50.928666,
  },
  { lat: -16.181724,
    lon: -47.217881 },
];

query.getRequest().setSearchFilter(new FilterGeoWithin('location', coordinates));
```