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.

update a get request to elastic search in nifi

Solved Go to solution
Highlighted

update a get request to elastic search in nifi

Rising Star

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

Accepted Solutions
Highlighted

Re: update a get request to elastic search in nifi

Super 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
Highlighted

Re: update a get request to elastic search in nifi

Rising Star
@Matt Burgess

Can you add something on it

Highlighted

Re: update a get request to elastic search in nifi

Super 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

Re: update a get request to elastic search in nifi

Rising Star

Thanks @Shu

Don't have an account?
Coming from Hortonworks? Activate your account here