1、启动es:
[root@baozi elasticsearch-1.4.4]# bin/service/elasticsearch start
Starting Elasticsearch...
Waiting for Elasticsearch......
running: PID:2409
[root@baozi elasticsearch-1.4.4]#

2、向es里面创建一个索引库:
[root@baozi elasticsearch-1.4.4]# curl -XPUT 'http://localhost:9200/hello'
{"acknowledged":true}[root@baozi elasticsearch-1.4.4]#

网页访问:http://192.168.1.200:9200/hello?pretty
显示内容:
{
  "hello" : {
    "aliases" : { },
    "mappings" : { },
    "settings" : {
      "index" : {
        "creation_date" : "1435386285465",
        "uuid" : "fbrLYbcmRfuRBYKlkcBvdw",
        "number_of_replicas" : "1",
        "number_of_shards" : "5",
        "version" : {
          "created" : "1040499"
        }
      }
    },
    "warmers" : { }
  }
}

3、向索引库hello里插入信息:
[root@baozi elasticsearch-1.4.4]# curl -XPUT 'http://localhost:9200/hello/emp/1' -d '{"name":"zs","age":"23"}'
{"_index":"hello","_type":"emp","_id":"1","_version":1,"created":true}[root@baozi elasticsearch-1.4.4]#

网址:http://192.168.1.200:9200/hello?pretty
显示信息:
{
  "hello" : {
    "aliases" : { },
    "mappings" : {
      "emp" : {
        "properties" : {
          "age" : {
            "type" : "string"
          },
          "name" : {
            "type" : "string"
          }
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1435386285465",
        "uuid" : "fbrLYbcmRfuRBYKlkcBvdw",
        "number_of_replicas" : "1",
        "number_of_shards" : "5",
        "version" : {
          "created" : "1040499"
        }
      }
    },
    "warmers" : { }
  }
}

网址:http://192.168.1.200:9200/hello/emp/1?pretty

显示内容:
{
  "_index" : "hello",
  "_type" : "emp",
  "_id" : "1",
  "_version" : 1,
  "found" : true,
  "_source":{"name":"zs","age":"23"}
}

es创建索引或者索引库的时候必须都用小写,不能以下划线开头,也不能包含逗号。

PUT是幂等操作,必须加ID操作;用于更新
POST不是幂等,ID加不加都可以;用于新增

加ID了,PUT和POST都一样,不加ID不能用PUT。

=========================================================================================
GET操作:
[root@baozi elasticsearch-1.4.4]# curl -XGET http://192.168.1.200:9200/hello/emp/1?pretty
{
  "_index" : "hello",
  "_type" : "emp",
  "_id" : "1",
  "_version" : 1,
  "found" : true,
  "_source":{"name":"zs","age":"23"}
}
[root@baozi elasticsearch-1.4.4]#

反馈头文件:
[root@baozi elasticsearch-1.4.4]# curl -i http://192.168.1.200:9200/hello/emp/1?pretty
HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 133

{
  "_index" : "hello",
  "_type" : "emp",
  "_id" : "1",
  "_version" : 1,
  "found" : true,
  "_source":{"name":"zs","age":"23"}
}
[root@baozi elasticsearch-1.4.4]#

检索指定字段:
[root@baozi elasticsearch-1.4.4]# curl -XGET 'http://192.168.1.200:9200/hello/emp/1?_source=name,age&pretty'
{
  "_index" : "hello",
  "_type" : "emp",
  "_id" : "1",
  "_version" : 1,
  "found" : true,
  "_source":{"age":"23","name":"zs"}
}
[root@baozi elasticsearch-1.4.4]# curl -XGET 'http://192.168.1.200:9200/hello/emp/1?_source=name&pretty'
{
  "_index" : "hello",
  "_type" : "emp",
  "_id" : "1",
  "_version" : 1,
  "found" : true,
  "_source":{"name":"zs"}
}
[root@baozi elasticsearch-1.4.4]#

只显示source:
[root@baozi elasticsearch-1.4.4]# curl -XGET 'http://192.168.1.200:9200/hello/emp/1/_source'
{"name":"zs","age":"23"}[root@baozi elasticsearch-1.4.4]#

关闭es:
[root@baozi elasticsearch-1.4.4]# bin/service/elasticsearch stop
Stopping Elasticsearch...
Stopped Elasticsearch.

[root@baozi elasticsearch-1.4.4]#

2、es索引创建及查询相关推荐

  1. ES 索引创建及查询

    ES 创建索引 PUT /xxxx_index {"settings": {"number_of_shards": 1, // 是数据分片数,默认为5,具体根据 ...

  2. ES索引创建、新增与修改字段

    创建索引并配置: number_of_shards为数据分片,默认值为5 number_of_replicas为数据备份数,如果只有一台机器,建议设置为0,避免索引一直处于yellow状态 注:该设置 ...

  3. es为mysql创建索引_ES(ElasticSearch) 索引创建

    环境:ES 6.2.2 os:Centos  7 kibana:6.2.2 介绍 索引是ElasticSearch存放数据的地方,可以理解为关系型数据库中的一个数据库.事实上,我们的数据被存储和索引在 ...

  4. Elasticsearch 入门(1):基本概念,安装教程,索引的创建,查询,删除,主键查询,修改,添加,聚合查询,条件查询

    Elasticsearch 入门 基本概念 The Elastic Stack, 包括 Elasticsearch.Kibana.Beats 和 Logstash(也称为 ELK Stack).能够安 ...

  5. java 索引实现,Java创建ES索引实现

    标签:public   text   cluster   frame   put   elastics   sea   min   user 1.pom.xml文件 org.springframewo ...

  6. logstash读取kafka所有topics 自动创建es 索引

    logstash读取kafka的topics,根据内容提取指定字段然后自动创建es索引. input {   kafka{      bootstrap_servers => "192 ...

  7. SQL39 针对salaries表emp_no字段创建索引idx_emp_no,查询emp_no为10005,使用强制索引。

    描述 针对salaries表emp_no字段创建索引idx_emp_no,查询emp_no为10005,使用强制索引. CREATE TABLE salaries ( emp_no int(11) N ...

  8. 希冀平台1-5:针对salaries表emp_no字段创建索引idx_emp_no,查询emp_no为10005, 使用强制索引。 CREATE TABLE `salaries` ( `emp_no`

    希冀平台1-5:针对salaries表emp_no字段创建索引idx_emp_no,查询emp_no为10005, 使用强制索引. CREATE TABLE salaries ( emp_no SEL ...

  9. es 索引操作(创建、查看、删除)

    文章目录 es 索引操作(创建.查看.删除) 创建 判断索引是否存在 查看索引 批量查看索引 查看所有索引 删除索引库 es 索引操作(创建.查看.删除) 创建 PUT /test01_demo{ & ...

最新文章

  1. android 字幕,Android中的字幕文本
  2. gtest使用初级指南
  3. 【PDF下载】无意中发现的另一本 统计学入门好书
  4. ASP:FileSystemObject处理文件
  5. Webservice开发之xsd中开发登录请求的响应接口
  6. 简单地使用线程之一:使用异步编程模型
  7. python声明编码为gbk_Python字符串编码坑彻底详细解决
  8. 程序的图标无法改变_安卓微信7.0.7内测版发布,细节更新,小程序功能优化
  9. 【es】ElasticSearch master 选举
  10. 如何爬取了知乎用户信息,并做了简单的分析
  11. Windows 安装kafka-python库
  12. 投入产出表直接消耗系数和完全消耗系数Stata版本(1990-2017年)
  13. 项目管理工具——PDCA管理循环
  14. NISP二级复习题库
  15. 操作系统进程进行系统调用详细过程
  16. 腾讯云CVM云服务器1M宽带能干嘛?1M宽带支撑多少人在线?
  17. 读入一个整数,如果是1~5之间则分别输出5个福娃的名字否则输出“北京欢迎你
  18. 【vulnhub】Raven2
  19. 域名备案审核需要多长时间?企业网站需要准备哪些材料?
  20. 3Dmax 通过wrl生成地形

热门文章

  1. 威纶通触摸屏技巧总结
  2. 使用PCLPY进行点云图像融合
  3. virtualbox设置文件夹共享(win7主机)
  4. 软件工程师职业道德规范_看一下三个职业道德规范的最新更新
  5. 在线研讨会 matlab,MatLab
  6. C for Graphic:各向异性(anisotropy)
  7. 评估数据,包括长度,角度,卷曲度
  8. 1024程序员节|代码改变世界,科技创造未来~ 机械工业出版社送福利,好书相赠~
  9. android MPChart图标使用详解
  10. 美国自由女神像是法国赠送的【科普】