elasticsearch增删查改
创建结构化索引
put http://127.0.0.1:9200/person
{
"settings" : {
"number_of_shards": 3,
"number_of_replicas": 0
},
"mappings": {
"man": {
"properties": {
"name": {
"type": "text"
},
"country": {
"type": "keyword"
},
"age": {
"type": "integer"
},
"date": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
},
"woman": { }
}
}
删除索引
delete http://127.0.0.1:9200/person
插入(指定id)
put http://127.0.0.1:9200/person/man/1
{
"name": "张三",
"country": "China",
"age": 30,
"date": "2019-03-16"
}
插入(自动生成id)
post http://127.0.0.1:9200/person/man/
{
"name": "李四",
"country": "China",
"age": 24,
"date": "2019-03-15"
}
修改
post http://127.0.0.1:9200/person/man/1/_update
{
"doc": {
"name": "王五",
"age": "25"
}
}
修改(使用脚本)
post http://127.0.0.1:9200/person/man/1/_update
//第一种方式
{
"script": {
"lang": "painless",
"inline": "ctx._source.age += 10"
}
}
//第二种方式
{
"script": {
"lang": "painless",
"inline": "ctx._source.age = params.age",
"params": {
"age": 100
}
}
}
删除
delete http://127.0.0.1:9200/person/man/1
查询
//查询单条记录
get http://127.0.0.1:9200/person/man/1 //查询所有数据
post http://127.0.0.1:9200/person/_search
{
"query": {
"match_all": {}
}
} //指定从第几条开始查,查询多少条数
post http://127.0.0.1:9200/person/_search
{
"query": {
"match_all": {}
},
"from":1,
"size":1
} //条件查询
post http://127.0.0.1:9200/person/_search
{
"query": {
"match": {
"age": 24
}
}
}
//排序
post http://127.0.0.1:9200/person/_search
{
"query": {
"match": {
"age": 24
}
},
"sort": [
{"age": {"order": "desc"}}
]
}
elasticsearch增删查改的更多相关文章
- spark对elasticsearch增删查改
增 新建一个 dataframe ,插入到索引 _index/_type ,直接调用 saveToEs ,让 _id 为自己设定的 id: import org.elasticsearch.spark ...
- Elasticsearch使用系列-ES增删查改基本操作+ik分词
Elasticsearch使用系列-ES简介和环境搭建 Elasticsearch使用系列-ES增删查改基本操作+ik分词 一.安装可视化工具Kibana ES是一个NoSql数据库应用.和其他数据库 ...
- 6.在MVC中使用泛型仓储模式和依赖注入实现增删查改
原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-operations-using-the-generic-repository-pat ...
- 3.EF 6.0 Code-First实现增删查改
原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-operations-using-entity-framework-5-0-code- ...
- 4.在MVC中使用仓储模式进行增删查改
原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-using-the-repository-pattern-in-mvc/ 系列目录: ...
- 5.在MVC中使用泛型仓储模式和工作单元来进行增删查改
原文链接:http://www.c-sharpcorner.com/UploadFile/3d39b4/crud-operations-using-the-generic-repository-pat ...
- jdbc的实例应用:增删查改实现
//在jdbc中进行增删查改 //查看所有 public static void findAll() { String url = "jdbc:mysql://localhost:3306/ ...
- 用javascript实现html元素的增删查改[xyytit]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- hibernate基础增删查改简单实例
hibernate 基础理论知识网上很多,可以百度和google.这里不做多的介绍,以一个User表来开展例子 建一个web-project 我这里用了junit单元测试环境来进行增删查改的测试,别的 ...
随机推荐
- Devexpress gridview cell增加控件
1.根据上图次序,先添加三类控件类型: 2.根据上图次序设置columnEdit 3.点开ColumnEdit , 设置 check 和 uncheck的 value
- Angular2+AngularJS
AngularJS 系列: 1.angular.module 的定义 var mapApp = angular.module("positionSalaryEditApp",[&q ...
- 学习Python3 天眼查 爬虫
刚开始学习Python,不愿意看基础,记忆不好,那些语法记不住,直接上个项目,这样比较深刻 刚好公司有个情况要查企业的信息,就想做个爬虫吧,有验证码的不愿意搞,那是个老大难问题,就选择了天眼查 过程都 ...
- bash: ./LM35_make_fs: Permission denied 解决办法
执行命令的时候 ./LM35_make_fs 遇到 permission denied, bash: ./LM35_make_fs: Permission denied权限的问题,可以运行 ls -l ...
- Win32-Application的窗口和对话框
Win32 Application,没有基于MFC的类库,而是直接调用C++接口来编程. 一.弹出消息窗口 (1)最简单的,在当前窗口中弹出新窗口.新窗口只有“YES”按钮. int APIENTRY ...
- Vue基础开发笔记
以下实例代码地址:https://github.com/NewBLife/VueDev 1,Vue组件导入 新建组件:Header.vue <template> <div> & ...
- 一个HTTP打趴80%面试者
面试多年,每当我问起面试者对HTTP的了解时,个个回答令我瞠目结舌,这些开发者都有3-5年的经验.请不要让我叫你野生程序员,是时候了解HTTP了,让我们当个正规军. 起因 面试官:请问你了解HTTP协 ...
- TCP/IP各层对应的协议
应用层: 该层包括所有和应用程序协同工作,利用基础网络交换应用程序专用的数据协议.如: HTTP:超文本传输协议. TELNET:(网络电传),通过一个终端(terminal)登录到网络(运行在TCP ...
- GitLab配置后收取不到邮件问题
一.root权限下,修改gitlab的配置文件:/etc/gitlab/gitlab.rb gitlab_rails['smtp_enable'] = true gitlab_rails['smtp_ ...
- 51nod 1162 质因子分解
https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1162 数据范围大约是2^97,需要高精度计算 可以使用pollard- ...