From 7f1b21c13de09caedbe263e37fcbe40c683a60bd Mon Sep 17 00:00:00 2001
From: Ugonna Okoli <ugokoli30@gmail.com>
Date: Mon, 5 Sep 2022 12:00:46 +0100
Subject: [PATCH] Example for Nested field type exists query

Changes include a solution for working with a Nested field type when searching for documents missing the nested field type field as seen here https://stackoverflow.com/a/41461613/2741245
---
 .../reference/query-dsl/exists-query.asciidoc | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/docs/reference/query-dsl/exists-query.asciidoc b/docs/reference/query-dsl/exists-query.asciidoc
index 75d1b07ea3851..3f883419a8a6d 100644
--- a/docs/reference/query-dsl/exists-query.asciidoc
+++ b/docs/reference/query-dsl/exists-query.asciidoc
@@ -67,3 +67,29 @@ GET /_search
   }
 }
 ----
+
+The following search returns documents that are missing an indexed value for
+a <<nested, nested>> type `user`.
+
+[source,console]
+----
+GET /_search
+{
+  "query": {
+        "bool": {
+            "must_not": [
+                {
+                    "nested": {
+                        "path": "user",
+                        "query": {
+                            "exists": {
+                                "field": "user"
+                            }
+                        }
+                    }
+                }
+            ]
+        }
+    }
+}
+----