-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathes语句备份.txt
285 lines (264 loc) · 6.27 KB
/
es语句备份.txt
1
2
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
POST /_analyze
{
"analyzer":"not_analyzed",
"text":"广州市天河区高天路"
}
GET /ropledata2/_analyze
{
"field": "address",
"text": "广州市天河区高普路"
}
GET /ropledata2/_search?q=address:"深圳市福田区科技路"
{
"profile":"true"
}
GET /ropledata2/_search#精确匹配
{
"query": {
"match_phrase": {
"company":"香满楼"
}
}
}
GET /ropledata2/_search#精确匹配
{
"query": {
"match_phrase": {
"_id":"7ce5e4c87b88c7f6e2e7ec72405e7779"
}
}
}
GET /ropledata2/_search
GET ropledata2/_search
{
"query": {
"bool": {
"must": [
{
"exists": {
"field": "sex"
}
}
]
}
}
}
DELETE /ropledata2
PUT /ropledata2
{
"settings":{
"number_of_shards" : "3",
"number_of_replicas" : "0",
"analysis": {
"analyzer": {
"ik_en_analyzer": {
"type": "custom",
"tokenizer": "ik_max_word",
"filter": ["my_pinyin"]
}
},
"filter": {
"my_pinyin" : {
"type" : "pinyin",
"keep_separate_first_letter" : false,
"keep_full_pinyin" : true,
"keep_original" : true,
"limit_first_letter_length" : 16,
"lowercase" : true,
"remove_duplicated_term" : true
}
}
}
},
"mappings":{
"properties":{
"id":{"type":"long"},
"address":{
"type" : "text",
"analyzer" : "ik_en_analyzer"
},
"company":{
"type" : "text",
"analyzer" : "ik_en_analyzer"
},
"text":{"type":"text"}
}
}
}
POST _bulk
{ "create" : { "_index" : "ropledata2", "_id" : "1005" } }
{"id":5,"address": "广州市天河区高普路","company": ["软通动力","欧博方"]}
{ "create" : { "_index" : "ropledata2", "_id" : "1006" } }
{"id":6,"address": "广州市天河区高科路","company": ["香满楼","燕塘"]}
{ "create" : { "_index" : "ropledata2", "_id" : "1007" } }
{"id":7,"address": "深圳市福田区科技路","company": ["香满楼","腾讯"]}
{ "create" : { "_index" : "ropledata2", "_id" : "1008" } }
{"id":8,"address": "上海市静安区南京路","company": ["阿里巴巴","腾讯"]}
{ "create" : { "_index" : "ropledata2", "_id" : "1009" } }
{"id":9,"address": "上海市杨浦区五角场路","company": ["超电文化","米哈游"]}
{ "create" : { "_index" : "ropledata2", "_id" : "1010" } }
{"id":10,"address": "广州市天河区高安路","company": ["唯品会"]}
POST ropledata2/_search#多字段匹配
{
"query": {
"multi_match":{
"query":"香满楼",
"fields":["address","company"]
}
},
"from":0,
"size":1
}
POST ropledata2/_search
{
"query" : {
"constant_score" : {
"filter" : {
"term" : {
"address": "南京"
}
}
}
}
}
POST ropledata2/_update_by_query
{
"query" : {
"constant_score" : {
"filter" : {
"term" : {
"address": "高"
}
}
}
}
,
"script": {
"source": "ctx._source['address']='广州市天河区高普路128号';"
}
}
POST ropledata2/_update_by_query
{
"query" : {
"constant_score" : {
"filter" : {
"term" : {
"address": "高"
}
}
}
}
,
"script": {
"source": "ctx._source['address']='广州市天河区高普路128号';"
}
}
POST ropledata2/_update_by_query#把address字符变数组再插入
{
"query": {
"match_phrase": {
"address":"广州市天河区高科路"
}
}
,
"script": {
"source": "ctx._source['address']=['广州市天河区高科路125号'];"
}
}
POST ropledata2/_search#
{
"query": {
"multi_match":{
"query":"软通动力在广州市天河区高普路",
"fields":["company","address"]
}
},
"from":0,
"size":1
}
PUT /_all/_settings
{
"index.blocks.read_only_allow_delete": null
}
GET /ropledata2/_search
POST ropledata2/_update_by_query#变更指定地址/企业的名字
{
"query": {
"match_phrase": {
"company":"香满楼乳业"
}
},
"script": {
"lang": "painless",
"source": "for (int i=0;i<ctx._source.company.size();i++) {if(ctx._source.company[i]== params.old) { ctx._source.company[i] = params.new} }",
"params": {
"old": "香满楼乳业",
"new": "香满楼99999"
}
}
}
POST ropledata2/_search#多字段匹配
{
"query": {
"multi_match":{
"query":"广州市天河区高普路",
"fields":["address"]
}
}
}
POST ropledata2/_search/exists
{
"query" : {
"term" : { "user" : "kimchy" }
}
}
POST ropledata2/_update_by_query#
{
"query": {
"match_phrase": {
"address":"广州市天河区高安路138号"
}
},
"script": {
"source": "ctx._source.company.add(params.tag)",
"lang": "painless",
"params": {
"tag": "blue"
}
}
}
PUT ropledata2/_doc/17273948879270242946
{
"address": "广州市天河区高天路144号","company": []
}
POST ropledata2/_search#
{
"query": {
"match_phrase": {
"_id":"4c33a6389976ee4b1441f101b2183f44"
}
}
}
POST ropledata2/_search#
{
"query": {
"match_phrase": {
"company":"香满楼"
}
}
}
POST ropledata2/_update_by_query#变更指定地址/企业的名字
{
"query": {
"match_phrase": {
"company":"香满楼"
}
},
"script": {
"lang": "painless",
"source": "int a=0;for (int i=0;i<ctx._source.company.size();i++) {if(ctx._source.company[i]==params.tag){a=1;break;}}if(a==0){ctx._source.company.add(params.tag)}",
"params":{
"tag":"香满楼8888"
}
}
}