wo Befehl - OpenSearch Amazon-Dienst

Die vorliegende Übersetzung wurde maschinell erstellt. Im Falle eines Konflikts oder eines Widerspruchs zwischen dieser übersetzten Fassung und der englischen Fassung (einschließlich infolge von Verzögerungen bei der Übersetzung) ist die englische Fassung maßgeblich.

wo Befehl

Anmerkung

Informationen darüber, welche AWS Datenquellenintegrationen diesen PPL Befehl unterstützen, finden Sie unterBefehle.

Der where Befehl verwendet einen Bool-Ausdruck, um das Suchergebnis zu filtern. Das Ergebnis wird nur zurückgegeben, wenn der bool-Ausdruck den Wert true ergibt.

Syntax

Verwenden Sie die folgende Syntax:

where <boolean-expression>
boolischer Ausdruck
  • Optional.

  • Jeder Ausdruck, der zu einem booleschen Wert ausgewertet werden könnte.

Beispiel 1: Filtert den Ergebnissatz mit einer Bedingung

Das Beispiel zeigt, wie Dokumente aus dem Kontenindex abgerufen werden, die bestimmte Bedingungen erfüllen.

PPLabfragen:

os> source=accounts | where account_number=1 or gender="F" | fields account_number, gender; fetched rows / total rows = 2/2 +------------------+----------+ | account_number | gender | |------------------+----------| | 1 | M | | 13 | F | +------------------+----------+
Weitere Beispiele

Filter mit logischen Bedingungen
  • source = table | where c = 'test' AND a = 1 | fields a,b,c

  • source = table | where c != 'test' OR a > 1 | fields a,b,c | head 1

  • source = table | where c = 'test' NOT a > 1 | fields a,b,c

  • source = table | where a = 1 | fields a,b,c

  • source = table | where a >= 1 | fields a,b,c

  • source = table | where a < 1 | fields a,b,c

  • source = table | where b != 'test' | fields a,b,c

  • source = table | where c = 'test' | fields a,b,c | head 3

  • source = table | where ispresent(b)

  • source = table | where isnull(coalesce(a, b)) | fields a,b,c | head 3

  • source = table | where isempty(a)

  • source = table | where isblank(a)

  • source = table | where case(length(a) > 6, 'True' else 'False') = 'True'

  • source = table | where a between 1 and 4- Hinweis: Dies gibt a >= 1 und a <= 4 zurück, also [1, 4]

  • source = table | where b not between '2024-09-10' and '2025-09-10'- Hinweis: Dies gibt b >= '**********' und b <= '2025-09-10' zurück

  • source = table | where cidrmatch(ip, '***********/24')

  • source = table | where cidrmatch(ipv6, '2003:db8::/32')

source = table | eval status_category = case(a >= 200 AND a < 300, 'Success', a >= 300 AND a < 400, 'Redirection', a >= 400 AND a < 500, 'Client Error', a >= 500, 'Server Error' else 'Incorrect HTTP status code') | where case(a >= 200 AND a < 300, 'Success', a >= 300 AND a < 400, 'Redirection', a >= 400 AND a < 500, 'Client Error', a >= 500, 'Server Error' else 'Incorrect HTTP status code' ) = 'Incorrect HTTP status code'
source = table | eval factor = case(a > 15, a - 14, isnull(b), a - 7, a < 3, a + 1 else 1) | where case(factor = 2, 'even', factor = 4, 'even', factor = 6, 'even', factor = 8, 'even' else 'odd') = 'even' | stats count() by factor