了解了一下python对es 7.5的操作,记录下,不难:

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
from settings import Config
mapping = {
'properties': {
'topic': {
'type': 'text',
'analyzer': 'ik_max_word',
'search_analyzer': 'ik_max_word'
},
'content': {
'type': 'text',
'analyzer': 'ik_max_word',
'search_analyzer': 'ik_max_word'
},
'like': {
'type': 'integer'
},
'read': {
'type': 'integer'
}
}
} data = {
'user':'xxx',
'topic':'44444',
'content':'xxxxxxxxxxxddddd',
'tm':'2019-1-20 22:00:00',
'like':'1',
'read':'2'
} #create index,create mapping
Config.es.indices.delete(index='question', ignore=[400, 404])
Config.es.indices.create(index='question', ignore=400)
result = Config.es.indices.put_mapping(index='question', body=mapping)
print(result) #insert data
result = Config.es.create(index='question', id=4, body=data) #update document
result = Config.es.index(index='question',body=data, id=4)
print(result)
#以下为查找操作
#search index all content
result = Config.es.search(index='question')
print(result) #query dsl,topic包含单词ddddd或lllll的所有内容
dsl = {
'query': {
'match': {
"topic": "ddddd lllll"
}
}
} result = Config.es.search(index='question', body=dsl)
print(result)

#kibana create index(mapping),post data
PUT kb_question
{
"mappings":{
"kb_question":{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
},
"topic": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
},
"like": {
"type": "integer"
},
"read": {
"type": "integer"
},
"user_id": {
"type": "integer"
},
"user": {
"type": "text"
},
"tm":{
"type":"date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
} }
}
} POST kb_question/kb_question/
{
"user": "xiqing",
"user_id": "704981",
"topic": "test test",
"content": "ccccccccccccccc la la lala la la la la la!!",
"read":"0",
"like":"0",
"tm":"2019-1-20 15:45:00"
} GET _cat/indices/kb_question
#DELETE /kb_question PUT kb_answer
{ "mappings":{
"kb_answer":{
"properties": {
"user": {
"type": "text"
},
"q_id": {
"type": "integer"
},
"answer": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
},
"like": {
"type": "integer"
},
"tm":{
"type":"date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
}
} GET _cat/indices/kb_answer POST kb_answer/kb_answer/
{
"user": "xiqing",
"q_id": "888",
"answer": "answer2 answer2 answer2 answer2 answer2!!",
"like":0,
"tm":"2019-1-21 18:45:00"
}

ES增删改查的更多相关文章

  1. ES增删改查入门1

    1.RESTful接口使用方法 为了方便直观我们使用Head插件提供的接口进行演示,实际上内部调用的RESTful接口. RESTful接口URL的格式: http://localhost:9200/ ...

  2. [elk]es增删改查最佳实战

    PUT app01 GET app01/_settings GET _all/_settings PUT app01/_settings { "number_of_replicas" ...

  3. 【ES】ElasticSearch初体验之使用Java进行最基本的增删改查~

    好久没写博文了, 最近项目中使用到了ElaticSearch相关的一些内容, 刚好自己也来做个总结. 现在自己也只能算得上入门, 总结下自己在工作中使用Java操作ES的一些小经验吧. 本文总共分为三 ...

  4. Es学习第三课, ElasticSearch基本的增删改查

    前面两课我们了解了ES的基本概念并且学会了安装ES,这节课我们就来讲讲ES基本的增删改查:ES主要对外界提供的是REST风格的API,我们通过客户端操作ES本质上就是API的调用.在第一课我们就讲了索 ...

  5. kibana的Dev Tool中如何对es进行增删改查

    kinaba Dev Tool中对es(elasticSearch)进行增删改查 一.查询操作 查询语句基本语法 以下语句类似于mysql的: select * from  xxx.yyy.topic ...

  6. Es图形化软件使用之ElasticSearch-head、Kibana,Elasticsearch之-倒排索引操作、映射管理、文档增删改查

    今日内容概要 ElasticSearch之-ElasticSearch-head ElasticSearch之-安装Kibana Elasticsearch之-倒排索引 Elasticsearch之- ...

  7. elasticsearch索引的增删改查入门

    为了方便直观我们使用Head插件提供的接口进行演示,实际上内部调用的RESTful接口. RESTful接口URL的格式: http://localhost:9200/<index>/&l ...

  8. 分布式搜索elasticsearch 索引文档的增删改查 入门

    1.RESTful接口使用方法 为了方便直观我们使用Head插件提供的接口进行演示,实际上内部调用的RESTful接口. RESTful接口URL的格式: http://localhost:9200/ ...

  9. ElasticSearch6(三)-- Java API实现简单的增删改查

    基于ElasticSearch6.2.4, Java API创建索引.查询.修改.删除,pom依赖和获取es连接 可查看此文章. package com.xsjt.learn; import java ...

随机推荐

  1. noip8

    T1 星际旅行 考试时觉得是道数学题,但没想到忘了欧拉路. 首先将每条边都拆成两条边,那么题目就变成了任意删掉两条边,使得新的图中存在欧拉路.设 \(sum\) 表示自环的数量, \(du_{i}\) ...

  2. Python实现发送邮件(实现单发/群发邮件验证码)

    Python smtplib 教程展示了如何使用 smtplib 模块在 Python 中发送电子邮件. 要发送电子邮件,我们使用 Python 开发服务器,Mailtrap 在线服务和共享的网络托管 ...

  3. exportfs命令 – 管理NFS服务器共享的文件系统

    exportfs命令需要参考配置文件"/etc/exportfs".也可以直接在命令行中指定要共享的NFS文件系统. 语法格式: export [参数] [目录] 常用参数: -a ...

  4. 安装RHEL7配置本地yum源 -- yum不能安装时,在本地安装,亲测成功

    RHEL7 本地yum源配置我们在安装Redhat的时候一般都不会填写注册信息,因为该产品是要购买的,所以我们在使用安装好的Redhat时有的功能是受限的,使用yum源install就是其中之一.那么 ...

  5. 异步编程之EAP

    一.概述 前面我们了解到了APM编程模式,但APM不支持对异步操作的取消和没有提供对进度报告的功能. 对于界面程序来说,进度报告和取消操作的支持也是必不可少的,为了支持这些功能,微软在.NET 2.0 ...

  6. nginx 实现反向代理、负载均衡、高可用

    转自:https://blog.csdn.net/zy1471162851/article/details/91795712 tip:   nginx是一款高性能的http 服务器/反向代理服务器及电 ...

  7. CentOS8安装Mysql5.7

    检查是否安装mysql [root@iZ2ze8crquorxf6c7l0eluZ ~]# rpm -qa |grep mysql [root@iZ2ze8crquorxf6c7l0eluZ ~]# ...

  8. mycat《对应关系》

  9. SpringBoot笔记(4)

    一.请求处理 1.1 常用参数注解使用 注解 使用 @PathVariable 获取URI模板指定请求,并赋值到变量中,不指定可以将所有请求放到map中,但是健值都为String @RequestHe ...

  10. <题解>「LibreOJ NOIP Round #1」序列划分

    solutions 题面loj#542 对我来说,这或许已经超出了我的能力,我,只能看题解 不知道我写完这一篇题解之后,会不会对我的构造题有一点点的帮助 让我在这类题的解决上能过有一些提升 直接说明白 ...