# Javascript problem

**URL:** <https://discuss.elastic.co/t/javascript-problem/134352>\
**Category:** Elasticsearch\
**Created:** [June 4, 2018, 4:16am UTC](https://discuss.elastic.co/t/javascript-problem/134352 "2018-06-04T04:16:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rr\_silicon](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rr\_silicon](https://discuss.elastic.co/u/rr_silicon)\
**Post date:** [June 4, 2018, 4:16am UTC](https://discuss.elastic.co/t/javascript-problem/134352/1 "2018-06-04T04:16:48Z")

</div>

I have a script that was running on ES 5.x and that I tried now on ES 6.2.4.

```
define(['scripts/d3.v4', 'scripts/elasticsearch'], function (d3, es) {

"use strict";

var svg = d3.select("svg"),
width = +svg.attr("width"),
height = +svg.attr("height");

var format = d3.format(",d");

var color = d3.scaleOrdinal(d3.schemeCategory20c);

var pack = d3.pack()
.size([width, height])
.padding(1.5); 

var client = new elasticsearch.Client({ 
host: 'http://192.168.10.151:9200'
});

client.search({
index: 'ips-inx',
size: 0,
body: {
    "size": 0,
    "aggs" : {
            "recent": {
                "filter": {
                    "range": {
                        "timestamp": {
                            "from": "now-1M"
                        }
                    }
                }
            }
    },
    "aggs": {
        "srcs" : {
            "terms" : {
                "field" : "src_ip",
                "size" : 10
            },
            "aggs" : {
                "dsts" : {
                    "terms" : {
                        "field" : "dst_ip",
                        "size" : 10
                    }
                }
            }
        }
    }
}
}).then(function(d) {
  console.log(d);
  d.value = +d.value;
  if (d.value) return d;

```

I get the following error that I don't undertand once the debugger proceed from the fourth last line above. - }).then(function(d) {

 ![2018-06-03_21-12-42](https://us1.discourse-cdn.com/elastic/original/3X/4/3/4306f1a5c09dac81efcaf626eea574a4a45a9156.png)

Appreciate assistance.

---

<div class="post-metadata">

**Author:** ![rr\_silicon](https://avatars.discourse-cdn.com/v4/letter/r/67e7ee/32.png) [@rr\_silicon](https://discuss.elastic.co/u/rr_silicon)\
**Post date:** [June 5, 2018, 6:30pm UTC](https://discuss.elastic.co/t/javascript-problem/134352/2 "2018-06-05T18:30:35Z")

</div>

Solved. I made an error when creating index. Corrected the mappings and it worked.

---

<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 3, 2018, 6:30pm UTC](https://discuss.elastic.co/t/javascript-problem/134352/3 "2018-07-03T18:30:42Z")

</div>

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