@@ -40,21 +40,15 @@ def create_git_index(client, index):
40
40
},
41
41
},
42
42
"mappings" : {
43
- "doc" : {
44
- "properties" : {
45
- "repository" : {"type" : "keyword" },
46
- "author" : user_mapping ,
47
- "authored_date" : {"type" : "date" },
48
- "committer" : user_mapping ,
49
- "committed_date" : {"type" : "date" },
50
- "parent_shas" : {"type" : "keyword" },
51
- "description" : {"type" : "text" , "analyzer" : "snowball" },
52
- "files" : {
53
- "type" : "text" ,
54
- "analyzer" : "file_path" ,
55
- "fielddata" : True ,
56
- },
57
- }
43
+ "properties" : {
44
+ "repository" : {"type" : "keyword" },
45
+ "author" : user_mapping ,
46
+ "authored_date" : {"type" : "date" },
47
+ "committer" : user_mapping ,
48
+ "committed_date" : {"type" : "date" },
49
+ "parent_shas" : {"type" : "keyword" },
50
+ "description" : {"type" : "text" , "analyzer" : "snowball" },
51
+ "files" : {"type" : "text" , "analyzer" : "file_path" , "fielddata" : True },
58
52
}
59
53
},
60
54
}
@@ -64,7 +58,7 @@ def create_git_index(client, index):
64
58
client .indices .create (index = index , body = create_index_body )
65
59
except TransportError as e :
66
60
# ignore already existing index
67
- if e .error == "index_already_exists_exception " :
61
+ if e .error == "resource_already_exists_exception " :
68
62
pass
69
63
else :
70
64
raise
@@ -112,7 +106,6 @@ def load_repo(client, path=None, index="git"):
112
106
client ,
113
107
parse_commits (repo .refs .master .commit , repo_name ),
114
108
index = index ,
115
- doc_type = "doc" ,
116
109
chunk_size = 50 , # keep the batch sizes small for appearances only
117
110
):
118
111
action , result = result .popitem ()
@@ -128,13 +121,13 @@ def load_repo(client, path=None, index="git"):
128
121
# we manually update some documents to add additional information
129
122
UPDATES = [
130
123
{
131
- "_type" : "doc " ,
124
+ "_type" : "_doc " ,
132
125
"_id" : "20fbba1230cabbc0f4644f917c6c2be52b8a63e8" ,
133
126
"_op_type" : "update" ,
134
127
"doc" : {"initial_commit" : True },
135
128
},
136
129
{
137
- "_type" : "doc " ,
130
+ "_type" : "_doc " ,
138
131
"_id" : "ae0073c8ca7e24d237ffd56fba495ed409081bf4" ,
139
132
"_op_type" : "update" ,
140
133
"doc" : {"release" : "5.0.0" },
@@ -179,9 +172,7 @@ def load_repo(client, path=None, index="git"):
179
172
es .indices .refresh (index = "git" )
180
173
181
174
# now we can retrieve the documents
182
- initial_commit = es .get (
183
- index = "git" , doc_type = "doc" , id = "20fbba1230cabbc0f4644f917c6c2be52b8a63e8"
184
- )
175
+ initial_commit = es .get (index = "git" , id = "20fbba1230cabbc0f4644f917c6c2be52b8a63e8" )
185
176
print (
186
177
"%s: %s" % (initial_commit ["_id" ], initial_commit ["_source" ]["committed_date" ])
187
178
)
0 commit comments