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


(amol) #1

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

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 ?


(Phalcony) #2

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 :wink:


(amol) #3

Hi ,

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

 {
     "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"   }
 						}
 				}			
             }
         }
     }
 }

(amol) #4

Oops .Looks like formatting is messed up again


(system) closed #5

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