4343from databuilder .publisher .elasticsearch_publisher import ElasticsearchPublisher
4444from databuilder .publisher .nebula_csv_publisher import NebulaCsvPublisher
4545from databuilder .task .task import DefaultTask
46+ from databuilder .task .search .search_metadata_to_elasticsearch_task import SearchMetadatatoElasticasearchTask
4647from databuilder .transformer .base_transformer import ChainedTransformer , NoopTransformer
4748from databuilder .transformer .complex_type_transformer import PARSING_FUNCTION , ComplexTypeTransformer
4849from databuilder .transformer .dict_to_model import MODEL_CLASS , DictToModel
@@ -675,6 +676,37 @@ def create_es_publisher_sample_job(
675676 return job
676677
677678
679+ def run_search_metadata_task (resource_type : str ):
680+ task_config = {
681+ f'task.search_metadata_to_elasticsearch.{ SearchMetadatatoElasticasearchTask .ENTITY_TYPE } ' :
682+ resource_type ,
683+ f'task.search_metadata_to_elasticsearch.{ SearchMetadatatoElasticasearchTask .ELASTICSEARCH_CLIENT_CONFIG_KEY } ' :
684+ es ,
685+ f'task.search_metadata_to_elasticsearch.{ SearchMetadatatoElasticasearchTask .ELASTICSEARCH_ALIAS_CONFIG_KEY } ' :
686+ f'{ resource_type } _search_index' ,
687+ 'extractor.search_data.entity_type' :
688+ resource_type ,
689+ 'extractor.search_data.extractor.nebula.nebula_endpoints' :
690+ nebula_endpoints ,
691+ 'extractor.search_data.extractor.nebula.nebula_auth_user' :
692+ nebula_user ,
693+ 'extractor.search_data.extractor.nebula.nebula_auth_pw' :
694+ nebula_password ,
695+ 'extractor.search_data.extractor.nebula.nebula_space' :
696+ nebula_space ,
697+ }
698+
699+ job_config = ConfigFactory .from_dict ({
700+ ** task_config ,
701+ })
702+
703+ extractor = NebulaSearchDataExtractor ()
704+ task = SearchMetadatatoElasticasearchTask (extractor = extractor )
705+
706+ job = DefaultJob (conf = job_config , task = task )
707+
708+ job .launch ()
709+
678710if __name__ == "__main__" :
679711 # Uncomment next line to get INFO level logging
680712 logging .basicConfig (level = logging .DEBUG )
@@ -785,6 +817,7 @@ def create_es_publisher_sample_job(
785817
786818 create_last_updated_job ().launch ()
787819
820+ # with ElasticsearchPublisher, which will be deprecated
788821 job_es_table = create_es_publisher_sample_job (
789822 elasticsearch_index_alias = 'table_search_index' ,
790823 elasticsearch_doc_type_key = 'table' ,
@@ -810,3 +843,7 @@ def create_es_publisher_sample_job(
810843 entity_type = 'dashboard' ,
811844 elasticsearch_mapping = DASHBOARD_ELASTICSEARCH_INDEX_MAPPING )
812845 job_es_dashboard .launch ()
846+
847+ # with SearchMetadatatoElasticasearchTask
848+ for resource_type in ['table' , 'dashboard' , 'user' , 'feature' ]:
849+ run_search_metadata_task (resource_type )
0 commit comments