What is the difference between cts:count
, cts:frequency
, fn:count
in MarkLogic?
Could you please support me with example?
What is the difference between cts:count
, cts:frequency
, fn:count
in MarkLogic?
Could you please support me with example?
cts:count
is deprecated and it was designed to take a sequence of values returned by a lexicon function (for example, cts:element-values
); if you input non-lexicon values, the result will always be 0.
You should use cts:count-aggregate
instead.
The cts:count-aggregate
function works like cts:count
except it performs the counting in parallel in all data nodes then aggregates the values. It generally performs better than cts:count
, especially on large clusters
See: https://docs.marklogic.com/cts:count-aggregate
cts:frequency
Returns an integer representing the number of times in which a particular value occurs in a value lexicon lookup (for example, cts:element-values
). When using the fragment-frequency lexicon option, cts:frequency
returns the number of fragments in which the lexicon value occurs. When using the item-frequency lexicon option, cts:frequency
returns the total number of times in which the lexicon value occurs in each item.
See https://docs.marklogic.com/cts:frequency
fn:count
Returns the number of items in a sequence
See https://docs.marklogic.com/fn:count
See the different links for samples