| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 
 | # ES导出指定索引中的数据elasticdump --input http://192.168.0.1:9200/default_data --output ./default_data.json --type=data
 # ES导入指定数据到索引中
 elasticdump --input=/opt/default_data.json --output=http://192.168.0.1:9200/default_data
 # 集群属性
 GET _cluster/health
 # 查看所有的索引
 curl http://192.168.0.1:9200/_cat/indices
 # 获取文档指定id的数据
 curl -XGET 'http://192.168.0.1:9200/default_index/_doc/123456?pretty=true'
 GET default_index/_doc/123456
 # 全量查询
 GET default_index/_search
 {
 "query": {
 "match_all": {}
 }
 }
 # 条件查询
 GET default_index/_search
 {
 "query": {
 "match": {
 "uid": 111
 }
 }
 }
 # 覆盖修改
 PUT default_index/_doc/123456
 {
 "id": 42,
 "name": "技师1",
 "price": 298
 }
 # 局部修改
 POST default_index/_doc/123456
 {
 "id": 66,
 "name": "技师2",
 "price": 398
 }
 # 清除索引内指定id的数据
 DELETE default_index/_doc/123456
 # 分析
 GET _analyze
 {
 "analyzer": "standard",
 "text" : "wu yi fan"
 }
 # 去除分页数量限制报错
 curl -XPUT http://192.168.0.1:9200/default_index/_settings -d '{ "index" : { "max_result_window" : 100000000}}'
 PUT default_index/_settings
 {
 "index":{
 "max_result_window":1000000
 }
 # 全量查询分页及排序
 GET default_index/_search
 {
 "query": {
 "match": {
 "name": "技师2"
 }
 },
 "from":0,
 "size":1,
 "_source":["name"],
 "sort":{
 "id":{
 "order":"desc"
 }
 }
 }
 # 多条件查找
 GET default_index/_search
 {
 "query": {
 "bool":{
 "must":[
 {"match":{
 "name":"技师2"
 }
 },
 {"match":{
 "id": 66
 }
 }
 ],
 "filter":{
 "range":{
 "price":{
 "gt": 298
 }
 }
 }
 }
 }
 }
 # 新增索引
 curl -X PUT "http://192.168.0.1:9200/default_index" -H 'Content-Type: application/json' -d'
 PUT default_index
 {
 "mappings": {
 "_doc": {
 "properties": {
 "USER_ID": {
 "type": "long"
 },
 "someString": {
 "type": "text",
 "fields": {
 "keyword": {
 "type": "keyword",
 "ignore_above": 256
 }
 },
 "fielddata": true
 },
 "someShortName": {
 "type": "text",
 "analyzer": "ik_max_word"
 },
 "someType": {
 "type": "text",
 "analyzer": "ik_smart",
 "fielddata": true
 },
 "roomId": {
 "type": "integer"
 },
 "someIds": {
 "type": "text",
 "fields": {
 "keyword": {
 "type": "keyword",
 "ignore_above": 256
 }
 }
 },
 "somePrices": {
 "type": "nested",
 "properties": {
 "endDate": {
 "type": "date"
 },
 "sellPrice": {
 "type": "double"
 },
 "startDate": {
 "type": "date"
 }
 }
 },
 "isSale": {
 "type": "boolean"
 },
 "location": {
 "type": "geo_point"
 },
 "valid": {
 "type": "boolean"
 }
 }
 }
 }
 }
 
 
 |