@@ -63,7 +63,8 @@ def process_entities(entities):
6363@click .option ('--max-buffer-size' , '-b' , default = 2048 , help = 'max buffer size in megabytes (default 2048)' )
6464@click .option ('--max-token-size' , '-t' , default = 500 , help = 'max size of each token in megabytes (default 500, max 512)' )
6565@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 ):
6768 if sys .version_info [0 ] < 3 :
6869 raise Exception ("Python 3 is required for the RedisGraph bulk loader." )
6970
@@ -116,6 +117,7 @@ def bulk_insert(graph, host, port, password, nodes, nodes_with_label, relations,
116117 end_time = timer ()
117118 query_buf .report_completion (end_time - start_time )
118119
120+ # Add in Graph Indices after graph creation
119121 for i in index :
120122 l , p = i .split (":" )
121123 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,
127129 print ("Unable to create Index on Label: %s, Property %s" % (l , p ))
128130 print (e )
129131
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+
130145if __name__ == '__main__' :
131146 bulk_insert ()
0 commit comments