I use Kibana to execute query elastic (Query string query).
When i search a word include escapable characters (reserved characters like: '\', '+', '-', '&&', '||', '!', '(', ')', '{', '}', '[', ']', '^', '"', '~', '*', '?', ':', '/'). It will get expected result. My example use: '!'
But when i search single reserved character. I got nothing.
Or:

How can i search with single reserved character?

TL;DR You'll need to specify an analyzer (+ a tokenizer) which ensures that special chars like
!won't be stripped away during the ingestion phase.In the first screenshot you've correctly tried running
_analyze. Let's use it to our advantage.See, when you don't specify any analyzer, ES will default to the
standardanalyzer which is, by definition, constrained by thestandardtokenizer which'll strip away any special chars (except the apostrophe'and some other chars).Running
thus yields:
This means you'll need to use some other tokenizer which'll preserve these chars instead. There are a few built-in ones available, the simplest of which would be the
whitespacetokenizer.Running
retains the
!:So,
1. Drop your index:
2. Then set the mappings anew:
(I chose the multi-field approach which'll preserve the original, standard analyzer and only apply the
whitespacetokenizer on thename.splitByWhitespacesubfield.)3. Reindex
4. Search freely for special chars:
Do note that if you leave the
default_fieldout, it won't work because of thestandardanalyzer.Indeed, you could reverse this approach, apply
whitespaceby default, and create a multi-field mapping for the "original" indexing strategy (-> the only config being"type": "text").Shameless plug: I wrote a book on Elasticsearch and you may find it useful!