Sample filters - Neptune Analytics

Sample filters

Sample filter: Specifying vertex and edge properties for export

{ "vertexFilter": { "Professor": { "properties": { "name": { "outputType": "String" }, "val": { "outputType": "Int" } } } }, "edgeFilter": { "knows": { "properties": { "weight": { "outputType": "Float" } } } } }
Vertex files:
  • Only vertices with the "Professor" label will be exported.

  • For each "Professor" vertex, the exported data will have the following columns:

    • ~id - The unique identifier of the vertex.

    • ~label - The label of the vertex, which will be "Professor".

    • name - The "name" property of the vertex, exported as a String type.

    • val - The "val" property of the vertex, exported as an Integer type.

"~id" "~label" "name:String" "val:Int"

"p5"

"Professor"

"Professor 5"

11

"p2"

"Professor"

"Professor 2"

2

"p1"

"Professor"

"Professor 1"

1

Edge files:
  • Only edges with the "knows" label will be exported.

  • For each "knows" edge, the exported data will have the following columns:

    • ~from - The unique identifier of the source vertex of the edge.

    • ~to - The unique identifier of the target vertex of the edge.

    • ~label - The label of the edge, which will be "knows".

    • weight - The "weight" property of the edge, exported as a Float type.

"~from" "~to" "~label" "weight:Float"

"p1"

"p5"

"reports"

1

"p1"

"p2"

"knows"

0.5

"p2"

"s2_2"

"knows"

0.6

Sample filter: Exporting vertices and edges to a single schema

{ "vertexFilter": { "_VERTEX_ALL_LABELS_": { "properties": { "name": { "outputType": "String" }, "val": { "outputType": "Int" } } } }, "edgeFilter": { "_EDGE_ALL_LABELS_": { "properties": { "weight": { "outputType": "Float" } } } } }

This filter will export the “name” and “val” vertex properties for all vertices (regardless of label) into vertex files with a unified schema. A Parquet export have columns ~id, ~label, val, and name, with val as an Integer type column, and name a String column. For CSV exports, the last two columns will have their types appended to be val:Int, and name:String. Unlike the case where a specific label is specified, the label column here will vary based on the labels of the vertices. Similarly, this filter will export the “weight” property as a Float column for all edges regardless of the edge label.

"~id" "~label" "name:String" "val:Int"

"p5"

"Professor"

"Professor 5"

11

"p2"

"Professor"

"Professor 2"

2

"p1"

"Professor"

"Professor 1"

1

"~from" "~to" "~label" "weight:Float"

"p1"

"p5"

"reports"

1

"p1"

"p2"

"knows"

0.5

"p2"

"s2_2"

"knows"

0.6

Sample filter: Exporting all vertices but no edges

{ "edgeFilter": {} }

This exports all vertices because there are no vertexFilters, and exports no edges because the edgeFilter is provided, but empty.

Sample filter: Exporting all properties of specific labels

{ "vertexFilter": { "Professor": {}, "Student": {} } }

This filter will export all properties of vertices with the label “Professor” or “Student” into files with schemas defined by the “Professor” and "Student” vertex property sets, respectively, along with all edges.

"~id" "~label" "Income:Int" "name:String"

"p5"

"Professor"

80000

"Professor 5"

"p2"

"Professor"

90000

"Professor 2"

"p1"

"Professor"

75000

"Professor 1"

"~id" "~label" "GraduationYear:Int" "name:String"

"s1"

"Student"

2021

"Bob"

"s2"

"Student"

2024

"Sam"

"s3"

"Student"

2008

"Jose"

Sample filter: Exporting edge topology without properties

{ "edgeFilter": { "_EDGE_ALL_LABELS_": { "properties": {} } } }

By specifying properties as an empty object, only the ~from, ~to, and ~label columns will be exported for all edges.

"~from" "~to" "~label"

"p1"

"p5"

"reports"

"p1"

"p2"

"knows"

"p2"

"s2_2"

"knows"

Run a mutation algorithm then export the results

Run the following query:

CALL neptune.algo.pageRank.mutate( { writeProperty:"P_RANK", dampingFactor: 0.85, numOfIterations: 1, edgeLabels: ["route"] } )

Followed by an export with a filter:

{ "vertexFilter": { "Airport": { "properties": { "P_RANK": { "outputType": "Float" } } } } }

The result would be:

"~id" "~label" "P_RANK:Float"

"SYD"

"Airport"

0.005

"JFK"

"Airport"

0.008

"LGA"

"Airport"

0.002