Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/2601#discussion_r178641076
  
    --- Diff: 
nifi-nar-bundles/nifi-elasticsearch-bundle/nifi-elasticsearch-processors/src/main/java/org/apache/nifi/processors/elasticsearch/QueryElasticsearchHttp.java
 ---
    @@ -219,6 +256,39 @@ public void setup(ProcessContext context) {
             super.setup(context);
         }
     
    +    @Override
    +    public void onPropertyModified(final PropertyDescriptor descriptor, 
final String oldValue, final String newValue) {
    +        if (ROUTING_QUERY_INFO_STRATEGY.equals(descriptor)) {
    +            if (ALWAYS.getValue().equalsIgnoreCase(newValue)) {
    +                final Set<Relationship> routeQueryInfoRels = new 
HashSet<>();
    +                routeQueryInfoRels.add(REL_SUCCESS);
    +                routeQueryInfoRels.add(REL_FAILURE);
    +                routeQueryInfoRels.add(REL_RETRY);
    +                routeQueryInfoRels.add(REL_QUERY_INFO);
    +                this.relationships = routeQueryInfoRels;
    +
    +                this.queryInfoRouteStrategy = 
QueryInfoRouteStrategy.ALWAYS;
    +            }else if (NO_HITS.getValue().equalsIgnoreCase(newValue)) {
    +                final Set<Relationship> routeQueryInfoRels = new 
HashSet<>();
    +                routeQueryInfoRels.add(REL_SUCCESS);
    +                routeQueryInfoRels.add(REL_FAILURE);
    +                routeQueryInfoRels.add(REL_RETRY);
    +                routeQueryInfoRels.add(REL_QUERY_INFO);
    +                this.relationships = routeQueryInfoRels;
    +
    +                this.queryInfoRouteStrategy = QueryInfoRouteStrategy.NOHIT;
    +            }
    +            }else {
    --- End diff --
    
    I believe that will work. Also MockProcessContext calls onPropertyModified 
on set/removeProperty(), so you might be able to parlay that into a unit test 
to check that the relationship is available or not (but I'm not sure)


---

Reply via email to