前提,

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. Qt无法用UTF-8编辑问题

    原因: Windows默认编码格式是GBK. 而QT-各默认版本的编码格式是UTF-8. 解决方法": Windows环境下,Qt Creator,菜单->工具->选项-> ...

  2. mssql for VSCode Guide

    前言 mssql 出自微软自己的 Visual Studio Code 开源插件,代码托管于 GitHub 上. 不过需要注意的一点是,使用 insert into 语句新增的数据...中文是会乱码的 ...

  3. 数据库Day3之SQL Server 触发器

    最近在做一个人事管理系统写了几个简单的触发器 1.在删除员工信息表中员工信息时结果区提示被删除员工信息 create trigger teston 员工信息表after deleteasselect ...

  4. Xshell连接linux服务器不成功的乌龙问题

    一般xshell连接linux服务器不成功有以下几个问题: linux防火墙拦截,导致Xshell不能访问linux 操作方法: firewalld(CentOS7):启动 :systemctl st ...

  5. vue 强制刷新组件

    <component v-if="hackReset"></component> 2 3 4 this.hackReset = false this.$ne ...

  6. C#第三节课(1)

    数据类型 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System. ...

  7. phpqrcode生成二维码

    这篇文章讲解得非常详细: https://www.jb51.net/article/136418.htm 备注一下: 如果遇到生成的二维码是一串乱码.只需要在代码最后加上 exit();即可解决,原理 ...

  8. Monkey日志中如何找错误

     无响应问题可以在日志中搜索 “ANR” ,崩溃问题搜索 “CRASH” ,内存泄露问题搜索"GC"(需进一步分析),异常问题搜索 “Exception”   monkey执行时未 ...

  9. 【密码学】RSA加密 kotlin实现方法(支持任意字节长度)

    这个编辑器不支持kotlin,尴尬了···· 算了,就用Java来弄吧 val 定义常量 var 定义变量 具体kotlin的开发手册详见:http://www.runoob.com/kotlin/k ...

  10. 一键安装LNMP(适合centos7)

    1.准备工作,下载源码包 wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar ...