Using custom search_analyzer produces: "analyzer [] not found for field []" error

Hi guys! I've been trying to follow this example to implement searching by post codes: Index-Time Search-as-You-Type | Elasticsearch: The Definitive Guide [2.x] | Elastic

I use Java client to create index and mappings:

CreateIndexResponse createIndexResponse = client.admin()
.indices()
.prepareCreate("myIndex")
.setSettings(settings)
.addMapping("default", mappings)
.get();
boolean acknowledged = createIndexResponse.isAcknowledged();

// When I execute create index request, it is acknowledged:
// acknowledged == true

"settings" and "mappings" variables are json documents:

settings:

{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1,
"analysis": {
"analyzer": {
"postcode_index": {
"tokenizer": "keyword",
"filter": [
"postcode_filter"
]
},
"postcode_search": {
"tokenizer": "keyword",
"filter":
}
},
"filter": {
"postcode_filter": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 8
}
}
}
}
}

mappings:

{
"_all": {
"enabled": false
},
"date_detection": true,
"dynamic_templates": [
{
"address_postal_code": {
"path_match": "address.postalCode",
"mapping": {
"type": "string",
"index": "analyzed",
"index_analyzer": "postcode_index",
"search_analyzer": "postcode_search"
}
}
},
{
"all_fields": {
"match": ".*",
"match_pattern": "regex",
"mapping": {
"index": "not_analyzed"
}
}
}
]
}

But indexing with the code below throws an error:

IndexResponse indexResponse = esClient.client().prepareIndex(index, type).setSource(entityAsJson).get();

// entityAsJson:
{
"description": "Some description",
"address": {
"postalCode": "123 456"
}
}

// throws MapperParsingException[analyzer [postcode_search] not found for field [postalCode]]

If anyone has any insights as to why this might happen, please shed some light.

To answer my own question: settings json was malformed - it should not have been wrapped in top element "settings". Also, documentation was somehow outdated: instead of "index_analyzer" simply "analyzer" should be used:

"index_analyzer": "postcode_index",
"search_analyzer": "postcode_search"

->

"analyzer": "postcode_index",
"search_analyzer": "postcode_search"