# 400 Bad Request - Unexpected close marker '}': expected '\]'

**URL:** <https://discuss.elastic.co/t/400-bad-request-unexpected-close-marker-expected/81156>\
**Category:** Elasticsearch\
**Created:** [April 4, 2017, 1:47pm UTC](https://discuss.elastic.co/t/400-bad-request-unexpected-close-marker-expected/81156 "2017-04-04T13:47:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![amolfuke1](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@amolfuke1](https://discuss.elastic.co/u/amolfuke1)\
**Post date:** [April 4, 2017, 1:47pm UTC](https://discuss.elastic.co/t/400-bad-request-unexpected-close-marker-expected/81156/1 "2017-04-04T13:47:28Z")

</div>

Hi All ,  
We are new to ES and trying very small search functionality through mustache template.We have created a index in local ES and inserted one sample record.  
We created a mustache template -  
{"query":{"template":{"inline":{"bool":{"must":[

{{#nameFilter}}  
{"bool" : {"should" : { "match" : { "{{fieldName}}" : "{{fieldValue}}" } }}}  
{{#FC}},{{/FC}}  
{{/nameFilter}}

}}}}}

My postman url -  
[http://localhost:9200/patientsummaryindex\_test/dvaPatientDoc/\_search/template](http://localhost:9200/patientsummaryindex_test/dvaPatientDoc/_search/template)

Below is my query which I am sending in body  
{  
"file":"LatestTemplate",  
"params":{  
"namefilter":[  
{  
"fieldName":"name",  
"fieldValue":"Amol"  
}  
]  
}  
}

What we get is -

{  
"error": {  
"root\_cause": [  
{  
"type": "parsing\_exception",  
"reason": "[script] failed to parse field [inline]",  
"line": 4,  
"col": 1  
}  
],  
"type": "parsing\_exception",  
"reason": "[script] failed to parse field [inline]",  
"line": 4,  
"col": 1,  
"caused\_by": {  
"type": "unchecked\_i\_o\_exception",  
"reason": "com.fasterxml.jackson.core.JsonParseException: Unexpected close marker '}': expected ']' (for Array starting at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@4b92c3c9; line: 1, column: 48])\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@4b92c3c9; line: 4, column: 2]",  
"caused\_by": {  
"type": "json\_parse\_exception",  
"reason": "Unexpected close marker '}': expected ']' (for Array starting at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@4b92c3c9; line: 1, column: 48])\n at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@4b92c3c9; line: 4, column: 2]"  
}  
}  
},  
"status": 400  
}

We tried filter on many fields but the error is more or less same.The query json is correct as when we validate it.  
Can someone find whats wrong here ?

---

<div class="post-metadata">

**Author:** ![phalcony](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/phalcony/32/16951_2.png) [@phalcony](https://discuss.elastic.co/u/phalcony)\
**Post date:** [April 4, 2017, 2:09pm UTC](https://discuss.elastic.co/t/400-bad-request-unexpected-close-marker-expected/81156/2 "2017-04-04T14:09:43Z")

</div>

Hi Amol,

Could you please write us, how your indexing script looks like?

Which version of ES you are running?

There are some tips how to write a more readable questions 😉

> [@About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21):
>
> The heart of the free and open Elastic Stack Elasticsearch is a distributed, RESTful search and analytics engine capable of addressing a growing number of use cases. As the heart of the Elastic Stack, it centrally stores your data for lightning fast search, fine‑tuned relevancy, and powerful analytics that scale with ease. warning PLEASE READ THIS SECTION IF IT'S YOUR FIRST POST Some useful links: [elasticsearch reference guide](http://www.elastic.co/guide/en/elasticsearch/reference/current/index.html)[elasticsearch user guide](http://www.elastic.co/guide/en/elasticsearch/guide/current/index.html)[elasticsearch plugins](https://www.elastic.co/guide/en/elasticsearch/plugins/current/index.html)[elasticsearch cl…](https://www.elastic.co/guide/en/elasticsearch/client/index.html)

---

<div class="post-metadata">

**Author:** ![amolfuke1](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@amolfuke1](https://discuss.elastic.co/u/amolfuke1)\
**Post date:** [April 4, 2017, 2:30pm UTC](https://discuss.elastic.co/t/400-bad-request-unexpected-close-marker-expected/81156/3 "2017-04-04T14:30:54Z")

</div>

Hi ,

Sorry about bad formatting of my question.We are using ES 5.1.2  
Below is my indexing script looks like -

```auto
 {
     "settings": {
         "number_of_shards": 1,
         "analysis": {
             "filter": {
                 "nGram_filter": {
                     "type": "nGram",
                     "min_gram": 2,
                     "max_gram": 20,
                     "token_chars": [
                         "letter",
                         "digit",
                         "punctuation",
                         "symbol"
                     ]
                 },
                 "autoComplete_nGram_filter": {
                     "type": "nGram",
                     "min_gram": 2,
                     "max_gram": 20,
                     "token_chars": [
                         "letter",
                         "punctuation",
                         "symbol"
                     ]
                 }
             },
             "analyzer": {
                 "nGram_analyzer": {
                     "type": "custom",
                     "tokenizer": "whitespace",
                     "filter": [
                         "lowercase",
                         "asciifolding",
                         "nGram_filter"
                     ]
                 },
                 "autocomplete_nGram_analyzer": {
                     "type": "custom",
                     "tokenizer": "whitespace",
                     "filter": [
                         "lowercase",
                         "asciifolding",
                         "autoComplete_nGram_filter"
                     ]
                 },
                 "autocomplete_search": {
                     "type": "custom",
                     "tokenizer": "lowercase"
                 },
                 "whitespace_analyzer": {
                     "type": "custom",
                     "tokenizer": "whitespace",
                     "filter": [
                         "lowercase",
                         "asciifolding"
                     ]
                 }
             }
         }
     },
     "mappings": {
         "patientDoc": {
             "_all": {
                 "analyzer": "nGram_analyzer",
                 "search_analyzer": "whitespace_analyzer"
             },
             "properties": {
                 "euid": {
                     "type": "text",
                     "term_vector": "yes",
                     "index": "false"
                 },
                 "masterPatientIdentifier": {
                     "type": "text",
                     "term_vector": "yes",
                     "index": "true"
                 },
                 "name": {
                     "type": "text",
 					"analyzer": "autocomplete_nGram_analyzer",
 					"search_analyzer": "autocomplete_search",					
                     "index": "true"
                 },
                 "dateOfBirth": {
                     "type": "date",
                     "index": "true"
                 },
                 "assignedFacilities": {
                      "type": "nested",
                         "properties": {
                             "facility": { "type": "nested",
                                 "properties": {
                                     "facilityId": { "type":"text","fielddata":"true"},
                                     "facilityName": { "type":"text","fielddata":"true"}
                                 }
                             },
                             "beginDate": { "type": "date" },
                             "endDate": { "type": "date" },
                             "isHomeFacility": { "type": "boolean" }
                           }
                 },
 				"administrativeGender": {
                      "type": "nested", 
                         "properties": {
                             "oid": { "type": "text" },
                             "conceptCode": { "type": "text" }
                           }
                 },
 				"asCitizen": {
                      "type": "nested", 
                         "properties": {
                             "oid": { "type": "text" },
                             "conceptCode": { "type": "text" }
                           }
                 },		
 				"primaryDiagnosis": {
                      "type": "nested", 
                         "properties": {
                             "oid": { "type": "text" },
                             "conceptCode": { "type": "text" }
                           }
                 },				
                 "actualFirstDateOfDialysis": {
                     "type": "date",
                     "index": "true"
                 },	
                 "regularChronicDialysisBegin": {
                     "type": "date",
                     "index": "true"
                 },					
 				"primaryLanguage": {
                      "type": "nested", 
                         "properties": {
                             "oid": { "type": "text","fielddata":"true" },
                             "conceptCode": { "type": "text" }
                           }
                 },				
 				"secondaryLanguage": {
                      "type": "nested", 
                         "properties": {
                             "oid": { "type": "text" },
                             "conceptCode": { "type": "text" }
                           }
                 },				
                 "assignedProviders": {
                      "type": "nested", 
                         "properties": {
                             "provider": { "type": "nested",
                                 "properties": {
                                     "providerId": { "type":"text"},
 									"providerType": {
 										 "type": "nested", 
 											"properties": {
 												"oid": { "type": "text" },
 												"conceptCode": { "type": "text" }
 											  }
 									},	
 									"startDate": {
 										"type": "date",
 										"index": "true"
 									},									
 									"endDate": {
 										"type": "date",
 										"index": "true"
 									},
 	                            }
                             }
                         }
                 },
 				"ethnicity": {
 					 "type": "nested", 
 						"properties": {
 							"oid": { "type": "text" },
 							"conceptCode": { "type": "text" }
 						}
 				},		
 				"maritalStatus": {
 					 "type": "nested", 
 						"properties": {
 							"oid": { "type": "text" },
 							"conceptCode": { "type": "text" }
 						}
 				},					
	 				"race": {
 					 "type": "nested", 
 						"properties": {
 							"oid": { "type": "text" },
 							"conceptCode": { "type": "text" }
 						}
 				}			
             }
         }
     }
 }

```

---

<div class="post-metadata">

**Author:** ![amolfuke1](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@amolfuke1](https://discuss.elastic.co/u/amolfuke1)\
**Post date:** [April 4, 2017, 2:32pm UTC](https://discuss.elastic.co/t/400-bad-request-unexpected-close-marker-expected/81156/4 "2017-04-04T14:32:22Z")

</div>

Oops .Looks like formatting is messed up again

---

<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:** [May 2, 2017, 2:32pm UTC](https://discuss.elastic.co/t/400-bad-request-unexpected-close-marker-expected/81156/5 "2017-05-02T14:32:39Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
