How to filter queries by attribute value

This page is a quick overview of how it is possible filter a data query by indicator value.

Create an indicator parameter

The chosen semantic type must match the semantic type of the indicator that will be filtered using this parameter.

Add filter on dimension

Edit the dimension and filter it using the chosen attribute and the previously created parameter

Queries in routes with high throughput are usually not advised. However, performances increase dramatically in the following conditions :

  • if there is only one filter on the dimension that is on the value of the entity key of the dimension
  • if the entity key is only made of 1 attribute
  • if this query is entirely configured at reference time

Such a query will take less than 3 ms to execute.

Add order on dimension

Edit the dimension and order it using the chosen attribute and the direction. Multiple ordering attributes can be defined. These attributes can be re-ordered by using the drag handle   at the left of each attribute

Set runtime value in route

Add the runtime parameter value in the parameter map in the route.

Runtime value can be a simple value like the one used in "How to use entity parameters" or a list of values depending on the chosen function. The function CONTAINED IN, for instance, accepts a list of values (see  <u:list-create> on how to create a list in a route).

(info) If runtime inputs do not match what is expected by the function, the query will not be filtered using this parameter.

Runtime values can be set using the <simple> or the <constant> tags. Each runtime value will be converted to the type expected by the parameter function. If conversion is not possible, the query will fail. It is recommended to use the dedicated Camel utility expression for special types like duration, instant and interval. 


Route sample
<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
    <route>
        <from uri="timer:foo?repeatCount=1"/>
        <!-- Parameter map for query-->
        <setProperty propertyName="tnd-query.parameters">
            <u:map-create>
                <u:map-entry key="tnd-query.referenceTime">
                    <constant>NOW</constant>
                </u:map-entry>
                <u:map-entry key="intersectsInterval"> <!-- alias of the parameter created in the data query -->
                    <u:interval-create end="NOW"> <!-- chosen function "INTERSECTS" neeeds an interval as input. We build it using the dedicated Camel Utility Expression -->
                        <u:begin>
                            <simple>2013-11-13T10:00:00</simple>
                        </u:begin>
                    </u:interval-create>
                </u:map-entry>
            </u:map-create>
        </setProperty>
        <to uri="tnd-query:GetPaymentFilteredByCreationTime"/>
        <log message="${body}"/>
    </route>
</routes>

Related Links