0%

elasticsearch使用

安装

跳过

数据结构

  • index:类似mysql的database
  • type:类似mysql的table
  • document:类似mysql一条数据
  • filed:类似mysql属性

插数据

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
PUT gmallpms
{
"mappings": {
"PmsSkuInfo":{
"properties": {
"id":{
"type": "keyword",
"index": true
},
"skuName":{
"type": "text",
"analyzer": "ik_max_word"
},
"skuDesc":{
"type": "text"
, "analyzer": "ik_smart"
},
"catalog3Id":{
"type": "keyword"
},
"price":{
"type": "double"
},
"skuDefaultImg":{
"type": "keyword",
"index": false
},
"hotScore":{
"type": "double"
},
"productId":{
"type": "keyword"
},
"skuAttrValueList":{
"properties": {
"attrId":{
"type":"keyword"
},
"valueId":{
"type":"keyword"
}
}
}
}
}
}
}

查数据

term:过滤条件

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
GET /gmallpms/PmsSkuInfo/_search
{
"query": {
"bool": {
"filter": [
{
"term": {
"price": "1000"
}
},
{
"term":{
"PmsSkuAttrValueList.valueId":"51"
}
}],
"must": [
{
"match": {
"skuName": "小米"
}
}
]
}
}
}
Donate comment here.

欢迎关注我的其它发布渠道