@@ -112,27 +112,33 @@ void IBulkOperation.PrepareIndex(IndexName? bulkRequestIndex)
112112
113113 private void ResolveIndex ( IElasticsearchClientSettings settings )
114114 {
115- if ( _bulkRequestIndex is not null )
116- {
117- var resolvedBulkIndex = settings . Inferrer . IndexName ( _bulkRequestIndex ) ;
118-
119- string ? inferredIndex ;
120- if ( Index is not null )
121- inferredIndex = settings . Inferrer . IndexName ( Index ) ;
122- else if ( ClrType is not null )
123- inferredIndex = settings . Inferrer . TryIndexName ( ClrType ) ;
124- else
125- inferredIndex = null ;
126-
127- if ( inferredIndex is null || inferredIndex == resolvedBulkIndex )
128- Index = null ;
129- else
130- Index = inferredIndex ;
131- }
132- else
115+ // Index resolution follows a strict hierarchy:
116+ // 1. Explicit per-operation Index (highest priority)
117+ // 2. Bulk request URL-level index
118+ // 3. CLR type inference via DefaultMappingFor<T> / DefaultIndex (lowest priority)
119+
120+ // When no bulk request index exists, fall back to CLR type inference
121+ // so the operation can resolve its index from settings (DefaultMappingFor / DefaultIndex).
122+ if ( _bulkRequestIndex is null )
133123 {
134124 Index ??= ClrType ;
125+ return ;
135126 }
127+
128+ // When a bulk request index is set but the operation has no explicit index,
129+ // the bulk request index takes precedence — leave Index null so the
130+ // URL-level index applies. Do not infer from ClrType here, as that would
131+ // allow DefaultIndex to override the explicit bulk request index.
132+ if ( Index is null )
133+ return ;
134+
135+ // When the operation has an explicit index, resolve both to compare.
136+ // If they match, clear the per-operation index to avoid redundancy in the
137+ // serialized body. If they differ, keep the per-operation override.
138+ var resolvedBulkIndex = settings . Inferrer . IndexName ( _bulkRequestIndex ) ;
139+ var resolvedIndex = settings . Inferrer . IndexName ( Index ) ;
140+
141+ Index = resolvedIndex == resolvedBulkIndex ? null : resolvedIndex ;
136142 }
137143
138144 /// <inheritdoc />
0 commit comments