Skip to content

Commit 079b40f

Browse files
committed
update docs
1 parent 16a41f1 commit 079b40f

File tree

8 files changed

+476
-50
lines changed

8 files changed

+476
-50
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@
6969
- [Redis 实战](docs/nosql/redis/redis-action.md) - 关键词:`缓存``分布式锁``布隆过滤器`
7070
- [Redis 运维](docs/nosql/redis/redis-ops.md) 🔨 - 关键词:`安装``命令``集群``客户端`
7171

72-
#### Elasticsearch
73-
74-
> [Elasticsearch](docs/nosql/elasticsearch) 📚
72+
#### [Elasticsearch](docs/nosql/elasticsearch) 📚
7573

7674
- [Elasticsearch 面试总结](docs/nosql/elasticsearch/elasticsearch-interview.md) 💯
77-
- [ElasticSearch 应用指南](docs/nosql/elasticsearch/elasticsearch-quickstart.md)
78-
- [ElasticSearch API](docs/nosql/elasticsearch/ElasticSearchRestApi.md)
79-
- [ElasticSearch 运维](docs/nosql/elasticsearch/elasticsearch-ops.md)
75+
- [Elasticsearch 简介](docs/nosql/elasticsearch/Elasticsearch简介.md)
76+
- [Elasticsearch 快速入门](docs/nosql/elasticsearch/Elasticsearch快速入门.md)
77+
- [Elasticsearch 基本概念](docs/nosql/elasticsearch/Elasticsearch基本概念.md)
78+
- [Elasticsearch Rest API](docs/nosql/elasticsearch/ElasticsearchRestApi.md)
79+
- [Elasticsearch 运维](docs/nosql/elasticsearch/Elasticsearch运维.md)
8080

8181
#### HBase
8282

docs/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ footer: CC-BY-SA-4.0 Licensed | Copyright © 2018-Now Dunwu
6868
- [Redis 实战](nosql/redis/redis-action.md) - 关键词:`缓存``分布式锁``布隆过滤器`
6969
- [Redis 运维](nosql/redis/redis-ops.md) 🔨 - 关键词:`安装``命令``集群``客户端`
7070

71-
#### Elasticsearch
72-
73-
> [Elasticsearch](nosql/elasticsearch) 📚
71+
#### [Elasticsearch](nosql/elasticsearch) 📚
7472

7573
- [Elasticsearch 面试总结](nosql/elasticsearch/elasticsearch-interview.md) 💯
76-
- [ElasticSearch 应用指南](nosql/elasticsearch/elasticsearch-quickstart.md)
77-
- [ElasticSearch API](nosql/elasticsearch/ElasticSearchRestApi.md)
78-
- [ElasticSearch 运维](nosql/elasticsearch/elasticsearch-ops.md)
74+
- [Elasticsearch 简介](nosql/elasticsearch/Elasticsearch简介.md)
75+
- [Elasticsearch 快速入门](nosql/elasticsearch/Elasticsearch快速入门.md)
76+
- [Elasticsearch 基本概念](nosql/elasticsearch/Elasticsearch基本概念.md)
77+
- [Elasticsearch Rest API](nosql/elasticsearch/ElasticsearchRestApi.md)
78+
- [Elasticsearch 运维](nosql/elasticsearch/Elasticsearch运维.md)
7979

8080
#### HBase
8181

docs/nosql/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
> [Elasticsearch](elasticsearch) 📚
2121
2222
- [Elasticsearch 面试总结](elasticsearch/elasticsearch-interview.md) 💯
23-
- [ElasticSearch 应用指南](elasticsearch/elasticsearch-quickstart.md)
24-
- [ElasticSearch API](elasticsearch/elasticsearch-api.md)
25-
- [ElasticSearch 运维](elasticsearch/elasticsearch-ops.md)
23+
- [Elasticsearch 简介](elasticsearch/Elasticsearch简介.md)
24+
- [Elasticsearch 快速入门](elasticsearch/Elasticsearch快速入门.md)
25+
- [Elasticsearch 基本概念](elasticsearch/Elasticsearch基本概念.md)
26+
- [Elasticsearch Rest API](elasticsearch/ElasticsearchRestApi.md)
27+
- [Elasticsearch 运维](elasticsearch/Elasticsearch运维.md)
2628

