# Dynamic field fetching

**URL:** https://discuss.elastic.co/t/dynamic-field-fetching/201584
**Category:** Logstash
**Created:** [September 30, 2019, 7:12am UTC](https://discuss.elastic.co/t/dynamic-field-fetching/201584 "2019-09-30T07:12:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![amanpradhan](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@amanpradhan](https://discuss.elastic.co/u/amanpradhan)
#### Post date: [September 30, 2019, 7:12am UTC](https://discuss.elastic.co/t/dynamic-field-fetching/201584/1 "2019-09-30T07:12:07Z")

</div>

I have a field "msg\_string" in my logs which has multiple fields saparated by tilda "~"  
e.g. msg\_string =firstname~lasname~city~hobby~marks ...  
position of fields firstname,lastname are at index 0 and 1  
the position of field city is not fixed i can appear anywhere in msg\_string hence i am using look up with city names. I am using split to saparate out fields in msg\_string and extract firstname and lastname  
I have a file with city names for look up i want to add a field name city using lookup file  
how to do it please help.  
split =\> ["msg\_string","~"]  
add\_field =\> {"firstname"=\> "%{[msg\_string][0]}"}  
add\_field =\> {"lastname"=\> "%{[msg\_string][1]}"}

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [September 30, 2019, 7:19am UTC](https://discuss.elastic.co/t/dynamic-field-fetching/201584/2 "2019-09-30T07:19:09Z")

</div>

Can you not use a cab filter with “~” as a separator or perhaps a dissect filter?

---

<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: [October 28, 2019, 7:26am UTC](https://discuss.elastic.co/t/dynamic-field-fetching/201584/3 "2019-10-28T07:26:36Z")

</div>

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