# ML Advanced datafeed Elasticsearch Query

**URL:** <https://discuss.elastic.co/t/ml-advanced-datafeed-elasticsearch-query/260219>\
**Category:** Elasticsearch\
**Created:** [January 5, 2021, 2:44pm UTC](https://discuss.elastic.co/t/ml-advanced-datafeed-elasticsearch-query/260219 "2021-01-05T14:44:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elk\_huh](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@Elk\_huh](https://discuss.elastic.co/u/Elk_huh)\
**Post date:** [January 5, 2021, 2:44pm UTC](https://discuss.elastic.co/t/ml-advanced-datafeed-elasticsearch-query/260219/1 "2021-01-05T14:44:20Z")

</div>

How do i do query for  
event.code == 4625  
winlog.event\_data.targetusername != "\*svc"

this is what i have and doesnt seem to work  
{  
"bool": {  
"must": [  
{  
"match\_all": {}  
}  
],  
"filter": [  
{  
"match\_phrase": {  
"event.code": "4625"  
}  
}  
],  
"must\_not": [  
{  
"term": {  
"winlog.event\_data.TargetUserName": "\*svc"  
}  
}  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![Elk\_huh](https://avatars.discourse-cdn.com/v4/letter/e/d26b3c/32.png) [@Elk\_huh](https://discuss.elastic.co/u/Elk_huh)\
**Post date:** [January 5, 2021, 3:49pm UTC](https://discuss.elastic.co/t/ml-advanced-datafeed-elasticsearch-query/260219/2 "2021-01-05T15:49:30Z")

</div>

Ive tried this too

```
{
  "bool": {
    "must": [
      {
        "match_all": {}
      }
    ],
    "filter": [
      {
        "match_phrase": {
          "event.code": "4625"
        }
      }
    ],
    "must_not": [
      {
        "regexp": {
          "winlog.event_data.TargetUserName": {
            "value": "*$"
          }
        }
      }
    ]
  }
}
```

---

<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:** [February 2, 2021, 3:49pm UTC](https://discuss.elastic.co/t/ml-advanced-datafeed-elasticsearch-query/260219/3 "2021-02-02T15:49:49Z")

</div>

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