2729
### 图数据库
2830

docs/nosql/elasticsearch/ElasticsearchRestApi.md

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,295 @@ POST kibana_sample_data_ecommerce/_msearch
666666
{"query" : {"match_all" : {}},"size":2}
667667
```
668668
669+
### URI Search 查询语义
670+
671+
Elasticsearch URI Search 遵循 QueryString 查询语义,其形式如下:
672+
673+
```bash
674+
GET /movies/_search?q=2012&df=title&sort=year:desc&from=0&size=10&timeout=1s
675+
{
676+
"profile": true
677+
}
678+
```
679+
680+
- **`q`** 指定查询语句,使用 QueryString 语义
681+
- **`df`** 默认字段,不指定时
682+
- **`sort`** 排序:from 和 size 用于分页
683+
- **`profile`** 可以查看查询时如何被执行的
684+
685+
```bash
686+
GET /movies/_search?q=title:2012&sort=year:desc&from=0&size=10&timeout=1s
687+
{
688+
"profile":"true"
689+
}
690+
```
691+
692+
#### Term 和 Phrase
693+
694+
Beautiful Mind 等效于 Beautiful OR Mind
695+
696+
"Beautiful Mind" 等效于 Beautiful AND Mind
697+
698+
```bash
699+
# Term 查询
700+
GET /movies/_search?q=title:Beautiful Mind
701+
{
702+
"profile":"true"
703+
}
704+
705+
# 使用引号,Phrase 查询
706+
GET /movies/_search?q=title:"Beautiful Mind"
707+
{
708+
"profile":"true"
709+
}
710+
```
711+
712+
#### 分组与引号
713+
714+
title:(Beautiful AND Mind)
715+
716+
title="Beautiful Mind"
717+
718+
#### AND、OR、NOT 或者 &&、||、!
719+
720+
> 注意:AND、OR、NOT 必须大写
721+
722+
```bash
723+
# 布尔操作符
724+
GET /movies/_search?q=title:(Beautiful AND Mind)
725+
{
726+
"profile":"true"
727+
}
728+
729+
GET /movies/_search?q=title:(Beautiful NOT Mind)
730+
{
731+
"profile":"true"
732+
}
733+
```
734+
735+
#### 范围查询
736+
737+
- `[]` 表示闭区间
738+
- `{}` 表示开区间
739+
740+
示例:
741+
742+
```bash
743+
# 范围查询 ,区间写法
744+
GET /movies/_search?q=title:beautiful AND year:{2010 TO 2018%7D
745+
{
746+
"profile":"true"
747+
}
748+
749+
GET /movies/_search?q=title:beautiful AND year:[* TO 2018]
750+
{
751+
"profile":"true"
752+
}
753+
```
754+
755+
#### 算数符号
756+
757+
```bash
758+
# 2010 年以后的记录
759+
GET /movies/_search?q=year:>2010
760+
{
761+
"profile":"true"
762+
}
763+
764+
# 2010 年到 2018 年的记录
765+
GET /movies/_search?q=year:(>2010 && <=2018)
766+
{
767+
"profile":"true"
768+
}
769+
770+
# 2010 年到 2018 年的记录
771+
GET /movies/_search?q=year:(+>2010 +<=2018)
772+
{
773+
"profile":"true"
774+
}
775+
```
776+
777+
#### 通配符查询
778+
779+
- `?` 代表 1 个字符
780+
- `*` 代表 0 或多个字符
781+
782+
示例:
783+
784+
```bash
785+
GET /movies/_search?q=title:mi?d
786+
{
787+
"profile":"true"
788+
}
789+
790+
GET /movies/_search?q=title:b*
791+
{
792+
"profile":"true"
793+
}
794+
```
795+
796+
#### 正则表达式
797+
798+
title:[bt]oy
799+
800+
#### 模糊匹配与近似查询
801+
802+
示例:
803+
804+
```bash
805+
# 相似度在 1 个字符以内
806+
GET /movies/_search?q=title:beautifl~1
807+
{
808+
"profile":"true"
809+
}
810+
811+
# 相似度在 2 个字符以内
812+
GET /movies/_search?q=title:"Lord Rings"~2
813+
{
814+
"profile":"true"
815+
}
816+
```
817+
818+
### Request Body & DSL
819+
820+
Elasticsearch 除了 URI Search 查询方式,还支持将查询语句通过 Http Request Body 发起查询。
821+
822+
```bash
823+
GET /kibana_sample_data_ecommerce/_search?ignore_unavailable=true
824+
{
825+
"profile":"true",
826+
"query": {
827+
"match_all": {}
828+
}
829+
}
830+
```
831+
832+
#### 分页
833+
834+
```bash
835+
GET /kibana_sample_data_ecommerce/_search?ignore_unavailable=true
836+
{
837+
"profile": "true",
838+
"from": 0,
839+
"size": 10,
840+
"query": {
841+
"match_all": {}
842+
}
843+
}
844+
```
845+
846+
#### 排序
847+
848+
最好在数字型或日期型字段上排序
849+
850+
因为对于多值类型或分析过的字段排序,系统会选一个值,无法得知该值
851+
852+
```bash
853+
GET /kibana_sample_data_ecommerce/_search?ignore_unavailable=true
854+
{
855+
"profile": "true",
856+
"sort": [
857+
{
858+
"order_date": "desc"
859+
}
860+
],
861+
"from": 1,
862+
"size": 10,
863+
"query": {
864+
"match_all": {}
865+
}
866+
}
867+
```
868+
869+
#### \_source 过滤
870+
871+
如果 `_source` 没有存储,那就只返回匹配的文档的元数据
872+
873+
`_source` 支持使用通配符,如:`_source["name*", "desc*"]`
874+
875+
示例:
876+
877+
```bash
878+
GET /kibana_sample_data_ecommerce/_search?ignore_unavailable=true
879+
{
880+
"profile": "true",
881+
"_source": [
882+
"order_date",
883+
"category.keyword"
884+
],
885+
"from": 1,
886+
"size": 10,
887+
"query": {
888+
"match_all": {}
889+
}
890+
}
891+
```
892+
893+
#### 脚本字段
894+
895+
```bash
896+
GET /kibana_sample_data_ecommerce/_search?ignore_unavailable=true
897+
{
898+
"profile": "true",
899+
"script_fields": {
900+
"new_field": {
901+
"script": {
902+
"lang": "painless",
903+
"source":"doc['order_date'].value+' hello'"
904+
}
905+
}
906+
},
907+
"from": 1,
908+
"size": 10,
909+
"query": {
910+
"match_all": {}
911+
}
912+
}
913+
914+
```
915+
916+
#### 使用查询表达式 - Match
917+
918+
```bash
919+
POST movies/_search
920+
{
921+
"query": {
922+
"match": {
923+
"title": "last christmas"
924+
}
925+
}
926+
}
927+
928+
POST movies/_search
929+
{
930+
"query": {
931+
"match": {
932+
"title": {
933+
"query": "last christmas",
934+
"operator": "and"
935+
}
936+
}
937+
}
938+
}
939+
940+
```
941+
942+
#### 短语搜索 - Match Phrase
943+
944+
```bash
945+
POST movies/_search
946+
{
947+
"query": {
948+
"match_phrase": {
949+
"title":{
950+
"query": "last christmas"
951+
952+
}
953+
}
954+
}
955+
}
956+
```
957+
669958
## 集群 API
670959
671960
> [Elasticsearch 官方之 Cluster API](https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster.html)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy