
Query = "SELECT VALUE LOWER(c.name) FROM c"Ĭontainer container = await client.GetDatabase("myDatabase").CreateContainerAsync(containerProperties) NET SDK: ContainerProperties containerProperties = new ContainerProperties("m圜ontainer", "/pk")
#Projector definition how to
Here's an example of how to create computed properties in a new container using the. You can either create a new container with computed properties defined, or add them to an existing container. SDKĬomputed properties are currently only available in preview package versions. Once the computed properties have been created, you can execute queries that reference them using any method including all SDKs and Data Explorer in the Azure portal. Queries can't use any of the following clauses: WHERE, GROUP BY, ORDER BY, TOP, DISTINCT, OFFSET LIMIT, EXISTS, ALL, and NONE.Īggregate functions, spatial functions, non-deterministic functions and user defined functions aren't supported.ĭuring the preview, computed properties must be created using the. Queries must use a VALUE clause in the projection. Examples of supported FROM clauses are FROM c, FROM root c AND FROM M圜ontainer c. Queries must specify a FROM clause representing the root item reference. The constraints on computed property query definitions are: Queries should evaluate to a deterministic value for all items in a container.
#Projector definition update
Queries in the computed property definition must be valid syntactically and semantically, otherwise the create or update operation will fail. This applies to all indexing paths specified including included paths, excluded paths, spatial indexes and composite indexes. can't be used as computed property names.Ī computed property name can't match a property path that is already indexed. Reserved system property names such as id, _rid, _ts etc. The value of name property represents the top-level property name that can be used to reference the computed property. The constraints on computed property names are:Īll computed properties must have unique names. This is because wildcard projection does not automatically include computed properties.

Queries will always use the computed property instead of the persisted property, with the exception of the persisted property being returned instead of the computed property if there is a wildcard projection in the SELECT clause. Regardless of whether the computed property is indexed, values from persisted properties that share a name with a computed property won't be included in the index. This article uses the prefix cp_ in all name definitions.ĭefining a computed property with the same name as a persisted property won't give an error, but it may lead to unexpected behavior.

To avoid overlapping property names, you can add a prefix or suffix to all computed property names. It's strongly recommended that computed properties are named in such a way that there's no collision with a persisted property name. "query": "SELECT VALUE LOWER(c.name) FROM c" Every container can have a maximum of 20 computed properties.

Computed properties are scoped to an individual item and therefore can't use values from multiple items or rely on other computed properties. The name is the computed property name, and the query defines logic to calculate the property value for each item. Each computed property definition has two components: a name and a query.
#Projector definition free
Do you have any feedback about computed properties? We want to hear it! Feel free to share feedback directly with the Azure Cosmos DB engineering team: Computed property definitionĬomputed properties must be at the top level in the item and can't have a nested path.
