Reputation: 11
I am trying to the dict's value for key "_string"
to be formatted like "tags:6586"
tagid=[6586,6573,6570]
for tid in tagid:
t_id="tags:{}".format(tid)
query={"query": {"_and": [{"_string":"t_id"}]}}
print (query)
returns
{'query': {'_and': [{'_string': 't_id'}]}}
{'query': {'_and': [{'_string': 't_id'}]}}
{'query': {'_and': [{'_string': 't_id'}]}}
Upvotes: 0
Views: 32
Reputation: 2342
In query={"query": {"_and": [{"_string":"t_id"}]}}
replace "t_id"
by str(t_id)
:
query={"query": {"_and": [{"_string": t_id}]}}
You want to put there the string representation of your variable t_id
, not the string "t_id"
.
Upvotes: 1