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语法在命令行方式下工 ...
随机推荐
- dubbo介绍及实战
1. dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.其核心部分包含: 远程通讯: 提供对多种基于长连接的NIO框架抽象封 ...
- React Native Windows下环境安装(一)
1.安装chocolatey 以管理员权限运行命令提示符(cmd.exe) @powershell -NoProfile -ExecutionPolicy Bypass -Command " ...
- STM32F103 rtthread工程构建
目录 STM32F103 工程构建 1.基本情况 2.硬件连接 3.rtthread配置 4.点灯 5. 码云上git操作 STM32F103 工程构建 1.基本情况 RAM 20K ROM 64K ...
- Hexo系列(二) 配置文件详解
Hexo 是一款优秀的博客框架,在使用 Hexo 搭建一个属于自己的博客网站后,我们还需要对其进行配置,使得 Hexo 更能满足自己的需求 这里所说的配置文件,是位于站点根目录下的 _config.y ...
- javascript Prototype constructor的理解(转)
讲JS的构造的,这个比较清晰,但并不表示一定正确. 这几天一直在思考这个东东,感觉比以前理解更深入了. http://blog.csdn.net/chunqiuwei/article/details/ ...
- 模型概念--MVC-MVVM
MVVM 第一个M是数据访问曾,第二个v是view视图页面,第三个vm是ViewModel视图模型
- redis安装配置-linux
wget http://download.redis.io/releases/redis-3.2.9.tar.gz .tar.gz cd redis-/ make --启动 ./redis-serve ...
- HDU 1240
#include <iostream> #include <cstdio> using namespace std; ; char maze[MAX][MAX][MAX]; s ...
- 输入url发生了什么--前端所有知识
面试经常会问到的一个问题,这个问题舒展开来,其实包含了前端(一些后端)几乎所有的知识.梳理一下,备忘.包含了一些面经中常问的问题. 有时间待续
- Java系列之JDBC和ODBC之间的差别与联系
JDBC简单介绍 JDBC(Java Data Base Connectivity,java数据库连接)是一种用于运行SQL语句的Java API,它是Java十三个规范之中的一个.能够为多种关系数据 ...