datavis-tech / es-tabify

A function that converts ElasticSearch results into a table data structure.
MIT License
12 stars 7 forks source link

multiple metric aggregation test case is not working #6

Open kullu208025 opened 4 years ago

kullu208025 commented 4 years ago

Please help!! Following test case is not working

{
  "took" : 24,
  "timed_out" : false,
  "_shards" : {
    "total" : 107,
    "successful" : 107,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "2" : {
      "value" : 89.47877310881191
    },
    "3" : {
      "value" : 4.8758952E7
    }
  }
}

by processing above output using tabify OUTPUT = [ { '2': 89.47877310881191 } ] aggregation with key '3' is missing

curran commented 4 years ago

PRs Welcome :)

Adding this as a failing test case would be a great start.

kullu208025 commented 4 years ago

Sorry closed it by mistake....

PRs Welcome :)

Adding this as a failing test case would be a great start.

How do i add it as a failing test case

curran commented 4 years ago

I would recommend using Mocha, with a similar configuration to this other project:

kullu208025 commented 4 years ago

I would recommend using Mocha, with a similar configuration to this other project:

* Add this script to `package.json` https://github.com/datavis-tech/topologica/blob/master/package.json#L9

* Add a file `test.js` using patterns similar to these https://github.com/datavis-tech/topologica/blob/master/test.js

* Import the function, add a test case

Actually i am new to nodejs , My code till now looks like

const tabify = require('./app/library/tabify');
var test_case = {
  "took" : 24,
  "timed_out" : false,
  "_shards" : {
    "total" : 107,
    "successful" : 107,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 10000,
      "relation" : "gte"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "2" : {
      "value" : 89.47877310881191
    },
    "3" : {
      "value" : 4.8758952E7
    }
  }
};
console.log(tabify(test_case));

Output : [ { '2': 89.47877310881191 } ]. Can you please help me with this one .....