# Count for 1 several JSONS with different fields but the same "id"

**URL:** <https://discuss.elastic.co/t/count-for-1-several-jsons-with-different-fields-but-the-same-id/154406>\
**Category:** Elasticsearch\
**Created:** [October 29, 2018, 9:17am UTC](https://discuss.elastic.co/t/count-for-1-several-jsons-with-different-fields-but-the-same-id/154406 "2018-10-29T09:17:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florian75](https://avatars.discourse-cdn.com/v4/letter/f/9d8465/32.png) [@Florian75](https://discuss.elastic.co/u/Florian75)\
**Post date:** [October 29, 2018, 9:17am UTC](https://discuss.elastic.co/t/count-for-1-several-jsons-with-different-fields-but-the-same-id/154406/1 "2018-10-29T09:17:36Z")

</div>

Hello everyone,  
I have a question, I think the anwser is simple but It blocks me for some days.

I need to know if it is possible to count different ID with the field A and field B in different JSONS.  
For exemple I have 3 jsons :

JSON 1  
{  
fieldID: 1  
field A : A  
}

JSON 2  
{  
fieldID: 1  
field B : B  
}  
JSON 3  
{  
fieldID : 2  
field A: A  
}  
How can I made a "count distinct" from ID where there are field A =A AND field B = B ? (for example, in this case, i must have 1 because ID 2 haven't json with field B :B )  
I have already try with filter but AND and OR fonctions work only on one JSON. And i have seen nothing about that on website or forum.

If you need more information, don't hesitate  
Thank you !

---

<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:** [November 26, 2018, 9:28am UTC](https://discuss.elastic.co/t/count-for-1-several-jsons-with-different-fields-but-the-same-id/154406/2 "2018-11-26T09:28:49Z")

</div>

Closed on November 26, 2018, 9:28am UTC

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