# How to properly use asterisk with keywords\_pattern?

**URL:** <https://discuss.elastic.co/t/how-to-properly-use-asterisk-with-keywords-pattern/154706>\
**Category:** Elasticsearch\
**Created:** [October 30, 2018, 6:08pm UTC](https://discuss.elastic.co/t/how-to-properly-use-asterisk-with-keywords-pattern/154706 "2018-10-30T18:08:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![7ca884569f2642e2c488](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/7ca884569f2642e2c488/32/75102_2.png) [@7ca884569f2642e2c488](https://discuss.elastic.co/u/7ca884569f2642e2c488)\
**Post date:** [October 30, 2018, 6:08pm UTC](https://discuss.elastic.co/t/how-to-properly-use-asterisk-with-keywords-pattern/154706/1 "2018-10-30T18:08:58Z")

</div>

I want to use [this](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-keyword-marker-tokenfilter.html) but I can't understand how to write valid keywords\_pattern. I modify code from example like this

> ```
> {
> "settings": {
> "analysis": {
> "analyzer": {
> "protect_cats": {
> "type": "custom",
> "tokenizer": "standard",
> "filter": ["lowercase", "protect_cats", "porter_stem"]
> },
> "normal": {
> "type": "custom",
> "tokenizer": "standard",
> "filter": ["lowercase", "porter_stem"]
> }
> },
> "filter": {
> "protect_cats": {
> "type": "keyword_marker",
> "keywords_pattern": ".*\\*"
> }
> }
> }
> }
> }
> 
> ```

and put this to test\_index via put request. I expected elasticsearch to return token "cats\*" or at least "cats" after executed "/\_analyze?text=cats\*&analyzer=protect\_cats" but I got "cat" instead. How to achieve desired result? Thanks.

---

<div class="post-metadata">

**Author:** ![Mike.Barretta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mike.barretta/32/16688_2.png) [@Mike.Barretta](https://discuss.elastic.co/u/Mike.Barretta)\
**Post date:** [November 1, 2018, 2:56pm UTC](https://discuss.elastic.co/t/how-to-properly-use-asterisk-with-keywords-pattern/154706/2 "2018-11-01T14:56:49Z")

</div>

@7ca884569f2642e2c488  
I think your problem is with the standard tokenizer. If you switch to the [whitespace tokenizer](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-whitespace-tokenizer.html), that should work.

---

<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 29, 2018, 2:56pm UTC](https://discuss.elastic.co/t/how-to-properly-use-asterisk-with-keywords-pattern/154706/3 "2018-11-29T14:56:49Z")

</div>

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