Searching special characters !, $, #, @

Hello,

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

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".

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?

Hi @oktaykalfa

you have some options:

1 - add in "token_chars" letter and whitespace:

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

But you need increase max_gram.

2 - Create a new field with analyzer whitespace.

1 Like

Thank you, you are amazing.

1 Like

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