了解了一下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. SSM自学笔记(六)

    11.MyBatis的Dao层实现方式 1.MyBatis的Dao层实现 1.1 传统开发方式 编写UserDao接口 public interface UserDao { List<User& ...

  2. Git分支创建命令

    一. 创建test分支提交步骤 1.列出所有分支 # git branch -a 2.创建test分支          # git branch test 3.切换到test分支:         ...

  3. 入门数据结构与算法,看这一个就够了,知识点+LeetCode实战演练

    本笔记来自拉钩教育300分钟搞定算法面试 算法与数据结构 要掌握一种数据结构,就必须要懂得分析它的优点和缺点. 在考虑是否应当采用一种数据结构去辅助你的算法时,请务必考虑它的优缺点,看看它的缺点是否会 ...

  4. 【ArcGIS】 设置管段的流向

    在排水管网或者燃气管网中对管段进行几何网络分析,常常用到设置管段流向,一般有三种方法: 1,有流向字段的,直接进行唯一值渲染, 2,没有流向字段的需要建立几何网络, 2.1 在几何网络存在的情况下,设 ...

  5. MFC 绘制坐标系

    主要讨论映射模式:MM_ANISOTROPIC,MM_ISOTROPIC.及相关方法的应用. 1,先建立一个MFC单文档,过程不再赘述. 2,在View类中找到CMainFrame::PreCreat ...

  6. [题解] Luogu P5446 [THUPC2018]绿绿和串串

    [题解] Luogu P5446 [THUPC2018]绿绿和串串 ·题目大意 定义一个翻转操作\(f(S_n)\),表示对于一个字符串\(S_n\), 有\(f(S)= \{S_1,S_2,..., ...

  7. 【CSS简介、基础选择器、字体属性、文本属性、引入方式】前端小抄(2) - Pink老师自学笔记

    [CSS简介.基础选择器.字体属性.文本属性.引入方式]前端小抄(2) 本学习笔记是个人对 Pink 老师课程的总结归纳,转载请注明出处! 一.CSS简介 CSS 的主要使用场景就是布局网页,美化页面 ...

  8. MySQL 源码安装规范

    一 .目录规划 MySQL 的目录包括 base 目录和 data 目录,base 目录存放软件文件,每个版本的软件单 独一个目录,例如/usr/local/mysql/mysql5.6.19.dat ...

  9. linux centos7 df命令

    2021-08-04 1. df 命令简介 linux 中 df 命令的功能是用来检查 linux 服务器的文件系统的磁盘空间占用情况.可以利用该命令来获取硬盘被占用了多少空间,目前还剩下多少空间等信 ...

  10. Spring Boot 入门系列(二十四)多环境配置,3分钟搞定!

    之前讲过Spring Boot 的系统配置和自定义配置,实现了按照实际项目的要求配置系统的相关熟悉.但是,在实际项目开发过程中,需要面对不同的环境,例如:开发环境,测试环境,生产环境.各个环境的数据库 ...