# How to check if a Field from a JSON Data exists in the Index bevor send another Data with same Field to Elasticsearch

**URL:** https://discuss.elastic.co/t/how-to-check-if-a-field-from-a-json-data-exists-in-the-index-bevor-send-another-data-with-same-field-to-elasticsearch/187815
**Category:** Elasticsearch
**Created:** [June 27, 2019, 11:39am UTC](https://discuss.elastic.co/t/how-to-check-if-a-field-from-a-json-data-exists-in-the-index-bevor-send-another-data-with-same-field-to-elasticsearch/187815 "2019-06-27T11:39:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![samyo](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@samyo](https://discuss.elastic.co/u/samyo)
#### Post date: [June 27, 2019, 11:39am UTC](https://discuss.elastic.co/t/how-to-check-if-a-field-from-a-json-data-exists-in-the-index-bevor-send-another-data-with-same-field-to-elasticsearch/187815/1 "2019-06-27T11:39:46Z")

</div>

Hello Folks,  
i have this JSON Data in Elastic , and i want to check in mytest Index , if it contains the application\_id=6 , so i can avoid sending the same JSON DATA twice with the same application\_id=6 .  
Is there any Function in **Java** like example "check\_exists\_content\_field" to check wheather the Field application\_id=6 existis in the Index "mytest" ???  
i am using REST ClientAPI in Java version 8.0 , and Elasticsearch Version 6.3.1.

```auto

"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "mytest",
"_type": "_doc",
"_id": "1",
"_score": 1,
"_source": {
"entity": {
"birthday_id": 0,
"application_id": 6,
"mission": [
"element 1"
,
"element 2"
]
},
"process": {
"login_id": 1311,
"page_name": "update"
},
"text": "hello world"
}
}
]
}

```

I just found how to check the Indexname , but not the field "application\_id=6" inside the Index.

```auto
boolean checkIndexExist = client.admin().indices()    
                    .prepareExists("hier mytest indexname as example")
                    .execute().actionGet().isExists();

```

i tried to create request , and assign it with the indexname "mytest" above, and asked it to return the field "application\_id" like in this page

```auto
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.7/java-rest-high-get-field-mappings.html

GetFieldMappingsRequest request1 = new GetFieldMappingsRequest();
request1.indices("mytest");
request1.fields("entity", "application_id");
GetFieldMappingsResponse response = client.admin().indices()
                        .getFieldMapping(request1, RequestOptions.DEFAULT);

```

i cound not finde the RequestOptions Class.  
Otherwise at the end of the Page is written `

```auto
final Map<String, Map<String, GetFieldMappingsResponse.FieldMappingMetaData>> mappings =
    response.mappings();

and that did not work until i changed it to 

final Map<String, Map<String, Map<String, GetFieldMappingsResponse.FieldMappingMetaData>>> mappings
                        = response.mappings();

```

Please any Idea how to check the field "application\_id=6" as Request bevor letting my ClientAPI send the same Data with the same field twice , i will be thankfull.

---

<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 25, 2019, 11:39am UTC](https://discuss.elastic.co/t/how-to-check-if-a-field-from-a-json-data-exists-in-the-index-bevor-send-another-data-with-same-field-to-elasticsearch/187815/2 "2019-07-25T11:39:50Z")

</div>

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