FindEntityInfo

This command is to ask for meta information about entities in the system or in traditional database parlance, information about the schema. This command can be used to find out the classes added to the metadata so far, properties added to entities of various classes, number of entities that have some property defined, more information on entities themselves like how many connections they have, or how many properties they have.

Note: This can be one of the slower commands due to the amount of metadata being traversed to respond to some parameters specified in the command.

Parameters

  • [optional] ref: Reference to other objects within the transaction.
  • [optional] class: name of entity class.

Blocks

  • [optional] constraints
  • [optional] results (with different expectations as defined below)

Details

The ref parameter allows the use of a previous search result to be used for querying meta information for the entities that were matched already. If the constraints block is skipped, information about all entities with the given class are returned. If the class is skipped, all entities ever added to the system are queried for information. It takes precedence over class + constraints.

“results” block is assumed in any invocation of this call. If it is not explicitly specified, its default behavior is to return a list of entity classes encountered based on the search criteria. By default, each group gets the count as “_matched” : <number>. If it is explicitly specified, the use is modified for this call. It does not support count, sum, or average. If limit is provided, the number of entries returned will be n <= m (which is the actually matched quantity). “list” is considered as an implicit parameter in this block. We introduce new keyword to allow us to get all the desired metadata.

In addition to “list”, user can specify “classwise” as true or false. “classwise” is true as the default option when “results” block is missing or is empty or only “list” is specified. If no other option is added in “list”, this will return the various classes that entities belong to.

The various options within the “list” parameter of the “results” block are:

  • name of specific property keys: this will return property keys with <class, a count of entities that they appear in, indexed or not, data-type>. The result is organized in a “properties” block if “classwise” is false. If “classwise” is true in the results block, then we get <count of entities, indexed or not as bool, data-type>, since the properties are organized class wise.
  • “*”: similar to previous, except for all properties.

Examples

Retrieve the schema for all Entity objects in the system by class:

[ {
    "FindEntityInfo": {
        "results" : {
            "list" : [ "*" ]
        }
    }
}
]

# Response:
[ {
    "FindEntityInfo" : {
        "returned" : 3,
        "classes" : [
            "Visit" : {
                "start_time" : [4, true,  Time],
                "end_time" :   [4, false, Time],
                "_matched" :   [4, false, None]
            },
            "Area" : {
                "name" :     [10, true,  String],
                "_matched" : [10, false, None]
            },
            "Person" : {
                "name" :     [20, false, String],
                "address" :  [10, false, String],
                "age" :      [5,  true,  Number],
                "_matched" : [20, false, None]
            }
        ]
    }
}]

Retrieve the schema for all Entity objects in the system by properties:

[ {
    "FindEntityInfo": {
        "results" : {
            "list" : [ "*" ],
            "classwise": false
        }
    }
}
]

# Response:
[ {
    "FindEntityInfo" : {
        "returned" : 5,
        "properties" : [
            "start_time" : {
                "Visit" :    [4, true, Time],
                "_matched" : [4, false, None]
            },
            "end_time" : {
                "Visit" :    [4, false, Time],
                "_matched" : [4, false, None]
            },
            "name" : {
                "Area":      [10, true,  String],
                "Person":    [20, true,  String],
                "_matched" : [30, false, None]
            },
            "address" : {
                "Person" :   [10, false, String],
                "_matched" : [10, false, None]
            },
            "age" : {
                "Person" :   [5, true,  Number],
                "_matched" : [5, false, None]
            }
        ]
    }
}]

Retrieve the number of Entity objects for all classes:

[ {
    "FindEntityInfo": {
        "results" : {
            "list" : [ "*" ],
            "classwise": true
        }
    }
}
]

# Response:
[ {
    "FindEntityInfo" : {
        "returned" : 3,
        "classes" : [
            "Visit" : {
                "_matched": [4, false, None]
            },
            "Area" : {
                "_matched": [10, false, None]
            },
            "Person" : {
                "_matched": [35, false, None]
            }
        ]
    }
}]