前提,

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创建索引库和索引时注意事项的更多相关文章

  1. Elasticsearch之curl创建索引库

    关于curl的介绍,请移步 Elasticsearch学习概念之curl 启动es,请移步 Elasticsearch的前后台运行与停止(tar包方式) Elasticsearch的前后台运行与停止( ...

  2. Elasticsearch之curl创建索引

    前提,是 Elasticsearch之curl创建索引库 [hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://192.168.80.200: ...

  3. Elasticsearch之curl删除索引库

    关于curl创建索引库的介绍,请移步 Elasticsearch之curl创建索引库 [hadoop@djt002 elasticsearch-2.4.3]$ curl -XPUT 'http://1 ...

  4. JAVAEE——Lucene基础:什么是全文检索、Lucene实现全文检索的流程、配置开发环境、索引库创建与管理

    1. 学习计划 第一天:Lucene的基础知识 1.案例分析:什么是全文检索,如何实现全文检索 2.Lucene实现全文检索的流程 a) 创建索引 b) 查询索引 3.配置开发环境 4.创建索引库 5 ...

  5. 应用activeMQ消息中间件同步索引库

    mq是一个消息服务器: 安装包内置了tomcat,直接登录访问,登录:http://ip:8161/admin/    (相当于dubbo的moniter监控中心) admin admin传统串行化, ...

  6. lucene索引库的增删改查操作

    1. 索引库的操作 保持数据库与索引库的同步 说明:在一个系统中,如果索引功能存在,那么数据库和索引库应该是同时存在的.这个时候需要保证索引库的数据和数据库中的数据保持一致性.可以在对数据库进行增.删 ...

  7. 第一个lucene程序,把一个信息写入到索引库中、根据关键词把对象从索引库中提取出来、lucene读写过程分析

    新建一个Java Project :LuceneTest 准备lucene的jar包,要加入的jar包至少有: 1)lucene-core-3.1.0.jar     (核心包) 2) lucene- ...

  8. JAVAEE——Solr:安装及配置、后台管理索引库、 使用SolrJ管理索引库、仿京东的电商搜索案例实现

    1 学习回顾 1. Lucene  是Apache开源的全文检索的工具包 创建索引 查询索引 2. 遇到问题? 文件名 及文件内容  顺序扫描法  全文检索 3. 什么是全文检索? 这种先创建索引 再 ...

  9. ElasticSearch之CURL操作(有空再去整理)

    https://www.cnblogs.com/jing1617/p/8060421.html ElasticSearch之CURL操作 CURL的操作    curl是利用URL语法在命令行方式下工 ...

随机推荐

  1. AI:IPPR的数学表示-CNN基本结构分析( Conv层、Pooling层、FCN层/softmax层)

    类似于SVM,CNN为代表的DNN方法的边缘参数随着多类和高精度的要求必然增长.比如向量机方法,使用可以映射到无穷维的高斯核,即使进行两类分类,在大数据集上得到高精度,即保持准确率和高精度的双指标,支 ...

  2. (1)dotnet开源电商系统-brnshop&brnMall 和老外开发的nopCommerce(dotnet两套电商来PK--第一篇)

    一直想做电商软件,但是实在不想学PHP了,所以前后关注了这两个开源电商系统.一个是国人出品的,一个据说是俄罗斯人写得(不知道对不对).目前两个开源软件都在学习了解中,以下的博文可能会涉及到这两套系统, ...

  3. C# 写入二进制文件

    写入整型25 文件在MiniHex中显示 写入字符串I am happy 0A 6D - 6D - 这一行数据是C#把字符串转换为16进制形式 不知道为啥用MiniHex打开多了个0A 写入空&quo ...

  4. django分页功能,templatetags的应用

    django 将不会将得到的html代码自动转化 from django.utils.html import format_html html =''' <a href='http://www. ...

  5. DOM学习之充实文档内容

    HTML代码 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <me ...

  6. [Cerc2007]robotic sort

    splay区间反转练手题 #include <iostream> #include <cstdio> #include <algorithm> using name ...

  7. layui 导出excel复杂表头

    众所周知 layui的导出功能很好用,但是今天我要给大家推荐一个更好用的 大家来到这里想必也是因为layui无法满足 [导出Excle复杂表头] 的业务需求而来,这里废话不多说但还是强调一点,如果你是 ...

  8. Codeforces 1106F Lunar New Year and a Recursive Sequence (数学、线性代数、线性递推、数论、BSGS、扩展欧几里得算法)

    哎呀大水题..我写了一个多小时..好没救啊.. 数论板子X合一? 注意: 本文中变量名称区分大小写. 题意: 给一个\(n\)阶递推序列\(f_k=\prod^{n}_{i=1} f_{k-i}b_i ...

  9. springMVC @ModelAttribute功能

    @ModelAttribute功能:将数据模型回写到页面 如: public String validate(@Valid @ModelAttribute("user") User ...

  10. 服务器监控(包括性能指标与web应用程序)

    http://blog.csdn.net/yao123long/article/details/53142029 http://blog.csdn.net/heyongluoyao8/article/ ...