@@ 20-31 (lines=12) @@ | ||
17 | class TaskDB(BaseTaskDB): |
|
18 | __type__ = 'task' |
|
19 | ||
20 | def __init__(self, hosts, index='pyspider'): |
|
21 | self.index = index |
|
22 | self._changed = False |
|
23 | self.es = Elasticsearch(hosts=hosts) |
|
24 | ||
25 | self.es.indices.create(index=self.index, ignore=400) |
|
26 | if not self.es.indices.get_mapping(index=self.index, doc_type=self.__type__): |
|
27 | self.es.indices.put_mapping(index=self.index, doc_type=self.__type__, body={ |
|
28 | "_all": {"enabled": False}, |
|
29 | "properties": { |
|
30 | "project": {"type": "string", "index": "not_analyzed"}, |
|
31 | "status": {"type": "byte"}, |
|
32 | } |
|
33 | }) |
|
34 |
@@ 19-30 (lines=12) @@ | ||
16 | class ResultDB(BaseResultDB): |
|
17 | __type__ = 'result' |
|
18 | ||
19 | def __init__(self, hosts, index='pyspider'): |
|
20 | self.index = index |
|
21 | self.es = Elasticsearch(hosts=hosts) |
|
22 | ||
23 | self.es.indices.create(index=self.index, ignore=400) |
|
24 | if not self.es.indices.get_mapping(index=self.index, doc_type=self.__type__): |
|
25 | self.es.indices.put_mapping(index=self.index, doc_type=self.__type__, body={ |
|
26 | "_all": {"enabled": True}, |
|
27 | "properties": { |
|
28 | "taskid": {"enabled": False}, |
|
29 | "project": {"type": "string", "index": "not_analyzed"}, |
|
30 | "url": {"enabled": False}, |
|
31 | } |
|
32 | }) |
|
33 |
@@ 18-27 (lines=10) @@ | ||
15 | class ProjectDB(BaseProjectDB): |
|
16 | __type__ = 'project' |
|
17 | ||
18 | def __init__(self, hosts, index='pyspider'): |
|
19 | self.index = index |
|
20 | self.es = Elasticsearch(hosts=hosts) |
|
21 | ||
22 | self.es.indices.create(index=self.index, ignore=400) |
|
23 | if not self.es.indices.get_mapping(index=self.index, doc_type=self.__type__): |
|
24 | self.es.indices.put_mapping(index=self.index, doc_type=self.__type__, body={ |
|
25 | "_all": {"enabled": False}, |
|
26 | "properties": { |
|
27 | "updatetime": {"type": "double"} |
|
28 | } |
|
29 | }) |
|
30 |