Return JSON Array of Arrays from elastic

Hi,

We've noticed that the overhead of the JSON object structure is creating some performance problems for us. One of the largest parts of this overhead is the repetitiveness of the object properties in each object. We'd like to see if it's possible to retrieve data from Elasticsearch as a JSON array of arrays instead of array of objects. Any insight would be greatly appreciated. The example below is what we'd like to do, in this example the object properties are not listed, we would have some other object that would define these for us.

[
[
1,
"295847284",
"adventure-works\ken0",
null,
null,
"Chief Executive Officer",
"1969-01-29",
"S",
"M",
"2009-01-14",
true,
99,
69,
true,
"F01251E5-96A3-448D-981E-0F99D789110D",
"2014-06-30T00:00:00"
],
[
2,
"245797967",
"adventure-works\terri0",
"/1/",
1,
"Vice President of Engineering",
"1971-08-01",
"S",
"F",
"2008-01-31",
true,
1,
20,
true,
"45E8F437-670D-4409-93CB-F9424A40D6EE",
"2014-06-30T00:00:00"
]
]

This is not pissible in Elasticsearch itself so is something you would need to handle in a custom intermediate layer.

1 Like

Hmm... ok. We'll look into that. On a side note what about csv? I have this basic call in kibana and would just like it to return csv instead of JSON:

GET transactions/_search?filter_path=_scroll_id,hits.hits._source,-hits.hits._source.attributes&scroll=1m&size=100
{
  "query":{
      "bool":{
        "filter":[
          {"term":{"elastic_tag_subdomain" : "franklymandev"}},
          {"term":{"elastic_tag_module": "order"}}
        ]
      }
  }
}

Elasticsearch REST API only returns JSON, if you want it in CSV you will need to handle it yourself as mentioned.

For example, write a custom python script that will query elasticsearch and transform your json response into a csv one.

1 Like

Thanks for the quick responses! We already have an express.js server between our front-end and the browser so we'll try handling it there. Thanks!

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