Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

set morphline variable from if command

Solved Go to solution

set morphline variable from if command

Explorer

Is it possble to set the value of SOLR_LOCATOR from a morphline if command? I want to assign which collection the output data should flow to based on a contains match of a substring within the _attachment_body.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: set morphline variable from if command

Expert Contributor
All variables have to statically resolve at compile time. Still, you can statically enumerate multiple solrLocators and do stuff like this:

if
{
conditions : [
{ equals { tenant : [foo] } }
]
then : [
{
loadSolr { solrLocator : { collection : collection_foo, zkHost : "127.0.0.1:2181/solr" } }
}
]
else : [
{
loadSolr { solrLocator : { collection : collection_bar, zkHost : "127.0.0.1:2181/solr" } }
}
]
}

Wolfgang.

1 REPLY 1

Re: set morphline variable from if command

Expert Contributor
All variables have to statically resolve at compile time. Still, you can statically enumerate multiple solrLocators and do stuff like this:

if
{
conditions : [
{ equals { tenant : [foo] } }
]
then : [
{
loadSolr { solrLocator : { collection : collection_foo, zkHost : "127.0.0.1:2181/solr" } }
}
]
else : [
{
loadSolr { solrLocator : { collection : collection_bar, zkHost : "127.0.0.1:2181/solr" } }
}
]
}

Wolfgang.