Support Questions

Find answers, ask questions, and share your expertise

update a get request to elastic search in nifi

avatar
Expert Contributor

I'm trying to hit a get request on my elastic search index using JSONelastisearchprocessor in NIFI. Now, for each flow file i have some incoming attributes, based on that i need to generate different get request and store the response somewhere.

The list of processors i'm using is as below:

  1. Getfile (to read JSON file)
  2. Evaluate JSON path (To extract the attributes which i want to use with every get request, PROC_INST_ID_ in this case )
  3. JSON queryelastic search (to hit the request with the below )
  4. PUTfile to store the response

Request body

{
  "query": {
    "nested": {
      "path": "los",
      "query": {
        "bool": {
          "must": [
            { "match": { "los.${proc_ins_id}":"784525" }},
            { "match": { "los._source.cibilPermission.VALUE_":"1" }}
          ]
        }
      }
    }
  }
}

I can't see the request being genrated and not getting any response instead i'm only getting the value of proc_ins_id as reponse in putfile. Can someone suggest some appropriate way to do this?

Attaching relevant screenshots as well for reference.

86418-evaluate-json-path.png

86417-flow.png

1 ACCEPTED SOLUTION

avatar
Master Guru
@Vaibhav Kumar

Please change EvaluateJsonPath processor configs Destination to flowfile-attribute

85572-evaljson.png

Now the processor will add the attribute to the flowfile then in JsonQueryElasticSearch processor will gets the attribute value and runs the query on ElasticSearch.

With Destination as flowfile-content will overwrites the existing flowfile content with PROC_INST_ID_ value.

JsonQueryElasticSearch Relationships:

85574-relationships.png

Only feed the required relationships to PutFile processor i.e. hits (or) aggregations

Flow:

85575-flow.png

View solution in original post

3 REPLIES 3

avatar
Expert Contributor
@Matt Burgess

Can you add something on it

avatar
Master Guru
@Vaibhav Kumar

Please change EvaluateJsonPath processor configs Destination to flowfile-attribute

85572-evaljson.png

Now the processor will add the attribute to the flowfile then in JsonQueryElasticSearch processor will gets the attribute value and runs the query on ElasticSearch.

With Destination as flowfile-content will overwrites the existing flowfile content with PROC_INST_ID_ value.

JsonQueryElasticSearch Relationships:

85574-relationships.png

Only feed the required relationships to PutFile processor i.e. hits (or) aggregations

Flow:

85575-flow.png

avatar
Expert Contributor

Thanks @Shu