# Search query - StartsWIth, Contains and Endswith

**URL:** <https://discuss.elastic.co/t/search-query-startswith-contains-and-endswith/252501>\
**Category:** Elasticsearch\
**Created:** [October 19, 2020, 8:15am UTC](https://discuss.elastic.co/t/search-query-startswith-contains-and-endswith/252501 "2020-10-19T08:15:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mruthyu](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@mruthyu](https://discuss.elastic.co/u/mruthyu)\
**Post date:** [October 19, 2020, 8:15am UTC](https://discuss.elastic.co/t/search-query-startswith-contains-and-endswith/252501/1 "2020-10-19T08:15:46Z")

</div>

How to query elasticsearch with Startswith, contains and Endswith.  
\Looks like it is not recommended to use wildcard \* at the beginning of the search term considering the performance impact.

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [October 19, 2020, 8:41am UTC](https://discuss.elastic.co/t/search-query-startswith-contains-and-endswith/252501/2 "2020-10-19T08:41:24Z")

</div>

> [@mruthyu](#):
>
> it is not recommended to use wildcard \* at the beginning of the search term considering the performance impact.

For content that has few unique values (thousands or less) then the `keyword` field is adequate. An example might be searching country names.  
For content that has millions or more unique values e.g. machine-generated log messages then the [new wildcard field](https://www.elastic.co/blog/find-strings-within-strings-faster-with-the-new-elasticsearch-wildcard-field) is designed for efficient wildcard and regex searches.

---

<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:** [November 16, 2020, 8:41am UTC](https://discuss.elastic.co/t/search-query-startswith-contains-and-endswith/252501/3 "2020-11-16T08:41:25Z")

</div>

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