# Joining of results from elecsticsearch filter

**URL:** https://discuss.elastic.co/t/joining-of-results-from-elecsticsearch-filter/183125
**Category:** Logstash
**Created:** [May 28, 2019, 2:30pm UTC](https://discuss.elastic.co/t/joining-of-results-from-elecsticsearch-filter/183125 "2019-05-28T14:30:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![marksparrish](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marksparrish/32/105857_2.png) [@marksparrish](https://discuss.elastic.co/u/marksparrish)
#### Post date: [May 28, 2019, 2:30pm UTC](https://discuss.elastic.co/t/joining-of-results-from-elecsticsearch-filter/183125/1 "2019-05-28T14:30:08Z")

</div>

I am trying to join the results of an elasticsearch filter query.  
The history index has two fields - id and result.  
I want to create a field in the new index called results that contains both the id and the result e.g results =\> 1-B, 2-A, 3-C, 4-A.

I have tried both of the following but both only give me an array of nulls. How do you properly reference the fields

```
elasticsearch {
    hosts => ["192.168.1.42"]
    index => "history"
    query => "id:%{[ID]}"
    fields => { 
        "id.result" => "results"
     }
    result_size => 1000
}

elasticsearch {
	hosts => ["192.168.1.42"]
	index => "history"
	query => "id:%{[ID]}"
	fields => { 
		"history-%{id}.history-%{result}" => "results"
	}
	result_size => 1000
}

elasticsearch {
    hosts => ["192.168.1.42"]
    index => "history"
    query => "id:%{[ID]}"
    add_field => { "elections" => "%{election_id}.%{voted}" }
    result_size => 1000
}
```

---

<div class="post-metadata">

### Author: ![marksparrish](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marksparrish/32/105857_2.png) [@marksparrish](https://discuss.elastic.co/u/marksparrish)
#### Post date: [May 28, 2019, 4:28pm UTC](https://discuss.elastic.co/t/joining-of-results-from-elecsticsearch-filter/183125/2 "2019-05-28T16:28:27Z")

</div>

Went a different direction and added fields for each grade.

```
elasticsearch {
    hosts => ["192.168.1.42"]
    index => "history"
    query => "id:%{[ID]}"
    fields => { 
        "grade-a" => "id"
     }
    result_size => 1000
}
```

---

<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: [June 25, 2019, 4:28pm UTC](https://discuss.elastic.co/t/joining-of-results-from-elecsticsearch-filter/183125/3 "2019-06-25T16:28:38Z")

</div>

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