X-pack chain input with condition

I have chained input like this:

  "input": {
        "chain" : {
    			"inputs" : [{
    					"input_http" : {
    						"http" : {
    							"request" : {
    								"url" : "http://localhost:8080/list"
    							}
    						}
    					}
    				}, {
    					"input_es" : {
    						"search": {
    						  "request": {
    							"indices": ["summary*"],
    							"body": {
    							  "size": 0,
    							  "query": {
    								"bool": {
    								  "must": [
    									{
    									  "query_string": {
    										"analyze_wildcard": true,
    										"query": "{{{{ CUSTOMIZATION HERE }}}"
    									  }
    									}
    								  ],
    								  "must_not": []
    								}
    							  },
    							  "_source": {
    								"excludes": []
    							  }
    							}
    						  }
    						}
    					}
    				   }
    			]
    		}
	}

I would like to customize my query in second input (input_es) based on payload returned by first input (input_http)
Example:

if ( ctx.payload.input_http._status_code = 200) {
   "query": "HTTP_STATUS:200"
}
else {
   "query": "!HTTP_STATUS:200"
}

How can I achieve this?
Thanks.

Hey,

you can do this using a chain transform which allows you to modify your payload properly and just write the query based on a condition in a script.

Hope this helps!

--Alex

Perfect. Looks like that's what I need. Will give a try.
Thank you !!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.