You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/12/29 13:25:23 UTC

[GitHub] [nifi] ChrisSamo632 commented on a diff in pull request #6778: NIFI-10970: Added a count RecordPath function

ChrisSamo632 commented on code in PR #6778:
URL: https://github.com/apache/nifi/pull/6778#discussion_r1058951771


##########
nifi-docs/src/main/asciidoc/record-path-guide.adoc:
##########
@@ -1071,6 +1071,37 @@ take the value of the supplied record path and use it as the namespace.
 Please note that the namespace must always be a valid UUID string. An empty string, another data type, etc. will result
 in an error. This is by design because the most common use case for UUID v5 is to uniquely identify records across data sets.
 
+
+=== count
+
+Returns the count of the number of elements. This is commonly used in conjunction with arrays. For example, if we have the following record:
+
+----
+{
+    "id": "1234",
+    "elements": [{
+        "name": "book",
+        "color": "red"
+    }, {
+        "name": "computer",
+        "color": "black"
+    }]
+}
+----
+
+We could determine the number of `elements` by using the `count` function. Using:
+
+----
+count(/elements[*])
+----
+
+Would yield a value of `2`. We could also use this as a filter, such as:
+----
+/id[ count(/elements[*]) ]

Review Comment:
   ```suggestion
   /id[ count(/elements[*]) = 2]
   ```
   
   Presumably for this to be a [filter function](https://nifi.apache.org/docs/nifi-docs/html/record-path-guide.html#filters), there needs to be some sort of [predicate](https://nifi.apache.org/docs/nifi-docs/html/record-path-guide.html#predicates), worth reflecting that within the docs



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org