// This file is autogenerated, DO NOT EDIT
// query-dsl/nested-query.asciidoc:298

[source, python]
----
resp = client.indices.create(
    index="my-index",
    mappings={
        "properties": {
            "comments": {
                "type": "nested"
            }
        }
    },
)
print(resp)

resp1 = client.index(
    index="my-index",
    id="1",
    refresh=True,
    document={
        "comments": [
            {
                "author": "kimchy"
            }
        ]
    },
)
print(resp1)

resp2 = client.index(
    index="my-index",
    id="2",
    refresh=True,
    document={
        "comments": [
            {
                "author": "kimchy"
            },
            {
                "author": "nik9000"
            }
        ]
    },
)
print(resp2)

resp3 = client.index(
    index="my-index",
    id="3",
    refresh=True,
    document={
        "comments": [
            {
                "author": "nik9000"
            }
        ]
    },
)
print(resp3)

resp4 = client.search(
    index="my-index",
    query={
        "nested": {
            "path": "comments",
            "query": {
                "bool": {
                    "must_not": [
                        {
                            "term": {
                                "comments.author": "nik9000"
                            }
                        }
                    ]
                }
            }
        }
    },
)
print(resp4)
----
