首页 > 解决方案 > ElasticSearch查询传递python动态变量

问题描述

res = es.search(index="resume", body={"query": {"match" : {"resume_file_text" : '"+key+"'}}})

如何传递变量'key'它保存用户在UI上给出的值并动态变化?

标签: python-3.xelasticsearch

解决方案


正文是哈希而不是字符串(因此无需连接任何内容)。所以你可以这样做:

res = es.search(index="resume", body={"query": {"match" : {"resume_file_text" : key}}})

推荐阅读