# Problem with inconsistently inserted documents using javascript client with etl

**URL:** <https://discuss.elastic.co/t/problem-with-inconsistently-inserted-documents-using-javascript-client-with-etl/108943>\
**Category:** Elasticsearch\
**Created:** [November 23, 2017, 11:31pm UTC](https://discuss.elastic.co/t/problem-with-inconsistently-inserted-documents-using-javascript-client-with-etl/108943 "2017-11-23T23:31:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyv](https://avatars.discourse-cdn.com/v4/letter/k/b5ac83/32.png) [@kyv](https://discuss.elastic.co/u/kyv)\
**Post date:** [November 23, 2017, 11:31pm UTC](https://discuss.elastic.co/t/problem-with-inconsistently-inserted-documents-using-javascript-client-with-etl/108943/1 "2017-11-23T23:31:33Z")

</div>

I am having trouble with the consistency of indexing data using javascript client  
and etl package for node. My code imports data to mongodb or elasticsearch, depending  
on a config option.

The following code contains tests for both mongodb and elasticsearch.  
While inserting to mongodb (with monk) works perfectly, I don't get consistent  
results from elasticsearch javascript client. Most of the time, 2 of the 3 documents  
in my CSV will get inserted. But some times it will be 1.

Both the mongo and the elastic option use the same node etl pipeline.

> **[kyv/stream2db](https://github.com/kyv/stream2db/tree/master/test)**
>
> stream2db - Stream a file or url to elasticSearch or mongodb

Thanks for your help

---

<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:** [November 24, 2017, 6:21am UTC](https://discuss.elastic.co/t/problem-with-inconsistently-inserted-documents-using-javascript-client-with-etl/108943/2 "2017-11-24T06:21:14Z")

</div>

In the context of tests, you should call refresh before searching.

---

<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:** [December 22, 2017, 6:21am UTC](https://discuss.elastic.co/t/problem-with-inconsistently-inserted-documents-using-javascript-client-with-etl/108943/3 "2017-12-22T06:21:28Z")

</div>

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