ES增删改查
了解了一下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增删改查的更多相关文章
- ES增删改查入门1
1.RESTful接口使用方法 为了方便直观我们使用Head插件提供的接口进行演示,实际上内部调用的RESTful接口. RESTful接口URL的格式: http://localhost:9200/ ...
- [elk]es增删改查最佳实战
PUT app01 GET app01/_settings GET _all/_settings PUT app01/_settings { "number_of_replicas" ...
- 【ES】ElasticSearch初体验之使用Java进行最基本的增删改查~
好久没写博文了, 最近项目中使用到了ElaticSearch相关的一些内容, 刚好自己也来做个总结. 现在自己也只能算得上入门, 总结下自己在工作中使用Java操作ES的一些小经验吧. 本文总共分为三 ...
- Es学习第三课, ElasticSearch基本的增删改查
前面两课我们了解了ES的基本概念并且学会了安装ES,这节课我们就来讲讲ES基本的增删改查:ES主要对外界提供的是REST风格的API,我们通过客户端操作ES本质上就是API的调用.在第一课我们就讲了索 ...
- kibana的Dev Tool中如何对es进行增删改查
kinaba Dev Tool中对es(elasticSearch)进行增删改查 一.查询操作 查询语句基本语法 以下语句类似于mysql的: select * from xxx.yyy.topic ...
- Es图形化软件使用之ElasticSearch-head、Kibana,Elasticsearch之-倒排索引操作、映射管理、文档增删改查
今日内容概要 ElasticSearch之-ElasticSearch-head ElasticSearch之-安装Kibana Elasticsearch之-倒排索引 Elasticsearch之- ...
- elasticsearch索引的增删改查入门
为了方便直观我们使用Head插件提供的接口进行演示,实际上内部调用的RESTful接口. RESTful接口URL的格式: http://localhost:9200/<index>/&l ...
- 分布式搜索elasticsearch 索引文档的增删改查 入门
1.RESTful接口使用方法 为了方便直观我们使用Head插件提供的接口进行演示,实际上内部调用的RESTful接口. RESTful接口URL的格式: http://localhost:9200/ ...
- ElasticSearch6(三)-- Java API实现简单的增删改查
基于ElasticSearch6.2.4, Java API创建索引.查询.修改.删除,pom依赖和获取es连接 可查看此文章. package com.xsjt.learn; import java ...
随机推荐
- noip13
T1 一开始直接丢了个暴力走人50pts,然后开始打表找规律,啥也没找着,最后二十分钟突然看出来了什么,把 \(f_{n,m}\)式子列了一下,发现常数项没啥规律,最后五分钟,突然闪过一丝灵感,但是是 ...
- jpa 指定字段内容按照顺序排序(orderBy when then)
query.orderBy( criteriaBuilder.desc( criteriaBuilder.selectCase() .when(criteriaBuilder.equal(root.g ...
- 堆排序——Java实现
一.堆排序 堆排序(Heap Sort)是指利用堆这种数据结构所设计的一种排序算法.堆是一个近似完全二叉树的结构,并同时满足堆积的性质:即子结点的键值或索引总是小于(或者大于)它的父节点. 二.堆 什 ...
- 十八:使用JDBC进行批处理
一.使用Statement完成批处理 1.使用Statement对象添加要批量执行SQL语句,如下: 1 Statement.addBatch(sql1); 2 Statement.addBatch( ...
- springmvc学习日志四
一.回顾 1.文件上传 1.1引入fileupload的jar包 1.2在springmvc的配置文件中引入CommonsMutilpartResolver文件上传解析器 1.3在控制层在写入代码 2 ...
- spring知识点(面试题)
转自(参考):https://baijiahao.baidu.com/s?id=1595722523154435312&wfr=spider&for=pc 本人收集了一些在大家在面试时 ...
- spring之自定义注解
java.lang.annotation提供了四种元注解,专门注解其他的注解: @Target –注解用于什么地方,默认值为任何元素,表示该注解用于什么地方.可用的ElementType指定参数 ,也 ...
- springboot全局异常封装案例
@ControllerAdvice三个场景:>https://www.cnblogs.com/lenve/p/10748453.html 全局异常处理 全局数据绑定 全局数据预处理 首先定义一个 ...
- Linux命令集锦之·字符截取命令
时间:2018-11-15 记录:byzqy 字符截取命令: cut.printf.awk.sed cut $ cut [选项] 文件名 选项: -f 列号:提取第几列: -d 分隔符:按照指定分隔符 ...
- hibernate01
什么是hibernate ORM框架/持久层框架 jdbc的一个框架 object reference mapping 通过管理对象来改变数据库中的数据 通过管理对象来操作数据库 hibernate的 ...