Specifying a different analyzer
In the previous recipes, we have seen how to map different fields and objects in Elasticsearch and we have described how it's easy to change the standard analyzer with the analyzer
and search_analyzer
properties.
In this recipe, we will see several analyzers and how to use them to improve the indexing and searching quality.
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
How to do it...
Every core type field allows you to specify custom analyzer for indexing and for searching as field parameters.
For example, if we want that the name field uses a standard analyzer for indexing and a simple analyzer for searching, the mapping will be as follows:
{ "name": { "type": "string", "index_analyzer": "standard", "search_analyzer": "simple" } }
How it works...
The concept...