﻿---
title: Comparison operators
description: PromQL comparison operators in Elasticsearch.
url: https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators/comparison
products:
  - Elasticsearch
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Preview in 9.4
---

# Comparison operators
These binary operators compare scalars and instant vectors. By default they act as filters; with the [`bool` modifier](/elastic/elasticsearch/tree/main/reference/query-languages/promql/operators#promql-operators-bool-modifier) they return `0` or `1`.
In Elasticsearch, a comparison is evaluated only at the top level of an expression and only with a scalar literal on the right-hand side. Comparisons between two instant vectors, and nested comparisons, return a client error (4xx). See [PromQL limitations](/elastic/elasticsearch/tree/main/reference/query-languages/promql/promql-limitations#promql-limitations-unsupported-constructs).

## `==` (eq)

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Compares elements for equality. By default, acts as a filter. With the bool modifier, returns 0 or 1.
**Operands**
<definitions>
  <definition term="lhs, rhs (instant_vector or scalar)">
    The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
  </definition>
</definitions>

**Returns**
An `instant_vector`, or a `scalar` when both operands are scalars.
**Example**
```
requests_total == 256
```


## `>` (gt)

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Compares elements where the left operand is greater than the right. By default, acts as a filter. With the bool modifier, returns 0 or 1.
**Operands**
<definitions>
  <definition term="lhs, rhs (instant_vector or scalar)">
    The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
  </definition>
</definitions>

**Returns**
An `instant_vector`, or a `scalar` when both operands are scalars.
**Example**
```
requests_total > 256
```


## `>=` (gte)

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Compares elements where the left operand is greater than or equal to the right. By default, acts as a filter. With the bool modifier, returns 0 or 1.
**Operands**
<definitions>
  <definition term="lhs, rhs (instant_vector or scalar)">
    The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
  </definition>
</definitions>

**Returns**
An `instant_vector`, or a `scalar` when both operands are scalars.
**Example**
```
requests_total >= 256
```


## `<` (lt)

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Compares elements where the left operand is less than the right. By default, acts as a filter. With the bool modifier, returns 0 or 1.
**Operands**
<definitions>
  <definition term="lhs, rhs (instant_vector or scalar)">
    The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
  </definition>
</definitions>

**Returns**
An `instant_vector`, or a `scalar` when both operands are scalars.
**Example**
```
requests_total < 256
```


## `<=` (lte)

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Compares elements where the left operand is less than or equal to the right. By default, acts as a filter. With the bool modifier, returns 0 or 1.
**Operands**
<definitions>
  <definition term="lhs, rhs (instant_vector or scalar)">
    The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
  </definition>
</definitions>

**Returns**
An `instant_vector`, or a `scalar` when both operands are scalars.
**Example**
```
requests_total <= 256
```


## `!=` (neq)

<applies-to>Elastic Stack: Preview in 9.4</applies-to>
Compares elements for inequality. By default, acts as a filter. With the bool modifier, returns 0 or 1.
**Operands**
<definitions>
  <definition term="lhs, rhs (instant_vector or scalar)">
    The left and right operands. When one side is a scalar, the operator applies between the scalar and each sample of the vector.
  </definition>
</definitions>

**Returns**
An `instant_vector`, or a `scalar` when both operands are scalars.
**Example**
```
requests_error != 0
```