# Wildcard query on text field

**URL:** <https://discuss.elastic.co/t/wildcard-query-on-text-field/311676>\
**Category:** Elasticsearch\
**Created:** [August 8, 2022, 10:03pm UTC](https://discuss.elastic.co/t/wildcard-query-on-text-field/311676 "2022-08-08T22:03:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maxfriz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maxfriz/32/123814_2.png) [@maxfriz](https://discuss.elastic.co/u/maxfriz)\
**Post date:** [August 8, 2022, 10:03pm UTC](https://discuss.elastic.co/t/wildcard-query-on-text-field/311676/1 "2022-08-08T22:03:47Z")

</div>

From a best practice and cautionary perspective, am I missing any other critical information I should be considering specific to a wildcard query on a text field? See bullets below.

- I have reviewed the documentation in-depth and it is clear that _wildcard_ queries are **best suited for fields mapped as wildcard or keyword** , however wildcard queries will work with fields mapped as text.
- Wildcard queries on fields mapped as text limit matching of any wildcard expressions to individual tokens rather than the original whole value held in a field.
- Wildcard queries will not be executed if search.allow\_expensive\_queries is set to false.
- For performance reasons it is a best practice to avoid beginning patterns with wildcard operators (e.g. an asterisk or question mark).

What else do I need to consider? Am I missing something important?

I appreciate any feedback.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [August 16, 2022, 5:27am UTC](https://discuss.elastic.co/t/wildcard-query-on-text-field/311676/2 "2022-08-16T05:27:01Z")

</div>

> [@maxfriz](#):
>
> For performance reasons it is a best practice to avoid beginning patterns with wildcard operators (e.g. an asterisk or question mark).

If your field is mapped as `wildcard` I do not think this applies.

Otherwise I think you got the summary right.

---

<div class="post-metadata">

**Author:** ![maxfriz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maxfriz/32/123814_2.png) [@maxfriz](https://discuss.elastic.co/u/maxfriz)\
**Post date:** [August 16, 2022, 2:11pm UTC](https://discuss.elastic.co/t/wildcard-query-on-text-field/311676/3 "2022-08-16T14:11:41Z")

</div>

Thank you.

---

<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 13, 2022, 2:12pm UTC](https://discuss.elastic.co/t/wildcard-query-on-text-field/311676/4 "2022-09-13T14:12:08Z")

</div>

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