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.

tip 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: Note: its not “_ref”. If you want to use results of a previous Entity/Image search result, you can use this parameter. It takes precedence over class + constraints.
  • [optional] class: name of entity class. (This can help restrict the search set)

Blocks

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

“ref” allows the use of a previous search result to be used for querying meta information for the entities that were matched already. However, we do not support “_ref” in this call since its goal is to find information about entities rather than using the results for a neighbor search. 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.

“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 if indexed>. 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 if indexed>, since the properties are organized class wise. The property types are only returned for indexed properties since it is possible to add the same property key in same class of entities with different data types for non-indexed properties.
  • “*”: similar to previous, except for all properties,

Examples

# To find schema information for all entities and all their properties.

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

# Response:
"FindEntityInfo" : {
    "returned" : 3,      # class wise, so the count indicates how many classes
    "classes" : [
        "Visit" : {
            "start_time" : [4, true, Time],
            "end_time" : [4, false, MaybeMixed],
            "_matched" : [4, false, None]
        },
        "Area" : {
            "name" : [10, true, String],
            "_matched" : [10, false, None]
        },
        "Person" : {
            "name" : [20, String],
            "address" : [10, false],
            "age" : [5, true, Number],
            "_matched" : [20, false, None]
        }
    ]
}

# Find schema information but arrange them property wise
"FindEntityInfo": {
    "results" : {
        "list" : ["*" ],
        "classwise": false
    }
}

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

# Traverses all the entities but doesn't return
# information about any properties. Just a count per class.
"FindEntityInfo": {
}
# OR
"FindEntityInfo": {
    "results" : {
        "classwise": true
    }
}

# Response:
"FindEntityInfo" : {
    "returned" : 3,      # class wise, so the count indicates how many classes
    "classes" : [
        "Visit" : {
            "_matched": [4, false, None]
        },
        "Area" : {
            "_matched": [10, false, None]
        },
        "Person" : {
            "_matched": [35, false, None]
        }
    ]
}