# Field length validation using ES and matched from ES document

**URL:** https://discuss.elastic.co/t/field-length-validation-using-es-and-matched-from-es-document/229633
**Category:** Elasticsearch
**Created:** [April 24, 2020, 11:28am UTC](https://discuss.elastic.co/t/field-length-validation-using-es-and-matched-from-es-document/229633 "2020-04-24T11:28:32Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![vinay123](https://avatars.discourse-cdn.com/v4/letter/v/a9a28c/32.png) [@vinay123](https://discuss.elastic.co/u/vinay123)
#### Post date: [April 24, 2020, 11:28am UTC](https://discuss.elastic.co/t/field-length-validation-using-es-and-matched-from-es-document/229633/1 "2020-04-24T11:28:33Z")

</div>

Hello ES Team,

I have criteria for searching field length from json file using ES query.  
lets say example .

I have a index 'A' - it contains json file documents.  
Now i need to validate a field lenght is matching in that json or not

example :  
{  
" name" :"10"  
"city" " " "  
"location ": " IN"  
}

Now i need _ **verify and match from the index** _ and to validate the length of name filed is 10 or not  
and city is blank or not , location is IN or not .

By suing ES queries + java.  
How can i write .any suggestions

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [April 24, 2020, 12:05pm UTC](https://discuss.elastic.co/t/field-length-validation-using-es-and-matched-from-es-document/229633/2 "2020-04-24T12:05:32Z")

</div>

Best thing to do is probably to compute the length at index time and provide it within your json document.

---

<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 22, 2020, 12:15pm UTC](https://discuss.elastic.co/t/field-length-validation-using-es-and-matched-from-es-document/229633/3 "2020-05-22T12:15:01Z")

</div>

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