@@ -63,7 +63,8 @@ def process_entities(entities):
63
63
@click .option ('--max-buffer-size' , '-b' , default = 2048 , help = 'max buffer size in megabytes (default 2048)' )
64
64
@click .option ('--max-token-size' , '-t' , default = 500 , help = 'max size of each token in megabytes (default 500, max 512)' )
65
65
@click .option ('--index' , '-i' , multiple = True , help = 'Label:Propery on which to create an index' )
66
- def bulk_insert (graph , host , port , password , nodes , nodes_with_label , relations , relations_with_type , separator , enforce_schema , skip_invalid_nodes , skip_invalid_edges , quote , max_token_count , max_buffer_size , max_token_size , index ):
66
+ @click .option ('--full-text-index' , '-f' , multiple = True , help = 'Label:Propery on which to create an full text search index' )
67
+ def bulk_insert (graph , host , port , password , nodes , nodes_with_label , relations , relations_with_type , separator , enforce_schema , skip_invalid_nodes , skip_invalid_edges , quote , max_token_count , max_buffer_size , max_token_size , index , full_text_index ):
67
68
if sys .version_info [0 ] < 3 :
68
69
raise Exception ("Python 3 is required for the RedisGraph bulk loader." )
69
70
@@ -116,6 +117,7 @@ def bulk_insert(graph, host, port, password, nodes, nodes_with_label, relations,
116
117
end_time = timer ()
117
118
query_buf .report_completion (end_time - start_time )
118
119
120
+ # Add in Graph Indices after graph creation
119
121
for i in index :
120
122
l , p = i .split (":" )
121
123
print ("Creating Index on Label: %s, Property: %s" % (l , p ))
@@ -127,5 +129,18 @@ def bulk_insert(graph, host, port, password, nodes, nodes_with_label, relations,
127
129
print ("Unable to create Index on Label: %s, Property %s" % (l , p ))
128
130
print (e )
129
131
132
+ # Add in Full Text Search Indices after graph creation
133
+ for i in full_text_index :
134
+ l , p = i .split (":" )
135
+ print ("Creating Full Text Search Index on Label: %s, Property: %s" % (l , p ))
136
+ try :
137
+ index_create = client .execute_command ("GRAPH.QUERY" , graph , "CALL db.idx.fulltext.createNodeIndex('%s', '%s')" % (l , p ))
138
+ print (index_create [- 1 ][0 ].decode ("utf-8" ))
139
+ except redis .exceptions .ResponseError as e :
140
+ print ("Unable to create Full Text Search Index on Label: %s, Property %s" % (l , p ))
141
+ print (e )
142
+ except :
143
+ print ("Unknown Error: Unable to create Full Text Search Index on Label: %s, Property %s" % (l , p ))
144
+
130
145
if __name__ == '__main__' :
131
146
bulk_insert ()
0 commit comments