python 创建es mapping

时间:2021-11-11 06:09:02

import requests
def get_():
    url = "http://127.0.0.1:9200/indextest/_mapping?pretty"
    ss = requests.get(url)
    print(ss)
    print(ss.content)
    d = json.loads(ss.content)
    print(d)
    return d

def post():
    url = "http://127.0.0.1:9200/index/type/_mapping?pretty"
 
    res = requests.post(url, data=json.dumps(get_()["index"]["mappings"]), json=d)
    print(res)
    print(res.content)