@@ -40,21 +40,15 @@ def create_git_index(client, index):
4040 },
4141 },
4242 "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 },
5852 }
5953 },
6054 }
@@ -64,7 +58,7 @@ def create_git_index(client, index):
6458 client .indices .create (index = index , body = create_index_body )
6559 except TransportError as e :
6660 # ignore already existing index
67- if e .error == "index_already_exists_exception " :
61+ if e .error == "resource_already_exists_exception " :
6862 pass
6963 else :
7064 raise
@@ -112,7 +106,6 @@ def load_repo(client, path=None, index="git"):
112106 client ,
113107 parse_commits (repo .refs .master .commit , repo_name ),
114108 index = index ,
115- doc_type = "doc" ,
116109 chunk_size = 50 , # keep the batch sizes small for appearances only
117110 ):
118111 action , result = result .popitem ()
@@ -128,13 +121,13 @@ def load_repo(client, path=None, index="git"):
128121# we manually update some documents to add additional information
129122UPDATES = [
130123 {
131- "_type" : "doc " ,
124+ "_type" : "_doc " ,
132125 "_id" : "20fbba1230cabbc0f4644f917c6c2be52b8a63e8" ,
133126 "_op_type" : "update" ,
134127 "doc" : {"initial_commit" : True },
135128 },
136129 {
137- "_type" : "doc " ,
130+ "_type" : "_doc " ,
138131 "_id" : "ae0073c8ca7e24d237ffd56fba495ed409081bf4" ,
139132 "_op_type" : "update" ,
140133 "doc" : {"release" : "5.0.0" },
@@ -179,9 +172,7 @@ def load_repo(client, path=None, index="git"):
179172 es .indices .refresh (index = "git" )
180173
181174 # 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" )
185176 print (
186177 "%s: %s" % (initial_commit ["_id" ], initial_commit ["_source" ]["committed_date" ])
187178 )
0 commit comments