# Arrange multiple fields into one line

**URL:** <https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482>\
**Category:** Kibana\
**Created:** [April 16, 2024, 8:03am UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482 "2024-04-16T08:03:57Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aviel\_Bashari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviel_bashari/32/92464_2.png) [@Aviel\_Bashari](https://discuss.elastic.co/u/Aviel_Bashari)\
**Post date:** [April 16, 2024, 8:03am UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482/1 "2024-04-16T08:03:57Z")

</div>

Hi,  
I have an execution of a bunch of tests that run with multiple devices with multiple roles(DEVICE\_1, DEVICE\_2, etc..)  
this means that for each test, I have for example 4 devices involved.  
each device pushes its own data(and adds a role text field to identify), my goal is to take all the data lines from the 1st test(identified by test\_id) and arrange them into one line(since all the data belong to test\_id=0).

Up to now I just created a nested dictionary like this:  
{INPUT:{ROLE:{FIELD:VALUE}}}  
then, I pushed the dictionary(using the elastic python package) and this flattened the dictionary - this created a single line with all the data as I expected.  
this is not a scalable solution for many devices since the role is part of the field.  
is there any solution for it?

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [April 16, 2024, 8:37am UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482/2 "2024-04-16T08:37:18Z")

</div>

Hi @Aviel_Bashari,

Welcome back! Can you share your current index mapping to highlight the data structure you are pushing to Elasticsearch? Are you making use of nested fields or object types to represent the device information for each test?

---

<div class="post-metadata">

**Author:** ![Aviel\_Bashari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviel_bashari/32/92464_2.png) [@Aviel\_Bashari](https://discuss.elastic.co/u/Aviel_Bashari)\
**Post date:** [April 16, 2024, 9:14am UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482/3 "2024-04-16T09:14:30Z")

</div>

sure!

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/b/4b1a054760a067665ef493b948380f7db276c67d.png)

I order the data inside the nested dictionary as I mentioned above, and then I know which field belongs to each device since the role is part of the field name.

---

<div class="post-metadata">

**Author:** ![Aviel\_Bashari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviel_bashari/32/92464_2.png) [@Aviel\_Bashari](https://discuss.elastic.co/u/Aviel_Bashari)\
**Post date:** [April 18, 2024, 11:52am UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482/4 "2024-04-18T11:52:37Z")

</div>

@carly.richmond any advice, please? 🙂

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [April 22, 2024, 4:08pm UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482/5 "2024-04-22T16:08:40Z")

</div>

Can you share what the data looks like? I'm struggling to figure out which attributes refer to your device results versus to test.

---

<div class="post-metadata">

**Author:** ![Aviel\_Bashari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviel_bashari/32/92464_2.png) [@Aviel\_Bashari](https://discuss.elastic.co/u/Aviel_Bashari)\
**Post date:** [April 30, 2024, 6:01am UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482/6 "2024-04-30T06:01:16Z")

</div>

assume that i have 2 participating devices named 'device1' and 'device2'.  
each of them executes some operations and finally prints the same result.  
in my dictionary I setting INPUT which is the parameters that I gave to the deviceX to run with, and OUTPUT which is the printed result after all operations.  
cuureenlty I set inside the 2 keys(INPUT & OUTPUT) nested dictionary which contains the roles of the device for example 'CMP180'.  
for example if I have an OUTPUT parameters called 'ANT' for 2 devices I will get 2 different fields:  
OUTPUT\_DEVICE1\_ANT  
OUTPUT\_DEVICE2\_ANT  
And so on for all INPUT & OUTPUT fields.  
this is not a scalable solution for my system since I have many devices in many executions.  
attached screenshot with INOUT and OUTPUT for 1 device named 'CMP180'.  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/a/0/a0c42d7cab621ca893a1d0c119bff96e447c32f3.png)

---

<div class="post-metadata">

**Author:** ![Aviel\_Bashari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviel_bashari/32/92464_2.png) [@Aviel\_Bashari](https://discuss.elastic.co/u/Aviel_Bashari)\
**Post date:** [May 1, 2024, 7:00am UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482/7 "2024-05-01T07:00:29Z")

</div>

@carly.richmond as you can see in the attached screenshot:  
I have a dictionary and inside I have INPUT and OUTPUT dictioinaries,inside I have the roles DUT/CMP and the data for each.  
when I pushed this to ELK(using Elasticsearch package in python) I got the data as mention in my previous comment:  
each field contains the device role - this is my big issue.  
can you advice please 🙂  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/3/0336e0708d78a338fa77deebe1f762ab010f046d.png)

---

<div class="post-metadata">

**Author:** ![Aviel\_Bashari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aviel_bashari/32/92464_2.png) [@Aviel\_Bashari](https://discuss.elastic.co/u/Aviel_Bashari)\
**Post date:** [May 6, 2024, 6:43am UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482/8 "2024-05-06T06:43:26Z")

</div>

@carly.richmond any help, please? 🙂

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [May 7, 2024, 9:42am UTC](https://discuss.elastic.co/t/arrange-multiple-fields-into-one-line/357482/9 "2024-05-07T09:42:23Z")

</div>

Hi @Aviel_Bashari,

Thanks for reaching out. I've had a look at your data, and it really depends on what you want to search for/ aggregate when it comes to your test output. I did wonder if you could flatten the schema to generic terms and then make use of either [nested](https://www.elastic.co/guide/en/elasticsearch/reference/current/nested.html) or [object arrays](https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html) rather than hard-coding your field names as you have in your current schema.

Alternatively you could have a look at the [flattened](https://www.elastic.co/guide/en/elasticsearch/reference/current/flattened.html) type and see if ingesting the test result json object as a single structure could help you avoid mapping explosion. But I would think about your queries and output first as they can impact the choice.

Hope that helps!
