43
43
from databuilder .publisher .elasticsearch_publisher import ElasticsearchPublisher
44
44
from databuilder .publisher .nebula_csv_publisher import NebulaCsvPublisher
45
45
from databuilder .task .task import DefaultTask
46
+ from databuilder .task .search .search_metadata_to_elasticsearch_task import SearchMetadatatoElasticasearchTask
46
47
from databuilder .transformer .base_transformer import ChainedTransformer , NoopTransformer
47
48
from databuilder .transformer .complex_type_transformer import PARSING_FUNCTION , ComplexTypeTransformer
48
49
from databuilder .transformer .dict_to_model import MODEL_CLASS , DictToModel
@@ -675,6 +676,37 @@ def create_es_publisher_sample_job(
675
676
return job
676
677
677
678
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
+
678
710
if __name__ == "__main__" :
679
711
# Uncomment next line to get INFO level logging
680
712
logging .basicConfig (level = logging .DEBUG )
@@ -785,6 +817,7 @@ def create_es_publisher_sample_job(
785
817
786
818
create_last_updated_job ().launch ()
787
819
820
+ # with ElasticsearchPublisher, which will be deprecated
788
821
job_es_table = create_es_publisher_sample_job (
789
822
elasticsearch_index_alias = 'table_search_index' ,
790
823
elasticsearch_doc_type_key = 'table' ,
@@ -810,3 +843,7 @@ def create_es_publisher_sample_job(
810
843
entity_type = 'dashboard' ,
811
844
elasticsearch_mapping = DASHBOARD_ELASTICSEARCH_INDEX_MAPPING )
812
845
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