forked from striver-ing/wechat-spider
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmapping.py
127 lines (118 loc) · 3.99 KB
/
mapping.py
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
# -*- coding: utf-8 -*-
'''
Created on 2017-11-28 14:22
---------
@summary: 设置ES mapping
---------
@author: Boris
'''
from db.elastic_search import ES
class WecahtMapping():
"""docstring for WecahtMapping"""
def __init__(self):
self._es = ES()
def set_account_mapping(self):
mapping = {
"wechat_account":{
"properties":{
"summary":{
"type":"string",
"analyzer":"ik_max_word"
},
"head_url":{
"type":"string",
"index":"not_analyzed"
},
"__biz":{
"type":"string",
"index":"not_analyzed"
},
"qr_code":{
"type":"string",
"index":"not_analyzed"
},
"verify":{
"type":"string",
"index":"not_analyzed"
},
"record_time":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"account":{
"type":"string",
"index":"not_analyzed"
},
"account_id":{
"type":"string",
"index":"not_analyzed"
}
}
}
}
self._es.set_mapping('wechat_account', mapping)
def set_article_mapping(self):
mapping = {
"wechat_article":{
"properties":{
"summary":{
"type":"string",
"analyzer":"ik_max_word"
},
"like_num":{
"type":"long"
},
"author":{
"type":"string",
"index":"not_analyzed"
},
"title":{
"type":"string",
"analyzer":"ik_max_word"
},
"content":{
"type":"string",
"analyzer":"ik_max_word"
},
"source_url":{
"type":"string",
"index":"not_analyzed"
},
"url":{
"type":"string",
"index":"not_analyzed"
},
"article_id":{
"type":"long"
},
"cover":{
"type":"string",
"index":"not_analyzed"
},
"read_num":{
"type":"long"
},
"__biz":{
"type":"string",
"index":"not_analyzed"
},
"record_time":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"account":{
"type":"string",
"index":"not_analyzed"
},
"release_time":{
"type":"date",
"format":"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
}
self._es.set_mapping('wechat_article', mapping)
if __name__ == '__main__':
wechat_mapping = WecahtMapping()
wechat_mapping.set_account_mapping()
wechat_mapping.set_article_mapping()