# Get document by searching for a field value

**URL:** <https://discuss.elastic.co/t/get-document-by-searching-for-a-field-value/181203>\
**Category:** Elasticsearch\
**Created:** [May 15, 2019, 1:35pm UTC](https://discuss.elastic.co/t/get-document-by-searching-for-a-field-value/181203 "2019-05-15T13:35:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidbien](https://avatars.discourse-cdn.com/v4/letter/d/ebca7d/32.png) [@davidbien](https://discuss.elastic.co/u/davidbien)\
**Post date:** [May 15, 2019, 1:35pm UTC](https://discuss.elastic.co/t/get-document-by-searching-for-a-field-value/181203/1 "2019-05-15T13:35:19Z")

</div>

Hi,

So I have a search query written in python to look for cloudtrail events. This works fine, however I would like to move this even further and access more data from the document my search finds.  
This is what I have atm:

```
res = es.search(index="*-{0}".format(now), doc_type="record", body={
    "query": {
        "bool": {
            "must": {
                "bool": {
                    "should": [
                        {"match": {"eventName": "AuthorizeSecurityGroupIngress"}},
                        {"match": {"eventName": "AuthorizeSecurityGroupEgress"}},
                        {"match": {"eventName": "RevokeSecurityGroupIngress"}},
                        {"match": {"eventName": "RevokeSecurityGroupEgress"}},
                        {"match": {"eventName": "CreateSecurityGroup"}},
                        {"match": {"eventName": "DeleteSecurityGroup"}}
                    ]
                }
            },
            "must_not": {
                "match": {"userIdentity.sessionContext.sessionIssuer.userName": "packer_runner"}
            },
            "filter": {
                "range": {
                    "eventTime": {
                        "gte":"now-15m",
                        "lt":"now"
                    }
                }
            }
        }
    }
})

```

What I want is to be able to view the whole document matching this query. What I get at the moment is just this:

```
{'took': 1, 'timed_out': False, '_shards': {'total': 6, 'successful': 6, 'skipped': 0, 'failed': 0}, 'hits': {'total': 0, 'max_score': None, 'hits': []}}

```

I was looking at .get() method but it requires document id, however I can't get anything from my search. How can I improve this?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 12, 2019, 1:35pm UTC](https://discuss.elastic.co/t/get-document-by-searching-for-a-field-value/181203/2 "2019-06-12T13:35:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
