@@ -237,12 +237,12 @@ async def multi_index_global_search(
237237 raise NotImplementedError (message )
238238
239239 links = {
240- "community " : {},
240+ "communities " : {},
241241 "community_reports" : {},
242242 "entities" : {},
243243 }
244244 max_vals = {
245- "community " : - 1 ,
245+ "communities " : - 1 ,
246246 "community_reports" : - 1 ,
247247 "entities" : - 1 ,
248248 }
@@ -272,16 +272,20 @@ async def multi_index_global_search(
272272 communities_df ["community" ] = communities_df ["community" ].astype (int )
273273 communities_df ["parent" ] = communities_df ["parent" ].astype (int )
274274 for i in communities_df ["community" ]:
275- links ["community " ][i + max_vals ["community " ] + 1 ] = {
275+ links ["communities " ][i + max_vals ["communities " ] + 1 ] = {
276276 "index_name" : index_name ,
277277 "id" : str (i ),
278278 }
279- communities_df ["community" ] += max_vals ["community " ] + 1
279+ communities_df ["community" ] += max_vals ["communities " ] + 1
280280 communities_df ["parent" ] = communities_df ["parent" ].apply (
281- lambda x : x if x == - 1 else x + max_vals ["community" ] + 1
281+ lambda x : x if x == - 1 else x + max_vals ["communities" ] + 1
282+ )
283+ communities_df ["human_readable_id" ] += max_vals ["communities" ] + 1
284+ # concat the index name to the entity_ids, since this is used for joining later
285+ communities_df ["entity_ids" ] = communities_df ["entity_ids" ].apply (
286+ lambda x , index_name = index_name : [i + f"-{ index_name } " for i in x ]
282287 )
283- communities_df ["human_readable_id" ] += max_vals ["community" ] + 1
284- max_vals ["community" ] = int (communities_df ["community" ].max ())
288+ max_vals ["communities" ] = int (communities_df ["community" ].max ())
285289 communities_dfs .append (communities_df )
286290
287291 # Prepare each index's entities dataframe for merging
@@ -514,13 +518,15 @@ async def multi_index_local_search(
514518
515519 links = {
516520 "community_reports" : {},
521+ "communities" : {},
517522 "entities" : {},
518523 "text_units" : {},
519524 "relationships" : {},
520525 "covariates" : {},
521526 }
522527 max_vals = {
523528 "community_reports" : - 1 ,
529+ "communities" : - 1 ,
524530 "entities" : - 1 ,
525531 "text_units" : 0 ,
526532 "relationships" : - 1 ,
@@ -544,6 +550,10 @@ async def multi_index_local_search(
544550 }
545551 communities_df ["community" ] += max_vals ["communities" ] + 1
546552 communities_df ["human_readable_id" ] += max_vals ["communities" ] + 1
553+ # concat the index name to the entity_ids, since this is used for joining later
554+ communities_df ["entity_ids" ] = communities_df ["entity_ids" ].apply (
555+ lambda x , index_name = index_name : [i + f"-{ index_name } " for i in x ]
556+ )
547557 max_vals ["communities" ] = int (communities_df ["community" ].max ())
548558 communities_dfs .append (communities_df )
549559
@@ -873,12 +883,14 @@ async def multi_index_drift_search(
873883
874884 links = {
875885 "community_reports" : {},
886+ "communities" : {},
876887 "entities" : {},
877888 "text_units" : {},
878889 "relationships" : {},
879890 }
880891 max_vals = {
881892 "community_reports" : - 1 ,
893+ "communities" : - 1 ,
882894 "entities" : - 1 ,
883895 "text_units" : 0 ,
884896 "relationships" : - 1 ,
@@ -901,6 +913,10 @@ async def multi_index_drift_search(
901913 }
902914 communities_df ["community" ] += max_vals ["communities" ] + 1
903915 communities_df ["human_readable_id" ] += max_vals ["communities" ] + 1
916+ # concat the index name to the entity_ids, since this is used for joining later
917+ communities_df ["entity_ids" ] = communities_df ["entity_ids" ].apply (
918+ lambda x , index_name = index_name : [i + f"-{ index_name } " for i in x ]
919+ )
904920 max_vals ["communities" ] = int (communities_df ["community" ].max ())
905921 communities_dfs .append (communities_df )
906922
0 commit comments