瀏覽代碼

Add docs for the IN operator (ESQL-1216)

Document the IN operator.

---------

Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
Bogdan Pintea 2 年之前
父節點
當前提交
82a4715eca

+ 13 - 6
docs/reference/esql/esql-syntax.asciidoc

@@ -66,15 +66,22 @@ FROM employees
 [discrete]
 [[esql-operators]]
 === Operators
-These comparison operators are supported:
+These binary comparison operators are supported:
 
 * equality: `==`
 * inequality: `!=`
-* comparison: 
-** less than: `<`
-** less than or equal: `<=`
-** larger than: `>`
-** larger than or equal: `>=`
+* less than: `<`
+* less than or equal: `<=`
+* larger than: `>`
+* larger than or equal: `>=`
+
+The `IN` operator allows testing whether a field or expression equals
+an element in a list of literals, fields or expressions:
+
+[source,esql]
+----
+include::{esql-specs}/row.csv-spec[tag=in-with-expressions]
+----
 
 For string comparison using wildcards or regular expressions, use `LIKE` or
 `RLIKE`:

+ 13 - 0
x-pack/plugin/esql/qa/testFixtures/src/main/resources/row.csv-spec

@@ -269,6 +269,19 @@ a:integer|b:integer
 1        |2
 ;
 
+inWithExpressions
+// tag::in-with-expressions[]
+ROW a = 1, b = 4, c = 3
+| WHERE c-a IN (3, b / 2, a)
+// end::in-with-expressions[]
+;
+
+// tag::in-with-expressions-result[]
+a:integer |b:integer |c:integer
+1         |4         |3
+// end::in-with-expressions-result[]
+;
+
 convertMvToMvDifferentCardinality-IgnoreWarnings
 row strings = ["1", "2", "three"] | eval ints = to_int(strings);