Watcher's transform adds smaller number of the values

Hi,

I'd like to make watcher which will write to a certain index unique values of the particular field.

A part of my query is

{
  "query" :  {
    "bool":  {
      "must": [
         { "wildcard": { "field": { "value": "foo-bar-*" }}}
       ]
    }
  }
}

Then I have the following transform in action section

List unique = new ArrayList();
for (hit in ctx['payload']['hits']['hits']) {
  if (!unique.contains(hit['_source']['field'])) {
    unique.add(hit['_source']['field']);
  }
}
return ['unique':unique];

and then

"index": {
  "index": "unique-values",
  "doc_id": "0001"
}

This configuration will write to the index some unique values but less than 10.
Aggregation cardinality shows 58 (looks like true).

The question is why it adds to the list smaller number of the values? How can I fix it?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.