# Using custom search\_analyzer produces: "analyzer \[\] not found for field \[\]" error

**URL:** <https://discuss.elastic.co/t/using-custom-search-analyzer-produces-analyzer-not-found-for-field-error/37344>\
**Category:** Elasticsearch\
**Created:** [December 16, 2015, 11:37am UTC](https://discuss.elastic.co/t/using-custom-search-analyzer-produces-analyzer-not-found-for-field-error/37344 "2015-12-16T11:37:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexey\_Danilov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_danilov/32/5995_2.png) [@Alexey\_Danilov](https://discuss.elastic.co/u/Alexey_Danilov)\
**Post date:** [December 16, 2015, 11:37am UTC](https://discuss.elastic.co/t/using-custom-search-analyzer-produces-analyzer-not-found-for-field-error/37344/1 "2015-12-16T11:37:16Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/guide/current/_index_time_search_as_you_type.html#_edge_n_grams_and_postcodes)

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.

---

<div class="post-metadata">

**Author:** ![Alexey\_Danilov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alexey_danilov/32/5995_2.png) [@Alexey\_Danilov](https://discuss.elastic.co/u/Alexey_Danilov)\
**Post date:** [December 16, 2015, 1:34pm UTC](https://discuss.elastic.co/t/using-custom-search-analyzer-produces-analyzer-not-found-for-field-error/37344/2 "2015-12-16T13:34:36Z")

</div>

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"

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:30pm UTC](https://discuss.elastic.co/t/using-custom-search-analyzer-produces-analyzer-not-found-for-field-error/37344/3 "2017-07-05T23:30:36Z")

</div>


