# Data not getting synced properly from SQL to elastic

**URL:** <https://discuss.elastic.co/t/data-not-getting-synced-properly-from-sql-to-elastic/351722>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-sql\
**Created:** [January 24, 2024, 2:29pm UTC](https://discuss.elastic.co/t/data-not-getting-synced-properly-from-sql-to-elastic/351722 "2024-01-24T14:29:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![abhishek\_agarwal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/abhishek_agarwal/32/131089_2.png) [@abhishek\_agarwal](https://discuss.elastic.co/u/abhishek_agarwal)\
**Post date:** [January 24, 2024, 2:29pm UTC](https://discuss.elastic.co/t/data-not-getting-synced-properly-from-sql-to-elastic/351722/1 "2024-01-24T14:29:15Z")

</div>

I am syncing data from sql to elastic and in filter in the code block I am appending to map eg features but what is happening is that when I am running the bulk sql query ,not all features are getting appended to each index. eg if index 1 has 10 features then 2 or 3 are getting ingested to elastic but when I am directly specifying the id in = in sql query then all 10 features are getting synced. But the bulk query if I am running separating then also it gives the correct count.

```auto
filter {
    aggregate {
      task_id => "%{HotelCode}"
      code => "
        map['HotelCode'] ||= event.get('HotelCode')

        map['Features']||= []  

        map['Features'] << {

            'FeatureId' => event.get('FeatureId'),
            'FeatureIdName' => event.get('FeatureIdName'),
            'Group' => event.get('GroupName'),
            'Rank' => event.get('Rank')
        }

        event.cancel()
       "
      push_previous_map_as_event => true
      timeout => 5
    }
  }

```

---

<div class="post-metadata">

**Author:** ![bogdan.pintea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bogdan.pintea/32/45740_2.png) [@bogdan.pintea](https://discuss.elastic.co/u/bogdan.pintea)\
**Post date:** [January 24, 2024, 3:52pm UTC](https://discuss.elastic.co/t/data-not-getting-synced-properly-from-sql-to-elastic/351722/2 "2024-01-24T15:52:58Z")

</div>

@abhishek_agarwal if this is about configuring Logstash, you might want to choose that category for your question to have it reach the right groups, or at least add the `logstash` tag.  
`elastic-stack-sql` is about using [Elastic's SQL implementation](https://www.elastic.co/guide/en/elasticsearch/reference/master/xpack-sql.html) once your data is ingested into Elasticsearch.

---

<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:** [February 21, 2024, 4:51pm UTC](https://discuss.elastic.co/t/data-not-getting-synced-properly-from-sql-to-elastic/351722/4 "2024-02-21T16:51:45Z")

</div>

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