# Query 2 indices

**URL:** <https://discuss.elastic.co/t/query-2-indices/138222>\
**Category:** Elasticsearch\
**Created:** [July 2, 2018, 2:04pm UTC](https://discuss.elastic.co/t/query-2-indices/138222 "2018-07-02T14:04:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![LesioS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lesios/32/32364_2.png) [@LesioS](https://discuss.elastic.co/u/LesioS)\
**Post date:** [July 2, 2018, 2:04pm UTC](https://discuss.elastic.co/t/query-2-indices/138222/1 "2018-07-02T14:04:19Z")

</div>

I've 2 indices:  
maindata  
`someData:keyword referrer:integer`  
and dictionary  
`refferer:keyword`

Is it possible, and if so then how to do that, to ask `maindata` for data with condition on `dictionary`? Soemthing similar to SQL's:  
`select m.someData, d.refferer from maindata m, dictionary d where m.refferer = d.id and d.refferer = "NAME";`  
Query has to be at the end `saved object` because I need it as datasource for visualization.

If not, how to gain such result without denormalizing data?

Best regards

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 2, 2018, 9:30pm UTC](https://discuss.elastic.co/t/query-2-indices/138222/2 "2018-07-02T21:30:11Z")

</div>

You can't do that natively.  
You can either denormalise, or run two queries and manage the merge in your code.

---

<div class="post-metadata">

**Author:** ![LesioS](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lesios/32/32364_2.png) [@LesioS](https://discuss.elastic.co/u/LesioS)\
**Post date:** [July 3, 2018, 8:07am UTC](https://discuss.elastic.co/t/query-2-indices/138222/3 "2018-07-03T08:07:45Z")

</div>

1. Denormalization is the thing we want to avoid 😉
2. There's no code under. We want this "combined answer" to be query for our Kibana's visualizations.

To follow p. 2: is it possible to create outside ES/Kibana piece of code (e.g. in C#, Java or whatever) and register it in Kibana as `saved object` and use it as datasource for visualization?

---

<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:** [July 31, 2018, 8:07am UTC](https://discuss.elastic.co/t/query-2-indices/138222/4 "2018-07-31T08:07:55Z")

</div>

Closed on July 31, 2018, 8:07am UTC

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