公司ES链接地址:http://10.202.77.206:5601/app/kibana#/dev_tools/console?_g=()
-- 创建一个index
put /customer_zhanglu?pretty
/*
成功会提示:{
"acknowledged": true,
"shards_acknowledged": true
}
*/
--查看所有索引
GET /_cat/indices?v
/*
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
green open icdstags_v1 EU7zRqqjSUWK3Sd8j7CfaA 5 1 21 0 250.5kb 125.2kb
green open bdp_css_waybill m51I5keSQw2L_UlpxzISwA 5 1 0 0 1.2kb 650b
green open customer_zhanglu Qa-T7S97SymryXFHqAV35A 5 1 0 0 1.2kb 650b
*/
-- 插入一条记录,记录id手动指定
PUT /customer_zhanglu/table1/1?pretty
{
"name": "John Doe"
}
/*
{
"_index": "customer_zhanglu",
"_type": "table1",
"_id": "1",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"created": true
}
*/
-- 插入一条记录,记录id自动生成
POST /customer_zhanglu/table1?pretty
{
"name": "table1_autoidtest",
"age": 20,
"servingStaffFlag": "no",
"provinctCityName": "深圳"
}
/*
{
"_index": "customer_zhanglu",
"_type": "table1",
"_id": "AWoGwpGBJUnalh9s_9hq",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 2,
"failed": 0
},
"created": true
}
*/
-- _source定制返回的结果,指定_source中,返回哪些field
GET customer_zhanglu/table1/1?pretty
/* 返回结果:
{
"_index": "customer_zhanglu",
"_type": "table1",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"name": "table1_1",
"age": 20,
"servingStaffFlag": "yes",
"provinctCityName": "深圳"
}
}
*/
GET customer_zhanglu/table1/1?_source=name,age -- 返回指定的字段
/*
{
"_index": "customer_zhanglu",
"_type": "table1",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"name": "table1_1",
"age": 20
}
}
*/
GET customer_zhanglu/table1/1?_source_include=name,age -- 未找到与_source的区别
GET customer_zhanglu/table1/1?_source_exclude=name,age -- 返回不包含指定字段的其余所有字段
/*
{
"_index": "customer_zhanglu",
"_type": "table1",
"_id": "1",
"_version": 1,
"found": true,
"_source": {
"servingStaffFlag": "yes",
"provinctCityName": "深圳"
}
}
*/
-- 查看结构
GET /customer_zhanglu
/*
{
"customer_zhanglu": {
"aliases": {},
"mappings": {
"table1": {
"dynamic_templates": [
{
"strings_not_analyzed": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}
],
"properties": {
"name": {
"type": "keyword"
}
}
},
"_default_": {
"dynamic_templates": [
{
"strings_not_analyzed": {
"match_mapping_type": "string",
"mapping": {
"type": "keyword"
}
}
}
]
}
},
"settings": {
"index": {
"creation_date": "1551175058672",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "Qa-T7S97SymryXFHqAV35A",
"version": {
"created": "5040199"
},
"provided_name": "customer_zhanglu"
}
}
}
}
*/
-- 查看index为icdstags,type为tags的所有数据
GET /icdstags/tags/_search?pretty
/*
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 23,
"max_score": 1,
"hits": [
{
"_index": "icdstags_v1",
"_type": "tags",
"_id": "DEEQAVTg%2B%2BKxH5hiTZSLQqPeeQck8%3D",
"_score": 1,
"_source": {
"phone": "DEEQAVTg%2B%2BKxH5hiTZSLQqPeeQck8%3D",
"validFlag": "1",
"baseMonthTag": "BM1-,BM1-SE0003-0-10,BM3-偏收有寄,BM4-1-4,BM5-1-4,BM6-1-4,BM7-5-10,BM8-5-10,BM9-11-20,BM10-0",
"marketTag": "MK2-否,MK3-否,MK4-否,MK5-否,MK6-否,MK7-否,MK8-否,MK9-否,MK10-否,MK11-否,MK12-否,MK13-否,MK14-否,MK15-否,MK16-非用券用户",
"uniqueid": "DEEQAVTg%2B%2BKxH5hiTZSLQqPeeQck8%3D",
"baseDayTag": "BD1-是,BD2-有,BD5-否,BD6-201411,BD7-金牌会员,BD8-595Y,BD9-QuanZhou,BD10-595CC,BD11-595Y,BD12-QuanZhou,BD13-595CC,BD14-否,BD15-否,BD17-是,BD18-100,BD19-4,BD20-工业区"
}
},
{
"_index": "icdstags_v1",
"_type": "tags",
"_id": "DEEQAVTg%2B%2FYt8x%2FkcySVCcYyt3wBQ%3D",
"_score": 1,
"_source": {
"phone": "DEEQAVTg%2B%2FYt8x%2FkcySVCcYyt3wBQ%3D",
"validFlag": "1",
"baseMonthTag": "BM1-,BM1-SE0003-0-10,BM3-偏收有寄,BM4-1-4,BM5-1-4,BM6-1-4,BM7-5-10,BM8-5-10,BM9-11-20,BM10-0",
"marketTag": "MK2-否,MK3-否,MK4-否,MK5-否,MK6-否,MK7-否,MK8-否,MK9-否,MK10-否,MK11-否,MK12-否,MK13-否,MK14-否,MK15-否,MK16-非用券用户",
"uniqueid": "DEEQAVTg%2B%2FYt8x%2FkcySVCcYyt3wBQ%3D",
"baseDayTag": "BD1-是,BD2-有,BD5-否,BD6-201411,BD7-金牌会员,BD8-595Y,BD9-QuanZhou,BD10-595CC,BD11-595Y,BD12-QuanZhou,BD13-595CC,BD14-否,BD15-否,BD17-否,BD18-50,BD19-1,BD20-商业区"
}
}
]
}
}
*/
--查看index为icdstags,type为tags下的记录总数
GET /icdstags/tags/_count?pretty
/*
{
"count": 23,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
}
}
*/
-- 查看index下的所有数据,按照name升序排列,排列字段必须,index下如果有多个type,sort的字段必须是每个type中都存在的
GET /customer_zhanglu/_search?q=*&sort=name:asc&pretty
GET /customer_zhanglu/_search
{
"query": { "match_all": {} },
"sort": [
{"name": "asc"}
]
}
/*
{
"took": 1, -- 搜索花费的时间,但是是毫秒
"timed_out": false, -- 是否超时
"_shards": { -- 分片
"total": 5, -- 搜索的分片个数
"successful": 5, -- 搜索成功的分片个数
"failed": 0 -- 搜索失败的分片个数
},
"hits": { -- 搜索的结果
"total": 3, -- 符合条件的记录个数,es中的记录叫document
"max_score": null,
"hits": [ -- 搜索到的数据,默认显示前10条
{
"_index": "customer_zhanglu",
"_type": "table1",
"_id": "1",
"_score": null,
"_source": {
"name": "hello1"
},
"sort": [ -- 排序的字段值,如果使用score排序,则不显示sort
"hello1"
]
},
{
"_index": "customer_zhanglu",
"_type": "table2",
"_id": "2",
"_score": null,
"_source": {
"doc": {
"name": "Jane",
"age": 22
}
},
"sort": [
null
]
},
{
"_index": "customer_zhanglu",
"_type": "table2",
"_id": "1",
"_score": null,
"_source": {
"doc": {
"name": "Jane Doe",
"age": 20
}
},
"sort": [
null
]
}
]
}
}
*/
-- 增加字段
POST customer_zhanglu/table1/_mapping
{
"properties": {
"servingStaffFlag":{"type": "keyword"},
"provinctCityName":{"type": "keyword"}
}
}
-- 上述命令转换为curl
curl -XPOST "http://10.202.116.33:9200/customer_zhanglu/table1/_mapping" -H 'Content-Type: application/json' -d'
{
"properties": {
"servingStaffFlag":{"type": "keyword"},
"provinctCityName":{"type": "keyword"}
}
}'
-- 按照某字段的特定值查询
GET /customer_zhanglu/table1/_search?pretty
{
"query":{
"term" : {"age":20}
}
}
/*
curl -XGET "http://10.202.116.33:9200/customer_zhanglu/table1/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query":{
"term" : {"age":20}
}
}'
*/
GET /customer_zhanglu/table1/_search?pretty
{
"query":{
"term" : {"servingStaffFlag":"yes"}
}
}
分享到:
相关推荐
这篇入门学习笔记将引导初学者了解如何安装、配置以及使用Elasticsearch。 首先,让我们从安装开始。要安装Elasticsearch,你可以访问官方网站(https://www.elastic.co/cn/downloads/elasticsearch)下载最新版本...
**Elasticsearch 入门与实战** Elasticsearch 是一个基于 Lucene 的开源全文搜索引擎,以其分布式、可扩展性、实时搜索以及强大的数据分析能力而受到广泛欢迎。它不仅支持文本搜索,还可以处理结构化和非结构化数据...
(狂神)ElasticSearch快速入门笔记,ElasticSearch基本操作以及爬虫(Java-ES仿京东实战),包含了小狂神讲的东西,特别适合新手学习,笔记保存下来可以多看看。好记性不如烂笔头哦~,ElasticSearch,简称es,es是一个...
elasticsearch安装和配置kibana安装和配置
通过深入学习和实践,你可以从 Elasticsearch 入门逐步掌握高级技巧,利用其强大的搜索和分析能力解决实际问题。记住,理解和掌握 Elasticsearch 的核心概念、API 以及与其他工具的整合是关键。
本教程将深入浅出地介绍Elasticsearch的基础知识,帮助初学者快速上手。 1. **Elasticsearch 概述** - Elasticsearch 是一个基于 Lucene 的分布式、RESTful 风格的搜索和数据分析引擎。 - 它的核心特性包括实时性...
Elasticsearch入门基础学习 带你走近一个生产环境的Elasticsearch 用详尽的概念、底层的原理、生动的案例、解开Elasticsearch神秘面纱
### ElasticSearch 全部学习资料 #### 一、ElasticSearch 安装及配置 **1.1 ElasticSearch 的安装** - **官网**: 访问官方网址 [www.elastic.co/](https://www.elastic.co/) 下载所需版本的 ElasticSearch。 - *...
通过深入学习和实践 Elasticsearch 5.5.0,可以充分利用其强大的搜索和分析能力,为业务提供高效、灵活的数据解决方案。结合视频课程,你可以更好地理解和掌握这些概念和技术,逐步成为 Elasticsearch 的专家。
elasticsearch的框架,同样是以lucene为基础,并且吸收了前两代的教训而开发出的分布式多用户能力的全文搜索引擎,并且elasticsearch是基于RESTful web接口进行发布的,那么这就意味着,我们开发人员操作起来更方便...
Search入门详解:开启你的搜索之旅 ElasticSearch(ES)是一个强大的、基于...从零基础开始学习ES,可以让你在运维领域具备竞争优势,理解并掌握其核心原理和实践应用,将极大地提升你的工作效率和解决问题的能力。
"ElasticSearch实战教程" ElasticSearch是一款分布式、RESTful 风格的搜索和数据分析引擎,能够达到近实时搜索,稳定,可靠,快速...本教程旨在帮助您快速入门ElasticSearch,掌握ElasticSearch的基本概念和实战应用。
### ElasticSearch中文学习教程知识点梳理 #### 一、总述 **1.1. 简介** ElasticSearch是一款基于Lucene构建的开源、分布式、RESTful搜索引擎。它专为云计算环境设计,具备实时搜索能力,且稳定、可靠、快速、...
### Elasticsearch入门教程知识点详解 #### 一、Elasticsearch安装与基本操作 1. **解压目录结构**: - 在解压后的Elasticsearch目录中,通常包含多个子...这些基础知识对于进一步学习和掌握Elasticsearch至关重要。
本文将深入探讨Elasticsearch的基础知识、核心概念以及应用场景。 ### 1. Elasticsearch概述 Elasticsearch是基于Lucene构建的,由 Shay Banon 在2009年创建。它提供了一个分布式、多租户的全文搜索引擎,具有实时...
这个"**ElasticSearch入门和基础(高清视频教程)**"显然旨在为初学者提供一个全面了解和学习Elasticsearch的平台。在视频教程中,你可能会学到以下几个关键知识点: 1. **Elasticsearch的基本概念**:包括其分布式...
ElasticSearch实战 in Action(原著原版)压缩包,ElasticSearch文档,ES全文检索从入门到精通,高清PDF,是学习es和精通es必备手册,能快速达到精通ElasticSearch,一册在手,ElasticSearch无忧,开发、学习、调优...
帮助elasticsearch开发者入门
在Elasticsearch的世界里,理解基础概念和掌握基本操作是入门的关键。本篇文章将深入探讨这些知识点,并结合提供的`es.http`和`es_book.http`文件进行阐述。 首先,我们要了解Elasticsearch的核心概念: 1. **节点...