Using variables inside of API

OK - am losing my hair over this -

I have a query that I am pulling data from the sample data index - I want to put the value of that query into the Put_role api via python script - I am getting errors as I am sure that I am doing something wrong - Can someone please look at the code below and give me some pointers -

Thanks -
Code:

q = Q('term', Carrier='*')

s = Search(index='kibana_sample_data_flights').using(es).query(q)
s = s.source(includes = ['Carrier']) ##(variable field)

for hit in s.scan():
put_role(Sample_"{{hit.Carrier}}"_Analysts, body={"cluster":["all"],"indices":[{"names":["kibana_sample_data_flight"], "privileges" : ["all"], "query" : "{"match":{"Carrier":"{{hit.Carrier}}"" }}],}}

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