I've successfully tested Variable Registries in the *Replacement Value*
field, but I still can't get it to work in the *Search Value* field
with *Replacement
Strategy* as Literal Replace and *Evaluation* as Entire Text.

Here is something really weird. I created a GenerateFlowFile and used
my ${tier1.linux} variable in the *Custom Text* field. Creates the flow
file as expected, with the expected text. But then in my ReplaceText's *Search
Value* field I use my ${tier1.linux} variable with *Replacement* being
anything, and it *does not* successfully search and replace the text.
Thoughts?

*GenerateFlowFile Values*
File Size: 0B
Batch Size: 1
Data Format: Text (granted, I'm using JSON in my official version, but it
should still work)
Unique FlowFiles: false
Custom Text: ${tier1.linux}
Character Set: UTF-8
Mime Type: No value set

*ReplaceText Values*
Search Value: ${tier1.linux}
Replacement Value: hello world
Character Set: UTF-8
Max Buff Size: 1MB (way more than I need)
Replacement Strat: Literal Replace
Evaluation Mode: Entire Text
Line-b-Line: All

On Tue, Nov 24, 2020 at 10:27 AM Thane Durey <[email protected]> wrote:

> Sorry, forgot to mention I'm using NiFi 1.12.1
>
> On Tue, Nov 24, 2020 at 10:03 AM Thane Durey <[email protected]> wrote:
>
>> Hey Mark,
>>
>> Not sure why the website (
>> https://lists.apache.org/[email protected]) won't let me
>> port over this conversation to my mail client. So I copy/pasted the
>> conversation so I can add attachments for you.
>>
>> In the attachment, you'll see the exact tag string I'm searching for in
>> my JSON contents, and what my ReplaceText looks like.
>>
>> For your convenience, my registry variable property files has this for
>> the variable:
>> tier1.linux=syslog, tier1
>>
>>
>>
>>
>> ORIGINAL CONVERSATION
>> On 2020/11/24 14:48:45, Mark Payne <[email protected]> wrote:
>> > Hello, Thane.
>> >
>> > Yes, that should work fine. I did setup a simple flow to verify the
>> behavior and it worked as I expected.
>> >
>> > Perhaps you can provide a template of your flow? That may help to
>> diagnose what’s going on.
>> >
>> > Also, what version of NiFi are you running?
>> >
>> > Thanks
>> > -Mark
>> >
>> >
>> > > On Nov 24, 2020, at 8:15 AM, Thane Durey <[email protected]> wrote:
>> > >
>> > > Does the variable registry allow for white space without
>> single/double quotes?
>> > >
>> > > I've spend the majority of yesterday and this morning still trying to
>> figure out why this ReplaceText won't work with the variable registry.
>> > >
>> > > Sadly, I can't find any online examples of how people have:
>> > > 1. Used the variable registry in a ReplaceText -> Search Value field
>> > > 2. How/If you can use white space within a variable, and what the
>> syntax would be (if its ok to not include single/double quotes, or if you
>> include a white space then you are required to add quotes of some kind).
>> > >
>> > >
>> > > To provide some more context, my variable is being used as a tag
>> system so I can tag my data with certain data types. So I have my variable
>> registry file looking like this
>> > > var1=somestring
>> > > var2=anotherstring
>> > > my.tag=linux, systemname
>> > > my.tag2=windows, systemname
>> > > my.tag3=linux, systemname1
>> > > my.tag4=windows, systename1
>> > >
>> > > After doing some minor processing on my data, I create a JSON using
>> AttributesToJSON. Unfortunately, this doesn't set any fields to an Array.
>> So I'm doing some "dirty" formatting and making the changes myself. My JSON
>> looks something like this:
>> > > {"somekey":"somevalue", "tags":"windows, systemname"}
>> > >
>> > > This is where my ReplaceText comes into play. Before, I would do a
>> literal string in my Search Value (in the ReplaceText) which would look
>> like this: "windows, systemname"
>> > >
>> > > This did exactly what I expected, but I wanted to try to get the
>> variable registry to work as this will be easier for me to maintain. So I
>> updated the Search Value field to look like this: "${my.tag2}"
>> > >
>> > > Shouldn't this work? Or am I missing something? Any help would be
>> appreciated.
>> > >
>> > > On 2020/11/23 18:41:41, Thane Durey <[email protected]> wrote:
>> > >> How would I be able to use the a variable in the Search Value field
>> for a ReplaceText processor?
>> > >>
>> > >> My String
>> > >> Some string has this "here, here" in it
>> > >>
>> > >> What I want to Search
>> > >> "here, here"
>> > >>
>> > >> My Variable (must not include the double quotes for other reasons)
>> > >> my.variable=here, here
>> > >>
>> > >> I have a string I'm wanting to parse out of a large string. I
>> thought the following would work:
>> > >> Search Value: "${my.variable}"
>> > >> Replacement Value: ["here", "here"]
>> > >>
>> > >> I thought the above Search value would replace ${my.variable} with
>> the string I've saved. So how could I used the variable registry in this
>> Search Value?
>> > >>
>> > >> Thanks
>> > >>
>> >
>> >
>>
>

Reply via email to