# Only insert json objects that are not in elasticsearch

**URL:** <https://discuss.elastic.co/t/only-insert-json-objects-that-are-not-in-elasticsearch/245712>\
**Category:** Elasticsearch\
**Created:** [August 20, 2020, 6:25am UTC](https://discuss.elastic.co/t/only-insert-json-objects-that-are-not-in-elasticsearch/245712 "2020-08-20T06:25:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmaharjan](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@jmaharjan](https://discuss.elastic.co/u/jmaharjan)\
**Post date:** [August 20, 2020, 6:25am UTC](https://discuss.elastic.co/t/only-insert-json-objects-that-are-not-in-elasticsearch/245712/1 "2020-08-20T06:25:20Z")

</div>

Hello. Very new to elasticsearch. I am trying to use the ELK stack to provide a tool for viewing records obtain from an external API. The setup is:

- Get new records from external API
- Add them to elasticsearch if they do not exist in elastic search
- View using Kibana

Every time I get new records from the external API, I save them as a list of dictionaries -- each record is a dictionary, there is a list of such records. I am looking for a query to get all documents from elasticsearch that match the any item in that list.

For example if `json_dump` is a list of json objects or dictionaries, how would you query elasticsearch such that only the documents that match json objects in `json_dump` are returned. The idea here is to then push `documents_from_external_API - documents_from_es_query` into elasticsearch via logstash.

---

<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:** [September 17, 2020, 6:25am UTC](https://discuss.elastic.co/t/only-insert-json-objects-that-are-not-in-elasticsearch/245712/2 "2020-09-17T06:25:38Z")

</div>

Closed on September 17, 2020, 6:25am UTC

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