@@ -510,21 +510,39 @@ fts_backend_solr_update_set_build_key(struct fts_backend_update_context *_ctx,
510510{
511511 struct solr_fts_backend_update_context * ctx =
512512 (struct solr_fts_backend_update_context * )_ctx ;
513+ struct solr_fts_backend * backend = (struct solr_fts_backend * )ctx -> ctx .backend ;
514+ struct fts_solr_user * fuser = FTS_SOLR_USER_CONTEXT (backend -> backend .ns -> user );
513515
514516 if (key -> uid != ctx -> prev_uid )
515517 fts_backend_solr_uid_changed (ctx , key -> uid );
516518
517- switch (key -> type ) {
518- case FTS_BACKEND_BUILD_KEY_HDR :
519+ bool want_indexed = FALSE;
520+ bool want_hdr = TRUE;
521+ if (key -> type == FTS_BACKEND_BUILD_KEY_HDR || key -> type == FTS_BACKEND_BUILD_KEY_MIME_HDR ) {
519522 if (fts_header_want_indexed (key -> hdr_name )) {
520- ctx -> cur_value2 =
521- fts_solr_field_get (ctx , key -> hdr_name );
523+ want_indexed = TRUE;
524+ } else if (fuser -> set .limit_mime_hdr ) {
525+ want_hdr = FALSE;
526+ }
527+
528+ if (!want_indexed && !want_hdr ) {
529+ return FALSE;
522530 }
531+ }
532+
533+ switch (key -> type ) {
534+ case FTS_BACKEND_BUILD_KEY_HDR :
535+ if (want_indexed )
536+ ctx -> cur_value2 = fts_solr_field_get (ctx , key -> hdr_name );
523537 /* fall through */
524538 case FTS_BACKEND_BUILD_KEY_MIME_HDR :
525539 ctx -> cur_value = fts_solr_field_get (ctx , "hdr" );
526- xml_encode (ctx -> cur_value , key -> hdr_name );
527- str_append (ctx -> cur_value , ": " );
540+ if (want_hdr ) {
541+ if (!fuser -> set .skip_mime_hdr_fieldname ) {
542+ xml_encode (ctx -> cur_value , key -> hdr_name );
543+ str_append (ctx -> cur_value , ": " );
544+ }
545+ }
528546 break ;
529547 case FTS_BACKEND_BUILD_KEY_BODY_PART :
530548 if (!ctx -> body_open ) {
@@ -843,7 +861,7 @@ fts_backend_solr_lookup(struct fts_backend *_backend, struct mailbox *box,
843861 if (solr_search (_backend , str , box_guid ,
844862 & result -> maybe_uids , & result -> scores ) < 0 )
845863 return -1 ;
846- }
864+ }
847865 result -> scores_sorted = TRUE;
848866 return 0 ;
849867}
0 commit comments