# Searching special characters !, $, #, @

**URL:** <https://discuss.elastic.co/t/searching-special-characters/322727>\
**Category:** Elasticsearch\
**Created:** [January 9, 2023, 11:27am UTC](https://discuss.elastic.co/t/searching-special-characters/322727 "2023-01-09T11:27:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oktaykalfa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oktaykalfa/32/115714_2.png) [@oktaykalfa](https://discuss.elastic.co/u/oktaykalfa)\
**Post date:** [January 9, 2023, 11:27am UTC](https://discuss.elastic.co/t/searching-special-characters/322727/1 "2023-01-09T11:27:46Z")

</div>

Hello,

My config is be like in the following and i want to search special characters like !, $, @, # too.

```auto
class ConversationIndexConfigurator extends IndexConfigurator
{
    use Migratable;

    protected $name = 'conversations';

    // You can specify any settings you want, for example, analyzers.
    protected $settings = [
        'analysis' => [
            'analyzer' => [
                'my_ngram_analyzer' => [
                    'tokenizer' => 'my_ngram_tokenizer'
                ]
            ],
            'tokenizer' => [
                'my_ngram_tokenizer' => [
                    'type' => 'edgeNGram',
                    'min_gram' => '1',
                    'max_gram' => '10',
                    'token_chars' => [
                        'punctuation'
                    ]
                ]
            ]
        ]
    ];
}

```

When i want to search only "!" the data is not returning. My search field name is " **text**".

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/0/60bc61b569a2741043ae7dad92b894841801da1f.png)

I tried many search query like but they didn't work.

- regexp =\> text =\> '!',

- regexp =\> text =\> ._'!' or i tried ._\!\*. and other combinations.

- wildcard =\> text =\> '!';

What should i do search special characters too?

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [January 9, 2023, 1:02pm UTC](https://discuss.elastic.co/t/searching-special-characters/322727/2 "2023-01-09T13:02:26Z")

</div>

Hi @oktaykalfa

you have some options:

1 - add in "token\_chars" letter and whitespace:

```auto
  "token_chars": [
            "letter",
            "whitespace",
            "punctuation"
          ]
        }

```

But you need increase max\_gram.

2 - Create a new field with analyzer whitespace.

---

<div class="post-metadata">

**Author:** ![oktaykalfa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oktaykalfa/32/115714_2.png) [@oktaykalfa](https://discuss.elastic.co/u/oktaykalfa)\
**Post date:** [January 10, 2023, 1:43pm UTC](https://discuss.elastic.co/t/searching-special-characters/322727/3 "2023-01-10T13:43:37Z")

</div>

Thank you, you are amazing.

---

<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 7, 2023, 2:33pm UTC](https://discuss.elastic.co/t/searching-special-characters/322727/5 "2023-02-07T14:33:37Z")

</div>

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