How to match trailing spaces in searches?

Hello all,

I'm currently trying to match trailing/leading spaces in searches such as:

  • "de "
  • "het "
  • "een "
  • " baan"

the field that im searching on is of type "text" with a search_analyzer "simple"

'my_searching_field' => [
        'type' => 'text',
        'analyzer' => 'autocomplete_mycustom',
        'search_analyzer' => 'simple',
    ],

'autocomplete_mycustom' => [
                            'tokenizer' => 'standard',
                            'filter' => 'lowercase, ngram_mycustomn'
                        ]

'ngram_mycustomn' => [
                            'type' => 'ngram',
                            'min_gram' => '1',
                            'max_gram' => '20',
                            'token_chars' => ['letter', 'digit', 'whitespace', 'symbol', 'punctuation'],
                        ]

Example values of said field within my documents:

"de bloem"
"denneboom"
"het is goed"
"hetterdo"
"de baan voor"

Where I would like to be able to search for: "de " (notice the trailing space) and match "de bloem", but not match "denbeboom".

Another example:
searching for " baan", where i would like to match "de baan voor".

Is this possible? And how would i achieve this?

Thanks in advance!

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