# Get only multi value in Elastic search

**URL:** <https://discuss.elastic.co/t/get-only-multi-value-in-elastic-search/197107>\
**Category:** Elasticsearch\
**Created:** [August 28, 2019, 12:01pm UTC](https://discuss.elastic.co/t/get-only-multi-value-in-elastic-search/197107 "2019-08-28T12:01:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ramesh\_balasubramani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramesh_balasubramani/32/53173_2.png) [@Ramesh\_balasubramani](https://discuss.elastic.co/u/Ramesh_balasubramani)\
**Post date:** [August 28, 2019, 12:01pm UTC](https://discuss.elastic.co/t/get-only-multi-value-in-elastic-search/197107/1 "2019-08-28T12:01:33Z")

</div>

```
"hits": [
         {
            "_index": "logstash-ramesh-2019.08.28",
            "_type": "doc",
            "_id": "7XYH2GwBQhFmziR_i09j",
            "_score": null,
            "_source": {
               "username": "xxxxx-003",
               "dst_ip": "server",
               "@timestamp": "2019-08-28T11:41:05.284Z",
               "host": "xxxxxx-003",
               "src_hostname": "xxxxxx-003",
               "path": "C:/1148/E/ssh.txt",
               "@version": "1",
               "sport": "12",
               "engine_log_id": [
                  "7",
                  "8"
               ],
               "src_ip": "1.1.1.1",
               "engine_id": "4003",
               "date": "Nov 23 22:05:01",
               "message": "Nov 23 22:05:01 server sshd[21358]: Accepted password for xxxxx from xxx.xx.xxx.xx port 12 ssh2 Low 7 - 13464\r"
            },
            "sort": [
               1566992465284
            ]
         },
{
            "_index": "logstash-ramesh-2019.08.28",
            "_type": "doc",
            "_id": "7XYH2GwBQhFmziR_i09j",
            "_score": null,
            "_source": {
               "username": "xxxxx-003",
               "dst_ip": "server",
               "@timestamp": "2019-08-28T11:41:05.284Z",
               "host": "xxxxx-003",
               "src_hostname": "xxxxx-003",
               "path": "C:/1148/E/ssh.txt",
               "@version": "1",
               "sport": "12",
               "engine_log_id": "20",
               "src_ip": "1.1.1.1",
               "engine_id": "4003",
               "date": "Nov 23 22:05:01",
               "message": "Nov 23 22:05:01 server sshd[21358]: Accepted password for xxxxx from xxx.xx.xxx.xx port 12 ssh2 Low 7 - 13464\r"
            },
            "sort": [
               1566992465284
            ]
         }

```

\*\*

> engine\_log\_id have multiple values, but sometimes single value also. My concern needs to get only multiple values only not single. Refer above example.

\*\*

Requesting to anyone help on this.

---

<div class="post-metadata">

**Author:** ![wangqinghuan](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wangqinghuan](https://discuss.elastic.co/u/wangqinghuan)\
**Post date:** [August 29, 2019, 6:29am UTC](https://discuss.elastic.co/t/get-only-multi-value-in-elastic-search/197107/2 "2019-08-29T06:29:49Z")

</div>

Assume field 'engine\_id' is keyword data type, you can use following DSL to get only multiple-value documents.

```
{
        "query": {
            "bool" : {
                "filter" : {
                    "script" : {
                        "script" : {
                            "source" : "doc['engine_id'].length>1"
                        }
                    }
                }
            }
        }
    }
```

---

<div class="post-metadata">

**Author:** ![Ramesh\_balasubramani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramesh_balasubramani/32/53173_2.png) [@Ramesh\_balasubramani](https://discuss.elastic.co/u/Ramesh_balasubramani)\
**Post date:** [August 29, 2019, 6:37am UTC](https://discuss.elastic.co/t/get-only-multi-value-in-elastic-search/197107/3 "2019-08-29T06:37:55Z")

</div>

Great, Awesome !!!!

I really appreciate.

Thanks Lot !!!

---

<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:** [September 26, 2019, 6:37am UTC](https://discuss.elastic.co/t/get-only-multi-value-in-elastic-search/197107/4 "2019-09-26T06:37:59Z")

</div>

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