[ 
https://issues.apache.org/jira/browse/NIFI-5060?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16452949#comment-16452949
 ] 

ASF subversion and git services commented on NIFI-5060:
-------------------------------------------------------

Commit fdea876ede6b503c703e9a816e9a29137be868f9 in nifi's branch 
refs/heads/master from [~greenCee]
[ https://git-wip-us.apache.org/repos/asf?p=nifi.git;h=fdea876 ]

NIFI-5060 Updated SubstringAfter record processing to support multi-character 
search trimming

This closes #2623.

Signed-off-by: Mark Payne <marka...@hotmail.com>


> UpdateRecord substringAfter and substringAfterLast only increments by 1
> -----------------------------------------------------------------------
>
>                 Key: NIFI-5060
>                 URL: https://issues.apache.org/jira/browse/NIFI-5060
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>    Affects Versions: 1.5.0, 1.6.0
>            Reporter: Chris Green
>            Priority: Major
>              Labels: easyfix, newbie
>         Attachments: Validate_substringafter_Behavior.xml
>
>
> This is my first submitted issue, so please feel free to point me in the 
> correct direction if I make process mistakes.
> Replication:
> Drag a GenerateFlowFile onto the canvas and configure this property, and set 
> run schedule to some high value like 600 seconds
> "Custom Text" \{"value": "01230123"}
> Connect GenerateFlowFile with an UpdateAttribute set to add the attribute 
> "avro.schema" with a value of 
>  
> {code:java}
> { 
> "type": "record", 
> "name": "test", 
> "fields" : [{"name": "value", "type": "string"}]
> }
> {code}
>  
>  
> Connect UpdateAttribute to an UpdateRecord onto the canvas, Autoterminate 
> success and failure. Set the Record Reader to a new JSONTreeReader. On the 
> JsonTreeReader configure it to use the "Use 'Schema Text' Attribute".
> Create a JsonRecordSetWriter and set the Schema Text to:
>  
>  
> {code:java}
> { 
>     "type": "record", 
>     "name": "test", 
>     "fields" : [
>         {"name": "value", "type": "string"},
>         {"name": "example1", "type": "string"},
>         {"name": "example2", "type": "string"},
>         {"name": "example3", "type": "string"},
>         {"name": "example4", "type": "string"}
>         ]
>  }
> {code}
>  
> Add the following properties to UpdateRecord
>  
> ||Heading 1||Heading 2||
> |/example1|substringAfter(/value, "1") |
> |/example2|substringAfter(/value, "123") |
> |/example3|substringAfterLast(/value, "1")|
> |/example4|substringAfterLast(/value, "123")|
>  
> Resulting record currently:
>  
> {code:java}
> [{ 
> "value" : "01230123", 
> "example1" : "230123", 
> "example2" : "30123", 
> "example3" : "23", 
> "example4" : "3" 
> }]
> {code}
>  
>  
>  
> Problem:
> When using the UpdateRecord processor, and the substringAfter() function 
> after the search phrase is found it will only increment the substring 
> returned by 1 rather than the length of the search term. 
> Based off XPath and other implementations of substringAfter functions I've 
> seen the value returned should remove the search term rather than just the 
> first character of the search term.
>  
>  
> Resulting record should be:
>  
> {code:java}
> [{ 
> "value" : "01230123", 
> "example1" : "230123", 
> "example2" : "0123", 
> "example3" : "23", 
> "example4" : "" 
> }]
> {code}
>  
>  
> I'm cleaning up a fix with test code that will change the increment from 1 to 
> the length of the search terms. 
> It appears substringBefore are not impacted by the behavior as always returns 
> the index before the found search term which is the expected behavior



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to