1
+ 浏览器访问es server
2
+ http://10.144.48.30:9200/_plugin/marvel/sense/
3
+
4
+
5
+ 0,创建数据:
6
+ PUT /gome/employee/1
7
+ {
8
+ "first_name" : "li",
9
+ "last_name" : "ming",
10
+ "age" : 18,
11
+ "about" : "I love play football",
12
+ "interests": [ "sports", "music" ]
13
+ }
14
+ 1,
15
+
16
+ 查询名字叫:
17
+ GET /gome/employee/_search?q=last_name:liue
18
+
19
+ 2,查询名字叫:
20
+ GET /gome/employee/_search
21
+ {
22
+ "query" : {
23
+ "match" : {
24
+ "last_name" : "yang"
25
+ }
26
+ }
27
+ }
28
+ 3,年龄大于12岁,且名字叫“yang”:
29
+ GET /gome/employee/_search
30
+ {
31
+ "query" : {
32
+ "filtered" : {
33
+ "filter" : {
34
+ "range" : {
35
+ "age" : { "gt" : 12 }
36
+ }
37
+ },
38
+ "query" : {
39
+ "match" : {
40
+ "last_name" : "yang"
41
+ }
42
+ }
43
+ }
44
+ }
45
+ }
46
+ 4,全文检索:
47
+ GET /gome/employee/_search
48
+ {
49
+ "query" : {
50
+ "match" : {
51
+ "about" : "i to"
52
+ }
53
+ }
54
+ }
55
+ 默认情况下,Elasticsearch根据结果相关性评分来对结果集进行排序,所谓的「结果相关性评分」就是文档与查询条件的匹配程度。很显然,排名第一的John Smith的about字段明确的写到“rock climbing”。
56
+
57
+ 但是为什么Jane Smith也会出现在结果里呢?原因是“rock”在她的abuot字段中被提及了。因为只有“rock”被提及而“climbing”没有,所以她的_score要低于John。
58
+
59
+ 这个例子很好的解释了Elasticsearch如何在各种文本字段中进行全文搜索,并且返回相关性最大的结果集。相关性(relevance)的概念在Elasticsearch中非常重要,而这个概念在传统关系型数据库中是不可想象的,因为传统数据库对记录的查询只有匹配或者不匹配。
60
+ 5,短语搜索:
61
+ GET /gome/employee/_search
62
+ {
63
+ "query" : {
64
+ "match_phrase" : {
65
+ "about" : "rock albums"
66
+ }
67
+ }
68
+ }
69
+ 6,高亮我们的搜索:
70
+ GET /gome/employee/_search
71
+ {
72
+ "query" : {
73
+ "match_phrase" : {
74
+ "about" : "rock albums"
75
+ }
76
+ },
77
+ "highlight": {
78
+ "fields" : {
79
+ "about" : {}
80
+ }
81
+ }
82
+ }
83
+
84
+ 7,聚合我们的结果:
85
+ GET /gome/employee/_search
86
+ {
87
+ "aggs": {
88
+ "all_interests": {
89
+ "terms": { "field": "interests" }
90
+ }
91
+ }
92
+ }
93
+ 8,聚合功能:
94
+ GET /gome/employee/_search
95
+ {
96
+ "query": {
97
+ "match": {
98
+ "last_name": "tao"
99
+ }
100
+ },
101
+ "aggs": {
102
+ "all_interests": {
103
+ "terms": {
104
+ "field": "interests"
105
+ }
106
+ }
107
+ }
108
+ }
109
+
110
+ 9,每种兴趣下职员的平均年龄:
111
+ GET /gome/employee/_search
112
+ {
113
+ "aggs" : {
114
+ "all_interests" : {
115
+ "terms" : { "field" : "interests" },
116
+ "aggs" : {
117
+ "avg_age" : {
118
+ "avg" : { "field" : "age" }
119
+ }
120
+ }
121
+ }
122
+ }
123
+ }
124
+ 分布式集群:
125
+ 状态为啥都是yellow的。
126
+ http://www.bjrbj.gov.cn/csibiz/indinfo/passwordSetAction!gerenreg1
127
+
128
+ 检查社保
129
+
130
+ http://www.360doc.com/content/14/0119/22/15109633_346516210.shtml
131
+
132
+ 130534195504022645
133
+
134
+ http://10.58.51.87:9201/_plugin/head/
135
+
136
+ http://10.58.45.16:8810/overview/37
137
+
138
+ http://10.58.22.2:9800/_plugin/head/
139
+
140
+ http://search.gome.com.cn/cloud/test.jsp
141
+
142
+ http://10.58.22.45:7003/gac/page/main/main.jsp
143
+ {
144
+ "query": {
145
+ "bool": {
146
+ "must": [
147
+ {
148
+ "query_string": {
149
+ "default_field": "_all",
150
+ "query": ""2015-11-27 15*""
151
+ }
152
+ }
153
+ ],
154
+ "must_not": [ ],
155
+ "should": [ ]
156
+ }
157
+ },
158
+ "from": 0,
159
+ "size": 10,
160
+ "sort": [ ],
161
+ "facets": { }
162
+ }
163
+
164
+
165
+ PUT /product/employee/1
166
+ {
167
+ "first_name" : "John",
168
+ "last_name" : "Smith",
169
+ "age" : 25,
170
+ "about" : "I love to go rock climbing",
171
+ "interests": [ "sports", "music" ]
172
+ }
173
+ PUT /product/employee/2
174
+ {
175
+ "first_name" : "Jane",
176
+ "last_name" : "Smith",
177
+ "age" : 32,
178
+ "about" : "I like to collect rock albums",
179
+ "interests": [ "music" ]
180
+ }
181
+ PUT /product/employee/3
182
+ {
183
+ "first_name" : "Douglas",
184
+ "last_name" : "Fir",
185
+ "age" : 35,
186
+ "about": "I like to build cabinets",
187
+ "interests": [ "forestry" ]
188
+ }
189
+ 2,
190
+ 获得单个的商品:
191
+ GET /product/employee/_search
192
+ 3,
193
+ 域搜索:GET /product/employee/_search?q=last_name:Smith
194
+ 4,
195
+ DSL (Domain Specific Language 领域特定语言) 检索
196
+ GET /product/employee/_search
197
+ {
198
+ "query" : {
199
+ "match" : {
200
+ "last_name" : "Smith"
201
+ }
202
+ }
203
+ }
204
+ 5,
205
+ 出姓 Smith 的员工,但是我们还将 添加一个年龄大于30岁的限定条件,添加过滤器
206
+ GET /product/employee/_search
207
+ {
208
+ "query" : {
209
+ "filtered" : {
210
+ "filter" : {
211
+ "range" : {
212
+ "age" : { "gt" : 30 }
213
+ }
214
+ },
215
+ "query" : {
216
+ "match" : {
217
+ "last_name" : "Smith"
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+ 6,
224
+ GET /product/employee/_search
225
+ {
226
+ "query" : {
227
+ "match" : {
228
+ "about" : "rock climbing"
229
+ }
230
+ }
231
+ }
232
+ 7,match_phrase用法,精确匹配
233
+ GET /product/employee/_search
234
+ {
235
+ "query" : {
236
+ "match_phrase" : {
237
+ "about" : "rock climbing"
238
+ }
239
+ }
240
+ }
241
+ 8,高亮显示搜索结果
242
+ GET /product/employee/_search
243
+ {
244
+ "query" : {
245
+ "match_phrase" : {
246
+ "about" : "rock climbing"
247
+ }
248
+ },
249
+ "highlight": {
250
+ "fields" : {
251
+ "about" : {}
252
+ }
253
+ }
254
+ }
0 commit comments