0
votes

I add an attribute (solrCoreSuffix) to my flowfile using UpdateAttribute processor with value "test". Then, in my PutSolrContentStream processor, i set Solr Location property to : "http://localhost:8983/solr/mycore-${solrCoreSuffix}". I expect the Solr processor to try to get to "http://localhost:8983/solr/mycore-test" but, as stated in the logs, it tries to access "http://localhost:8983/solr/mycore-".

This field has "support expression language : true", I can see my attribute with correct value when inspecting flowfile in the queue, I can use this attribute on other processor like PutFile for example, field "Collection" has same unexpected behavior.

I don't see what I'm doing wrong here, did I miss something ?

1

1 Answers

2
votes

The Solr Location field supports expression language, but not per-flow file.

What this means is that when the processor is started, it is creating a SolrClient (from SolrJ) and evaluating the value of Solr Location against environment variables, variable registry, etc, but there is no flow file at this point in time to use flow file attributes. This allows someone to easily externalize the Solr Location based on environments like dev/qa/prod.

The reason it was done this way is because it would be expensive to create a new connection to Solr for ever single flow file that comes in.

In cloud mode, the collection is not part of the Solr Location, and is dynamic because the CloudSolrClient allows you to specify the collection on each operation:

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/PutSolrContentStream.java#L178

https://github.com/apache/nifi/blob/master/nifi-nar-bundles/nifi-solr-bundle/nifi-solr-processors/src/main/java/org/apache/nifi/processors/solr/PutSolrContentStream.java#L203-L205