I'm a novice to Elasticsearch (ES), messing around with the analyzers. As the documentation states, the analyzer can be specifed "index time" and "search time", depending on the use case.
My document has a text field title
, and i have defined the following mapping that introduces a sub-field custom
:
PUT index/_mapping
{
"properties": {
"title": {
"type": "text",
"fields": {
"custom": {
"type": "text",
"analyzer": "standard",
"search_analyzer":"keyword"
}
}
}
}
}
So if i have the text : "email-id is [email protected]"
, the standard-analyzer
would analyze the text into the following tokens during indexing:
[email, id, is, someid, someprovider.com]
.
However whenever I try to query on the field (with different variations in query terms) title.custom
, it results in no hits.
This is what I think is happening when i query with the keyword: email
:
- It gets analyzed by the keyword analyzer.
- The field title.custom's value also analyzed by keyword analyzer (analysis on tokens), resulting in same set of tokens as mentioned earlier.
- An exact match should happen on
email
token, returning the document.
Clearly this is not the case and there are gaps in my understanding.
- I would like to know what exactly is happening during search.
- On a generic level, I would like to know how the analysis and search happens when combination of search and index analyzer is specified.