Elasticsearch.The.Definitive.Guide学习笔记 -- 1. You know, for search
2016-10-19 16:11
573 查看
http://localhost:9200/?pretty http://localhost:5601/app/marvel http://localhost:9200/_plugin/head/
1 请求格式
curl -i -X<VERB> '<PROTOCOL>://<HOST>/<PATH>?<QUERY_STRING>' -d '<BODY>'
VERB : GET POST HEAD DELETE PUT
PROTOCOL : http / https
HOST : 127.0.0.1:9200 (例子)
PORT : 端口号9200
QUERY_STRING : 查询参数 _count _search
BODY : json串
2 与关系型数据库对比
Relational DB -> Databases -> Tables -> Rows -> Columns
ElasticSearch -> Indices (目录) -> Types -> Documents -> Fields
3 http://127.0.0.1:9200/megacorp/employee/_search?q=last_name:Smith
megacorp : index (目录)
employee : type
q : parameter
4 Query DSL
5 短语查询 和 高亮查询
6 分析和 aggregations(聚合,类似于group by)
1 请求格式
curl -i -X<VERB> '<PROTOCOL>://<HOST>/<PATH>?<QUERY_STRING>' -d '<BODY>'
VERB : GET POST HEAD DELETE PUT
PROTOCOL : http / https
HOST : 127.0.0.1:9200 (例子)
PORT : 端口号9200
QUERY_STRING : 查询参数 _count _search
BODY : json串
'{ "query": { "match_all":{} } }'
2 与关系型数据库对比
Relational DB -> Databases -> Tables -> Rows -> Columns
ElasticSearch -> Indices (目录) -> Types -> Documents -> Fields
3 http://127.0.0.1:9200/megacorp/employee/_search?q=last_name:Smith
megacorp : index (目录)
employee : type
q : parameter
4 Query DSL
curl -XGET 'http://127.0.0.1:9200/megacorp/employee/_search' -d ' { "query":{ "filtered":{ "filter":{ "range":{ "age":{"gt":30} } } }, "query":{ "match":{ "last_name":"Smith" } } } }'
5 短语查询 和 高亮查询
curl -XGET 'http://127.0.0.1:9200/megacorp/employee/_search' -d ' { "query":{ "match_phrase":{ "last_name":"Smith" } }, "highlight":{ "fields"{ "about":{} } } }'
6 分析和 aggregations(聚合,类似于group by)
curl -XGET 'http://127.0.0.1:9200/megacorp/employee/_search' -d ' { "query":{ "match":{ "about":"rock climbing" } }, "aggs":{ "all_interests":{ "terms":{"fields":"interests"}, } } }' curl -XGET 'http://127.0.0.1:9200/megacorp/employee/_search' -d ' { "aggs":{ "all_interests":{ "terms":{"fields":"interests"}, "aggs":{ "avg_age":{ "avg":{ "field":"age" } } } } } }'
相关文章推荐
- Elasticsearch.The.Definitive.Guide学习笔记 -- 3. Data in, Data in
- The Definitive Guide To Django 2 学习笔记(八) 第四章 模板 (四)基本的模板标签和过滤器
- ElasticSearch API for JAVA 学习笔记
- The Definitive Guide To Django 2 学习笔记(九) 第五章 模型 (一)数据库访问
- The Definitive Guide To Django 2 学习笔记(五) 第四章 模板 (一)基本模板系统
- The Definitive Guide To Django 2 学习笔记(三) URLconfs 和松耦合
- The Definitive Guide To Django 2 学习笔记(二) 第二个View 动态内容
- The Definitive Guide To Django 2 学习笔记(六) 第四章 模板 (二)使用模板系统
- ElasticSearch API for JAVA 学习笔记
- 《Elasticsearch: The Definitive Guide》读书笔记2
- The Definitive Guide To Django 2 学习笔记(一) Views and UrL confsRL
- The Definitive Guide To Django 2 学习笔记(七) 第四章 模板 (三)使用模板系统
- The Definitive Guide To Django 2 学习笔记(四) 动态URLs
- Hadoop- The Definitive Guide 笔记2
- Hadoop The Definitive Guide 2nd Edition 笔记
- [JavaScript: The Definitive Guide]笔记(1)
- JavaScript中的prototypes(JavaScript: The Definitive Guide学习摘要7)
- [论文笔记] Direct Answers for Search Queries in the Long Tail (CHI, 2012)
- Hadoop- The Definitive Guide 笔记
- 数组的长度(JavaScript: The Definitive Guide学习摘要6)