Use Table visualization to display linked metrics from different documents

Hello all,

I'm trying to display metrics from different documents but I need to relate those metrics in the following way:

Let's assume I have two types of documents in the same index:

Worker Document:
{
workerID: 3948,
workerName: John
}

Organization Document
{
workerID: 3948,
organizationName: Elastic
}

Is it possible to connect "organizationName" and "workerName" by "workerID" to display the information in a table as below?

Thank you in advance.

1 Like

Hi, Elasticsearch doesn't have a concept of joining or foreign keys, so the connection as you describe it isn't an option.

The best solution I've seen is to index the documents in a way where workerName and organizationName is in the same document, and a clever way of doing that would be to use workerID as the _id of the document in Elasticsearch. As additional information about the worker comes into the system, you will update document _id: 3940. Essentially, that merges new info with existing info. There may be field collisions, but it would only be a problem if the values are changing - then the integrity would be getting lost in the data.

As for avoiding those collisions, updating an Elasticsearch document can also be a partial operation, as opposed to a whole-document update. See https://www.elastic.co/guide/en/elasticsearch/guide/current/partial-updates.html

1 Like

@tsullivan, thank you for your help.

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