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 ...
随机推荐
- AQS源码分析看这一篇就够了
好了,我们来开始今天的内容,首先我们来看下AQS是什么,全称是 AbstractQueuedSynchronizer 翻译过来就是[抽象队列同步]对吧.通过名字我们也能看出这是个抽象类 而且里面定 ...
- python初始化定义空变量-小记
python初始化定义空变量 数值 digital_value = 0 字符串 str_value = "" 列表 list_value = [] 字典 ditc_value = ...
- 为什么网络损伤仪WANsim中没有流量通过
在使用网络损伤仪 WANsim 的过程中,有时候发现网损仪中没有流量通过.有些小伙伴可能会想:自己所有配置都是正确的 ,为什么会没有流量通过呢? 有可能,是你忽略了一些东西. 下面,我总结了一些导致网 ...
- NOIP 模拟 $12\; \text{简单的填数}$
题解 一个纯的贪心,被我搞成 \(dp\) 了,最后把错解删掉了,骗了 \(10pts\) 考虑如何贪心,设置一种二元组 \((x,l)\),\(x\) 表示当前值,\(l\) 表示当前最长连续长度. ...
- SpringCloud升级之路2020.0.x版-21.Spring Cloud LoadBalancer简介
本系列代码地址:https://github.com/HashZhang/spring-cloud-scaffold/tree/master/spring-cloud-iiford 我们使用 Spri ...
- 安装 iperf和服务器之间测速
安装 # https://downloads.es.net/pub/iperf/iperf-3.1.3.tar.gz wget https://iperf.fr/download/source/ipe ...
- ATM取款机优化需求的用例设计
案例设计需求 有一个ATM取款系统,现对于取款功能进行了如何需求变更:碑只能取面额是100元(如取500,输出5张100元),现在功能修改为,可以取面额是10元.50元和100元的,其余功能不变,用户 ...
- docker下gitlab(redis)安装配置使用(完整版)
ps:如果是云主机,需添加安全组开放相应端口(关联相应实例),防火墙开放端口或直接关闭 https://www.jianshu.com/p/080a962c35b6 将其中external_url换为 ...
- jwt《token》
payload与claims只能存在一个这部分是jwt源码:依赖如下:官方文档的依赖 <dependency> <groupId>io.jsonwebtoken</gro ...
- assign()与create()的区别
Q:assign()与create()的区别? A:let obj = Object.assign(targetObj, -sourceObj) 作用:将一个或多个源对象自身的可枚举属性与目标对象的属 ...