Examining schema

How to examine schema.

Examining schema can be done to either verify the existence or non-existence of schema before creation.

Procedure

  1. A list of all schema can be retrieved with the following command:
    schema.describe()

    In Studio and Gremlin console, a list is retrieved, although the presentation is different. Here is a portion of a Studio result:

  2. The schema for a particular element can be examined by appending describe() to a more specific schema:
    schema.edgeLabel('includedIn').describe()
    schema.edgeLabel("includedIn").multiple().properties("amount").create()
    schema.edgeLabel("includedIn").connection("recipe", "meal").connection("recipe", "book").connection("recipe", "ingredient").connection("ingredient", "recipe").connection("meal", "book").add()
  3. Some groovy steps are useful in the Gremlin query to find specific schema descriptions. For instance, to inspect only the vertex labels and their indexes, use the split() and grep()steps:
    schema.describe().split('\n').grep(~/.*vertexLabel.*/)
    In Studio: