@@ -17,9 +17,10 @@ use kamu_search::*;
1717////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1818
1919pub ( crate ) async fn index_dataset_from_scratch (
20+ indexer_config : & SearchIndexerConfig ,
2021 dataset : ResolvedDataset ,
2122 owner_id : & odf:: AccountID ,
22- ) -> Result < serde_json:: Value , InternalError > {
23+ ) -> Result < Option < serde_json:: Value > , InternalError > {
2324 // Find key blocks that contribute to search
2425 let mut attachments_visitor = odf:: dataset:: SearchSetAttachmentsVisitor :: new ( ) ;
2526 let mut info_visitor = odf:: dataset:: SearchSetInfoVisitor :: new ( ) ;
@@ -46,6 +47,17 @@ pub(crate) async fn index_dataset_from_scratch(
4647 let ( description, keywords) = extract_description_and_keywords ( info_visitor) ;
4748 let attachments = extract_attachment_contents ( attachments_visitor) ;
4849
50+ // Apply indexing configuration filters
51+ if indexer_config. skip_datasets_with_no_data && !schema_fields. is_present ( ) {
52+ return Ok ( None ) ;
53+ }
54+ if indexer_config. skip_datasets_with_no_description
55+ && !description. is_present ( )
56+ && !attachments. is_present ( )
57+ {
58+ return Ok ( None ) ;
59+ }
60+
4961 // Seed event: created_at
5062 let seed_event_time = seed_visitor. into_block ( ) . unwrap ( ) . system_time ;
5163
@@ -91,7 +103,7 @@ pub(crate) async fn index_dataset_from_scratch(
91103 index_doc_mut. insert ( fields:: ATTACHMENTS . to_string ( ) , serde_json:: json!( v) ) ;
92104 }
93105
94- Ok ( index_doc)
106+ Ok ( Some ( index_doc) )
95107 }
96108
97109 Err ( e) => Err ( e. int_err ( ) ) ,
@@ -101,11 +113,12 @@ pub(crate) async fn index_dataset_from_scratch(
101113////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
102114
103115pub ( crate ) async fn partial_update_for_new_interval (
116+ indexer_config : & SearchIndexerConfig ,
104117 dataset : ResolvedDataset ,
105118 owner_id : & odf:: AccountID ,
106119 new_head : & odf:: Multihash ,
107120 maybe_prev_head : Option < & odf:: Multihash > ,
108- ) -> Result < serde_json:: Value , InternalError > {
121+ ) -> Result < Option < serde_json:: Value > , InternalError > {
109122 // Extract key blocks that contribute to search
110123 let mut attachments_visitor = odf:: dataset:: SearchSetAttachmentsVisitor :: new ( ) ;
111124 let mut info_visitor = odf:: dataset:: SearchSetInfoVisitor :: new ( ) ;
@@ -136,7 +149,7 @@ pub(crate) async fn partial_update_for_new_interval(
136149 match result {
137150 Ok ( _) => { }
138151 Err ( AcceptVisitorError :: Traversal ( IterBlocksError :: InvalidInterval ( _) ) ) => {
139- return index_dataset_from_scratch ( dataset, owner_id) . await ;
152+ return index_dataset_from_scratch ( indexer_config , dataset, owner_id) . await ;
140153 }
141154 Err ( e) => return Err ( e. int_err ( ) ) ,
142155 }
@@ -170,7 +183,7 @@ pub(crate) async fn partial_update_for_new_interval(
170183 insert_search_incremental_update_field ( & mut update, fields:: KEYWORDS , keywords) ;
171184 insert_search_incremental_update_field ( & mut update, fields:: ATTACHMENTS , attachments) ;
172185
173- Ok ( serde_json:: Value :: Object ( update) )
186+ Ok ( Some ( serde_json:: Value :: Object ( update) ) )
174187}
175188
176189////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -270,6 +283,7 @@ pub(crate) async fn index_datasets(
270283 dataset_entry_service : & dyn DatasetEntryService ,
271284 dataset_registry : & dyn DatasetRegistry ,
272285 search_repo : & dyn SearchRepository ,
286+ indexer_config : & SearchIndexerConfig ,
273287) -> Result < usize , InternalError > {
274288 const BULK_SIZE : usize = 500 ;
275289
@@ -288,7 +302,8 @@ pub(crate) async fn index_datasets(
288302 . int_err ( ) ?;
289303
290304 // Index dataset
291- let dataset_document = index_dataset_from_scratch ( dataset, & entry. owner_id ) . await ?;
305+ let dataset_document =
306+ index_dataset_from_scratch ( indexer_config, dataset, & entry. owner_id ) . await ?;
292307 let dataset_document_json = serde_json:: to_value ( dataset_document) . int_err ( ) ?;
293308
294309 tracing:: debug!(
0 commit comments