# Why is wildcard required in DQL matchesPhrase with host.name?

**URL:** <https://community.dynatrace.com/t/why-is-wildcard-required-in-dql-matchesphrase-with-host-name/44156>\
**Category:** DQL\
**Tags:** matchesphrase\
**Created:** [February 15, 2024, 7:30pm UTC](https://community.dynatrace.com/t/why-is-wildcard-required-in-dql-matchesphrase-with-host-name/44156 "2024-02-15T19:30:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![GerryIsHere](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gerryishere/32/15590_2.png) [@GerryIsHere](https://community.dynatrace.com/u/GerryIsHere)\
**Post date:** [February 15, 2024, 7:30pm UTC](https://community.dynatrace.com/t/why-is-wildcard-required-in-dql-matchesphrase-with-host-name/44156/1 "2024-02-15T19:30:59Z")

</div>

**This fails:**

fetch logs  
| filter matchesPhrase(host.name, “carn”) // fail  
and matchesPhrase(log.source, “rmwfeapi”)  
and matchesPhrase(content, “Unable”)  
| fieldsKeep timestamp, host.name, content, log.source

**This works:**

fetch logs  
| filter matchesPhrase(host.name, “carn\*”) // why is wildcard required?  
and matchesPhrase(log.source, “rmwfeapi”)  
and matchesPhrase(content, “Unable”) // this works!  
| fieldsKeep timestamp, host.name, content, log.source

What is it about host.name that matchesPhrase doesn’t work as expected? It can find “Unable” in the&nbsp; middle of content but it can’t find “carn” at the beginning of host.name? Why not?

---

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [February 15, 2024, 7:40pm UTC](https://community.dynatrace.com/t/why-is-wildcard-required-in-dql-matchesphrase-with-host-name/44156/2 "2024-02-15T19:40:17Z")

</div>

MatchPhrase should match the exact value you are querying.

So I am assuming your host name is not only carn, but carn’something’.

Can you confirm?

If you want to filter by hostname with just a piece of the name without using the wildcard, you can use the contains instead.

---

<div class="post-metadata">

**Author:** ![GerryIsHere](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gerryishere/32/15590_2.png) [@GerryIsHere](https://community.dynatrace.com/u/GerryIsHere)\
**Post date:** [February 15, 2024, 7:52pm UTC](https://community.dynatrace.com/t/why-is-wildcard-required-in-dql-matchesphrase-with-host-name/44156/3 "2024-02-15T19:52:23Z")

</div>

My message says “carn\*” works and “carn” does not. If “carn” was the server name “carn” would work. I think this is a DQL bug.

---

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [February 15, 2024, 7:55pm UTC](https://community.dynatrace.com/t/why-is-wildcard-required-in-dql-matchesphrase-with-host-name/44156/4 "2024-02-15T19:55:43Z")

</div>

That’s not a bug, that’s just how matchPhrase works:

> **[DQL matcher in logs](https://docs.dynatrace.com/docs/analyze-explore-automate/logs/lma-classic-log-processing/lma-log-processing-matcher)**
>
> Examine specific DQL functions and logical operators for log processing.

It should match the phrase you are looking for. If you want to get a string piece only, you should use “contains” instead.

> **[contains - String functions](https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/functions/string-functions#contains)**
>
> String functions allow you to create expressions that manipulate text strings in a variety of ways. | A list of DQL string functions.

---

<div class="post-metadata">

**Author:** ![GerryIsHere](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gerryishere/32/15590_2.png) [@GerryIsHere](https://community.dynatrace.com/u/GerryIsHere)\
**Post date:** [February 15, 2024, 8:13pm UTC](https://community.dynatrace.com/t/why-is-wildcard-required-in-dql-matchesphrase-with-host-name/44156/5 "2024-02-15T20:13:12Z")

</div>

Please let someone from Dynatrace respond thanks.

---

<div class="post-metadata">

**Author:** ![GerryIsHere](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/gerryishere/32/15590_2.png) [@GerryIsHere](https://community.dynatrace.com/u/GerryIsHere)\
**Post date:** [February 15, 2024, 10:01pm UTC](https://community.dynatrace.com/t/why-is-wildcard-required-in-dql-matchesphrase-with-host-name/44156/6 "2024-02-15T22:01:21Z")

</div>

because word boundaries count
