hello datastax enterprise graph

30
Hello DSE Graph Lets build a knowledge graph Markus Höfer, codecentric AG DataStax Summit Europe 2016

Upload: datastax

Post on 06-Jan-2017

459 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Hello DataStax Enterprise Graph

Hello DSE Graph Lets build a knowledge graph Markus Höfer, codecentric AG DataStax Summit Europe 2016

Page 2: Hello DataStax Enterprise Graph

2

What is this talk about?

Page 3: Hello DataStax Enterprise Graph

3

Knowledge Graph What is the problem?

Page 4: Hello DataStax Enterprise Graph

4

15 locations

Page 5: Hello DataStax Enterprise Graph

5

Many customers

Page 6: Hello DataStax Enterprise Graph

6

300+ employees

Page 7: Hello DataStax Enterprise Graph

7

A lot of knowledge

Page 8: Hello DataStax Enterprise Graph

8

Results in graph

Page 9: Hello DataStax Enterprise Graph

9

How can we answer the following questions?

! Which projects are currently running? ! Which employee has expertise in required fields and

doesn’t work for a project at the requested time? ! Which employees already worked for a customer? ! Which employees are currently not working for a

project? ! Which skills are requested most by customers?

Page 10: Hello DataStax Enterprise Graph

10

Implementation

Page 11: Hello DataStax Enterprise Graph

11

The Setup

Page 12: Hello DataStax Enterprise Graph

12

Java driver

•  Query execution very similar to "normal" DataStax Java Driver queries

GraphResultSet executeGraph(String var1); GraphResultSet executeGraph(String var1, Map<String, Object> var2); GraphResultSet executeGraph(GraphStatement var1);

Page 13: Hello DataStax Enterprise Graph

13

Create a graph

GraphResultSet resultSet = dseSession.executeGraph( "system.createGraph(name).ifNotExist().build()", ImmutableMap.<String, Object> of("name", GRAPH_NAME) );

Page 14: Hello DataStax Enterprise Graph

14

The Schema

// Vertex label schema.vertexLabel('employee').ifNotExists().create() schema.vertexLabel('project').ifNotExists().create() // Edge label schema.edgeLabel('worked_for').ifNotExists().create() // Property keys schema.propertyKey('from').Timestamp().ifNotExists().create() schema.propertyKey('name').Text().ifNotExists().create()

Page 15: Hello DataStax Enterprise Graph

15

Indexes

// Materialized schema.vertexLabel('customer').index('byName')

.materialized().by('name').add() // Secondary schema.vertexLabel('employee').index('byCity')

.secondary().by('city').add() // Search schema.vertexLabel(‘project').index('search')

.search().by(‘discription').add()

Page 16: Hello DataStax Enterprise Graph

16

Insert Data

g.V().has('employee', 'name', 'Markus Höfer') .tryNext().orElseGet { graph.addVertex( label, 'employee', 'name', 'Markus Höfer', 'geo', POINT(51.926164 7.718504) ) }

Add employee vertex

Page 17: Hello DataStax Enterprise Graph

17

Insert Data

Add project vertex

g.V().has('project', 'name', 'ProjectX') .tryNext().orElseGet { graph.addVertex( label, 'project', 'name', 'ProjectX' ) }

Page 18: Hello DataStax Enterprise Graph

18

Add edge

def employee = g.V(employee_id).next() def project = g.V(project_id).next() employee.addEdge( 'worked_for', project, 'from', Instant.parse('2015-11-30T00:00:00.00Z'), 'until', Instant.parse('2016-11-30T00:00:00.00Z') )

Page 19: Hello DataStax Enterprise Graph

19

Subgraph looks like this

Page 20: Hello DataStax Enterprise Graph

20

Working with DataStax Studio

Page 21: Hello DataStax Enterprise Graph

21

Working with DataStax Studio

•  Markdown for documentation

•  Gremlin for schema and

traversal development

Page 22: Hello DataStax Enterprise Graph

22

Working with DataStax Studio

•  Schema aware content assist!

Page 23: Hello DataStax Enterprise Graph

23

Working with DataStax Studio

Profiling Without index

With materialized index

Page 24: Hello DataStax Enterprise Graph

24

The Result

Page 25: Hello DataStax Enterprise Graph

25

Looking back to our initial questions

Page 26: Hello DataStax Enterprise Graph

26

Working with DataStax Studio

Which skills are requested most by customers?

g.V().hasLabel('project') .out('requires').groupCount().by('name') .order(local).by(valueDecr).limit(local, 10)

Page 27: Hello DataStax Enterprise Graph

27

Working with DataStax Studio

Which employee has expertise in required fields and doesn‘t work for a project at the requested time?

Page 28: Hello DataStax Enterprise Graph

28

Working with DataStax Studio

Which employees are currently not working for a project?

Page 29: Hello DataStax Enterprise Graph

29

Whats next?

Add more connections, e.g. -  Community events -  Blog posts -  Trainings -  Geospatial traversals -  etc

Page 30: Hello DataStax Enterprise Graph

30

Questions?

Markus Höfer IT Consultant

[email protected] www.codecentric.de blog.codecentric.de/en

#HashtagMarkus