# How to use the terms filter for a whitelist (or blacklist) for a search

**URL:** <https://discuss.elastic.co/t/how-to-use-the-terms-filter-for-a-whitelist-or-blacklist-for-a-search/187223>\
**Category:** Elasticsearch\
**Created:** [June 25, 2019, 4:23am UTC](https://discuss.elastic.co/t/how-to-use-the-terms-filter-for-a-whitelist-or-blacklist-for-a-search/187223 "2019-06-25T04:23:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wengsengtam](https://avatars.discourse-cdn.com/v4/letter/w/4da419/32.png) [@wengsengtam](https://discuss.elastic.co/u/wengsengtam)\
**Post date:** [June 25, 2019, 4:23am UTC](https://discuss.elastic.co/t/how-to-use-the-terms-filter-for-a-whitelist-or-blacklist-for-a-search/187223/1 "2019-06-25T04:23:47Z")

</div>

Can somebody please explain how the terms filter can be used as a Whitelist / Blacklist for a search. I tried the following, but it did not work. Thanks.

```
 PUT iplist/_doc/_bulk
    { "index":{}}
    { "type" : "C2", "source" : "Test1", "ip": "192.168.1.13"}
    { "index":{}}
    { "type" : "C2", "source" : "Test1", "ip":"192.168.1.14"}
    { "index":{}}
    { "type" : "TOR", "source" : "Test2", "ip": "192.168.2.23"}
    { "index":{}}
    { "type" : "TOR", "source" : "Test2", "ip": "192.168.2.24"}
    { "index":{}}
    { "type" : "Source", "source" : "Test1", "ip": "192.168.1.69"}

GET iplist/_search

PUT traffic/_doc/_bulk
{ "index":{}}
{"seq":1, "sip" : "192.168.8.2", "dip" : "192.168.1.13"}
{ "index":{}}
{"seq":2, "sip" : "192.168.8.4", "dip" : "192.168.1.14"}
{ "index":{}}
{"seq":3, "sip" : "192.168.8.8", "dip" : "192.168.2.23"}
{ "index":{}}
{"seq":4, "sip" : "192.168.8.8", "dip" : "192.168.2.23"}
{ "index":{}}
{"seq":5, "sip" : "192.168.8.2", "dip" : "192.168.1.13"}
{ "index":{}}
{"seq":6, "sip" : "192.168.8.4", "dip" : "192.168.1.14"}
{ "index":{}}
{"seq":7, "sip" : "192.168.1.69", "dip" : "192.168.8.2"}
{ "index":{}}
{"seq":8, "sip" : "192.168.1.69", "dip" : "192.168.8.2"}

GET traffic/_search?pretty
{
  "query": {
    "terms": {
      "dip": {
        "index":"iplist",
        "id": "*",
        "path":"dip"
        }
      }
  }
}
```

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [June 25, 2019, 7:12am UTC](https://discuss.elastic.co/t/how-to-use-the-terms-filter-for-a-whitelist-or-blacklist-for-a-search/187223/2 "2019-06-25T07:12:17Z")

</div>

2 things here:

- the path should be `ip` and not `dip`.
- You can't use `*` for the document id. It must be one single document.

---

<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:** [July 23, 2019, 7:12am UTC](https://discuss.elastic.co/t/how-to-use-the-terms-filter-for-a-whitelist-or-blacklist-for-a-search/187223/3 "2019-07-23T07:12:22Z")

</div>

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