# How to join relationships in between indexes

**URL:** <https://discuss.elastic.co/t/how-to-join-relationships-in-between-indexes/310949>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [July 29, 2022, 6:42am UTC](https://discuss.elastic.co/t/how-to-join-relationships-in-between-indexes/310949 "2022-07-29T06:42:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ritikapawar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ritikapawar/32/98580_2.png) [@Ritikapawar](https://discuss.elastic.co/u/Ritikapawar)\
**Post date:** [July 29, 2022, 6:42am UTC](https://discuss.elastic.co/t/how-to-join-relationships-in-between-indexes/310949/1 "2022-07-29T06:42:45Z")

</div>

I have two index as  
mxcel\_schedule\_appoint and mxcel\_schedule staff  
both indexes has a common field as staff\_id

I want t use relationship field in between in these two indexes to get the no of visits for each staff based on the count from schedule\_appoint index.

merging those indexes is not working for me.  
I'm trying to visualize it by writing custom code in vega

```auto
{
  "$schema": "https://vega.github.io/schema/vega-lite/v2.json",
  "data": {
    "url": {
      "index": ["mxcel_schedule_appoint","mxcel_schedule_staff"]
      "%context%": true,
      "body": {"size": 10000}     
    },
    "transform":
    {
  "source": {
    "index": ["mxcel_schedule_appoint", "mxcel_schedule_staff"]
  },
  "pivot": {
    "group_by": {
      "id": {"terms": {
        "field": "staff_id"
      }}
    },
    "format": {"property": "hits.hits"}
  },
  "mark": "bar",
  "encoding": {
    "tooltip": {"field": "_source.staff_name", "type": "ordinal"},
    "y": {"aggregate":"count",
    "field":"_source.staff_id",
    "type": "quantitative"},
    
    "x": {"field": "_source.staff_name", "type": "ordinal"}
  }
}

```

or is there any other way to do this in kibana?

---

<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:** [August 26, 2022, 6:43am UTC](https://discuss.elastic.co/t/how-to-join-relationships-in-between-indexes/310949/2 "2022-08-26T06:43:36Z")

</div>

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