2、es索引创建及查询
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索引创建及查询相关推荐
- ES 索引创建及查询
ES 创建索引 PUT /xxxx_index {"settings": {"number_of_shards": 1, // 是数据分片数,默认为5,具体根据 ...
- ES索引创建、新增与修改字段
创建索引并配置: number_of_shards为数据分片,默认值为5 number_of_replicas为数据备份数,如果只有一台机器,建议设置为0,避免索引一直处于yellow状态 注:该设置 ...
- es为mysql创建索引_ES(ElasticSearch) 索引创建
环境:ES 6.2.2 os:Centos 7 kibana:6.2.2 介绍 索引是ElasticSearch存放数据的地方,可以理解为关系型数据库中的一个数据库.事实上,我们的数据被存储和索引在 ...
- Elasticsearch 入门(1):基本概念,安装教程,索引的创建,查询,删除,主键查询,修改,添加,聚合查询,条件查询
Elasticsearch 入门 基本概念 The Elastic Stack, 包括 Elasticsearch.Kibana.Beats 和 Logstash(也称为 ELK Stack).能够安 ...
- java 索引实现,Java创建ES索引实现
标签:public text cluster frame put elastics sea min user 1.pom.xml文件 org.springframewo ...
- logstash读取kafka所有topics 自动创建es 索引
logstash读取kafka的topics,根据内容提取指定字段然后自动创建es索引. input { kafka{ bootstrap_servers => "192 ...
- 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 ...
- 希冀平台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 ...
- es 索引操作(创建、查看、删除)
文章目录 es 索引操作(创建.查看.删除) 创建 判断索引是否存在 查看索引 批量查看索引 查看所有索引 删除索引库 es 索引操作(创建.查看.删除) 创建 PUT /test01_demo{ & ...
最新文章
- android 字幕,Android中的字幕文本
- gtest使用初级指南
- 【PDF下载】无意中发现的另一本 统计学入门好书
- ASP:FileSystemObject处理文件
- Webservice开发之xsd中开发登录请求的响应接口
- 简单地使用线程之一:使用异步编程模型
- python声明编码为gbk_Python字符串编码坑彻底详细解决
- 程序的图标无法改变_安卓微信7.0.7内测版发布,细节更新,小程序功能优化
- 【es】ElasticSearch master 选举
- 如何爬取了知乎用户信息,并做了简单的分析
- Windows 安装kafka-python库
- 投入产出表直接消耗系数和完全消耗系数Stata版本(1990-2017年)
- 项目管理工具——PDCA管理循环
- NISP二级复习题库
- 操作系统进程进行系统调用详细过程
- 腾讯云CVM云服务器1M宽带能干嘛?1M宽带支撑多少人在线?
- 读入一个整数,如果是1~5之间则分别输出5个福娃的名字否则输出“北京欢迎你
- 【vulnhub】Raven2
- 域名备案审核需要多长时间?企业网站需要准备哪些材料?
- 3Dmax 通过wrl生成地形