Elasticsearch之curl创建索引库和索引时注意事项
前提,
Elasticsearch之curl创建索引库
Elasticsearch之curl创建索引
注意事项
1、索引库名称必须要全部小写,不能以下划线开头,也不能包含逗号
2、如果没有明确指定索引数据的ID,那么es会自动生成一个随机的ID,需要使用POST参数
curl -XPOST http://192.168.80.200:9200/zhouls/emp/ -d '{"name" : "tom"}'
3、如果想要确定我们创建的都是全新的数据
1:使用随机ID(post方式)
2:在url后面添加参数
curl -XPUT http://192.168.80.200:9200/zhouls/emp/2/_create -d '{"name":"tom","age":25}'
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200:9200/zhouls/emp/1' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"1","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200:9200/zhouls/emp/1' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"1","_version":2,"_shards":{"total":2,"successful":1,"failed":0},"created":false}[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPOST 'http://192.168.80.200:9200/zhouls/emp/1' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"1","_version":3,"_shards":{"total":2,"successful":1,"failed":0},"created":false}[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200:9200/zhouls/emp' -d'{"name":"tom","age":25}'
No handler found for uri [/zhouls/emp] and method [PUT][hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPOST 'http://192.168.80.200:9200/zhouls/emp' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"AVpdAus-cJQ8qYq5I_Er","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPOST 'http://192.168.80.200:9200/zhouls/emp' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"AVpdBaixcJQ8qYq5I_Es","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
得出,
不指定id,就必须得用-XPOST
3、
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200:9200/zhouls/emp/1' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"1","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200:9200/zhouls/emp/1' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"1","_version":2,"_shards":{"total":2,"successful":1,"failed":0},"created":false}[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPOST 'http://192.168.80.200:9200/zhouls/emp/1' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"1","_version":3,"_shards":{"total":2,"successful":1,"failed":0},"created":false}[hadoop@djt002 elasticsearch-2.4.3]$ ^C
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200:9200/zhouls/emp' -d'{"name":"tom","age":25}'
No handler found for uri [/zhouls/emp] and method [PUT][hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPOST 'http://192.168.80.200:9200/zhouls/emp' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"AVpdAus-cJQ8qYq5I_Er","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPOST 'http://192.168.80.200:9200/zhouls/emp' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"AVpdBaixcJQ8qYq5I_Es","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200:9200/zhouls/emp/2/._create -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"2_create","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200:9200/zhouls/emp/2_create ' -d'{"name":"tom","age":25}'
{"_index":"zhouls","_type":"emp","_id":"2_create","_version":2,"_shards":{"total":2,"successful":1,"failed":0},"created":false}[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
[hadoop@djt002 elasticsearch-2.4.3]$
这样做的好处,是,只要这条命令成功,那么就一定是新增的。
Elasticsearch之curl创建索引库和索引时注意事项的更多相关文章
- Elasticsearch之curl创建索引库
关于curl的介绍,请移步 Elasticsearch学习概念之curl 启动es,请移步 Elasticsearch的前后台运行与停止(tar包方式) Elasticsearch的前后台运行与停止( ...
- Elasticsearch之curl创建索引
前提,是 Elasticsearch之curl创建索引库 [hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200: ...
- Elasticsearch之curl删除索引库
关于curl创建索引库的介绍,请移步 Elasticsearch之curl创建索引库 [hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://1 ...
- JAVAEE——Lucene基础:什么是全文检索、Lucene实现全文检索的流程、配置开发环境、索引库创建与管理
1. 学习计划 第一天:Lucene的基础知识 1.案例分析:什么是全文检索,如何实现全文检索 2.Lucene实现全文检索的流程 a) 创建索引 b) 查询索引 3.配置开发环境 4.创建索引库 5 ...
- 应用activeMQ消息中间件同步索引库
mq是一个消息服务器: 安装包内置了tomcat,直接登录访问,登录:http://ip:8161/admin/ (相当于dubbo的moniter监控中心) admin admin传统串行化, ...
- lucene索引库的增删改查操作
1. 索引库的操作 保持数据库与索引库的同步 说明:在一个系统中,如果索引功能存在,那么数据库和索引库应该是同时存在的.这个时候需要保证索引库的数据和数据库中的数据保持一致性.可以在对数据库进行增.删 ...
- 第一个lucene程序,把一个信息写入到索引库中、根据关键词把对象从索引库中提取出来、lucene读写过程分析
新建一个Java Project :LuceneTest 准备lucene的jar包,要加入的jar包至少有: 1)lucene-core-3.1.0.jar (核心包) 2) lucene- ...
- JAVAEE——Solr:安装及配置、后台管理索引库、 使用SolrJ管理索引库、仿京东的电商搜索案例实现
1 学习回顾 1. Lucene 是Apache开源的全文检索的工具包 创建索引 查询索引 2. 遇到问题? 文件名 及文件内容 顺序扫描法 全文检索 3. 什么是全文检索? 这种先创建索引 再 ...
- ElasticSearch之CURL操作(有空再去整理)
https://www.cnblogs.com/jing1617/p/8060421.html ElasticSearch之CURL操作 CURL的操作 curl是利用URL语法在命令行方式下工 ...
随机推荐
- 时序分析:串匹配—Brute-Force算法
在使用KMP算法之前,使用了BF算法用于串匹配:原文链接已无法查找..... 设有主串s和子串t,子串t的定位就是要在主串s中找到一个与子串t相等的子串.通常把主串s称为目标串,把子串t ...
- 安卓桌布显示的dip和px
安卓程序设计界面显示设置图像大小,在layout.xml里面有dip和px选项,dip为 什么 暂时还不知道,或许是设计桌布的设定像素比率,px为像素值: 比如我的手机是 Lenovo K920,屏幕 ...
- 06--谈谈:C++类的“包含”机制
谈谈:C++类的“包含”机制 本人在学习Qt的时候发现了一个非常有趣的现象.有很多函数的调用方法都写成了如下的形式: object.func().func2(); 这令小弟着实不懂.在上面这段代码 ...
- Mysql 设置起始值
alter table t_tszj_pet_activity AUTO_INCREMENT=10000; 设置 id 从10000 开始
- 如何查看Linux的CPU负载
哪些工具可以查看 CPU 负载? 可以使用 top 命令.uptime 命令,特别是 top 命令,功能强大,不仅仅可以用来查看 CPU 负载. CPU 负载怎么理解?是不是 CPU 利用率? 要区别 ...
- 爬取某网站景区列表并保存为csv文件
网址:http://www.halehuo.com/jingqu.html 经过查看可以发现,该景区页面没有分页,不停的往下拉,页面会进行刷新显示后面的景区信息 通过使用浏览器调试器,发现该网站使用的 ...
- Linux—Ubuntu14.0.5安装Redis
1.前言 Redis是常用基于内存的Key-Value数据库,比Memcache更先进,支持多种数据结构,高效,快速.用Redis可以很轻松解决高并发的数据访问问题:做为时时监控信号处理也非常不错. ...
- js对对象的校验技巧,随时更新
js中,字符串长度用length. 若不确定一个Map里,是否存在某个对象,则用underfind 去校验
- jQuery Webcam Plugin jscam.swf文件反编译工具使用说明
jQuery webcam plugin是一个在ie,firefox,chrome下都可以用的摄像头摄像及拍照用的插件. (http://www.xarg.org/project/jquery-web ...
- MySQL用Load Data local infile 导入部分数据后中文乱码
今天在两台MySQL服务器之间导数据,因为另一个MySQL服务器是测试用的,差一个月的数据,从现有MySQL服务器select到一个文件,具体语句是: select * from news where ...