Incorrect index for aggregation function in Clusterpoint Cloud

24 views Asked by At

What should be the correct index for aggregation function, if the tag values I am using are numerical in 'ID' tag and string values in 's_version tag'? 'ID' has index-numbers=yes 's_version tag' has index=xml

My aggregation query looks like:

$aggregateQuery = 'COUNT(ID) as user_count, s_version as a GROUP BY s_version ORDER BY s_version';

$response returns an error:

Cannot aggregate unindexed fields
Cannot aggregate fields that have not been indexed. Check your policy and make sure all fields you are aggregating are indexed with appropriate types
1

There are 1 answers

0
Marija On

Tags you use in aggregation should be appropriate indexed with index-numbers=yes, index-dates=yes or index=facet (index=xml affects only path how to define certain tag). Use “index-numbers” for numeric tags, “index-dates” for date values, and “index-facet” for string.

It seems, that your “ID” tag is correctly indexed. But for “s_version” you should add “index=facet”:

<rule>
<xpath>//root_tag/.../s_version</xpath>
<property>index=xml&amp;facet</property>
</rule>