azureazure-digital-twins

How to make a case insensitive query in Azure Digital Twins


So I have this code in C# that performs a query in DT

query = digitalTwinsClientInstance.QueryAsync<BasicDigitalTwin>(
                @$"SELECT Child, Child.$metadata.$model
                FROM DIGITALTWINS
                    ...
                WHERE Area.$dtId = '{areaId}'

                  AND CONTAINS(Child.Name, '{textFilter}')"
            );

However, I would like for the search to be case insensitive. Is there any way to do that in the query itself, since Azure DT dos not support UPPER or LOWER functions?

This is the functionality that I would like

query = digitalTwinsClientInstance.QueryAsync<BasicDigitalTwin>(
                @$"SELECT Child, Child.$metadata.$model
                FROM DIGITALTWINS
                    ...
                WHERE Area.$dtId = '{areaId}'

                  AND CONTAINS(LOWER(Child.Name), '{textFilter.ToLower()}')" // !! Does Not Work
            );

Solution

  • Unfortunately, no. There is native support for case-insensitive queries in ADT.

    A possible workaround is to store a second property on your twin, with the same data but lowercase. Not ideal, but it works.