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 ...
随机推荐
- 题解 Game
传送门 一有「字典序最大」什么的的就懵了--这题我颓的std 首先可以发现全局最大得分很好统计,我们令它为 \(k\) 然后我们尝试构造方案,但发现无论怎么放都可能会有后效性 发现对于一个位置,可以放 ...
- [ES6深度解析]12:Classes
我们将讨论一个老问题:在JavaScript中创建对象的构造函数. 存在的问题 假设我们想要创建最典型的面向对象设计的示例:Circle类.假设我们正在为一个简单的Canvas库编写一个Circle. ...
- C# 计时器用法(DispatcherTimer、System.Timers.Timer、System.Threading.Timer)
首先,我觉得三种计时器最大的区别是:DispatcherTimer触发的内容会直接转到主线程去执行(耗时操作会卡住主线程),另外两个则是在副线程执行,如果需要修改界面,则需要手动转到主线程. Disp ...
- 输入npm install 报错node-sass@4.13.0 postinstall:`node scripts/build.js` Failed at the node-sass@4.13.0
这个是因为sass安装时获取源的问题,先修改sass安装的源,再运行npm install就成功了 npm config set sass_binary_site=https://npm.taobao ...
- Flink 保证ExactlyOnce
Flink 保证 ExactlyOnce 1.使用执行ExactlyOnce 的数据源,比如 kafka 2.使用FlinkConsumer,开启CheckPointing,偏移量会保存通过Check ...
- 论如何在服务器上部署一个自己的web前端项目
就在前两天,有新人通过邮箱问到笔者,如何部署自己的web前端项目?笔者在此详细介绍. 一.购买云服务器 配置用户名密码.安全组 二.下载Xshell于Xftp工具 用于登录服务器和文件上传 三.在li ...
- rtsp->rtmp 推流直播 Plan B
上篇文章我们谈到使用 EasyDarwin 推流后 前端HTML播放器 播放无画面的情况,找了各种播放器都服务正常解决,但使用VLC却能正常播放的问题,我们尝试了很久最后另辟蹊径,找到 nginx安装 ...
- 【Python机器学习实战】决策树与集成学习(六)——集成学习(4)XGBoost原理篇
XGBoost是陈天奇等人开发的一个开源项目,前文提到XGBoost是GBDT的一种提升和变异形式,其本质上还是一个GBDT,但力争将GBDT的性能发挥到极致,因此这里的X指代的"Extre ...
- GoLang设计模式05 - 原型模式
原型模式也是一种创建型模式,它可以帮助我们优雅地创建对象的拷贝.在这种设计模式里面,将克隆某个对象的职责交给了要被克隆的这个对象.被克隆的对象需要提供一个clone()方法.通过这个方法可以返回该对象 ...
- input 只可以输入时分秒
在html5的time中,只有时.分,没有秒. 例如<input type="time" name="user_date" /> 属性加上 step ...