es添加和删除索引

微信扫一扫,分享到朋友圈

es添加和删除索引
收藏 00

1.配置mappings

mappings ={
    "mappings":{
        "properties":{
            "title":{
                "type":"text",
                "analyzer":"ik_smart"
            },
            "content":{
                "type":"text",
                "analyzer":"ik_smart"
            }
        }
    }
}

2.创建索引

ret = es.indices.create("test-demo",request_timeout=20,ignore=[400],body=mappings)
print(ret)

删除索引

res = es.indices.delete(index="test-demo")
print(res)

查看mappings

rets = es.indices.get_mapping(index="test-demo")

3.添加文档 ,如果文档已存在就会更新文档

doc = {
    "title":'cs',
    "contene":'cccccc'
}
rep = es.index(index="test-demo",body=doc)
print(rep)

 

一个热爱互联网的咸鱼
下一篇

帝国cms自带文章生成标题图片插件AutoTitlePic

你也可能喜欢

发表评论

您的电子邮件地址不会被公开。 必填项已用 * 标注

提示:点击验证后方可评论!

插入图片

热门

    抱歉,30天内未发布文章!
返回顶部