3

I just started using X-Pack for Elasticsearch and want to connect vertices from a nested document type. However, looking for documentation on this hasn't got me anywhere.

What I have is an index of documents which have person names/ids as nested documents (one document can have many persons, one person can be related to many documents). The desired result is to get a graph data with connections between persons.

Does anyone have a clue or can tell me if this is even possible?

Part of my mappings:

mappings: {
    legend: {
        properties: {
            persons: {
                type: 'nested',
                properties: {
                    id: {
                        type: 'string',
                        index: 'not_analyzed'
                    },
                    name: {
                        type: 'string',
                        index: 'not_analyzed'
                    }
                }
            }
        }
    }
}

And my Graph API query, which of course doesn't work because I don't know how to handle the "name" field of the nested "persons" field.

POST sagenkarta_v3/_xpack/_graph/_explore
{
  "controls": {
    "use_significance": true,
    "sample_size": 20000,
    "timeout": 2000
  },
  "vertices": [
    {
      "field": "persons.name"
    }
  ],
  "connections": {
    "vertices": [
      {
        "field": "persons.name"
      }
    ]
  }
}

Thanks in advance!

traustid
  • 31
  • 1

1 Answers1

0

The following question was discussed here: https://discuss.elastic.co/t/elasticsearch-x-pack-how-to-get-vertices-connections-from-nested-documents/88709

quote from Mark_Harwood - Elastic Team Member:

Unfortunately Graph does not support nested documents but you can use copy_to in your mappings to put the person data in an indexed field in the containing root document.

I can see that you have the classic problem of "computers-want-IDs-but-people-want-labels" and have both these values. In Graph (and arguably the rest of Kibana too) I suggest you use tokens that combine IDs for uniqueness' sake and names for readability by humans.

The copy_to and IDs-and-labels tips are part of the modelling suggestions in my elasticon talk this year: https://www.elastic.co/elasticon/conf/2017/sf/getting-your-data-graph-ready 3