@@ -31,6 +31,12 @@ public interface IBulkUpdateOperation<TDocument, TPartialDocument> : IBulkOperat
3131 /// </summary>
3232 bool ? DocAsUpsert { get ; set ; }
3333
34+ /// <summary>
35+ /// If you would like your script to run regardless of whether the document exists or not — i.e. the script handles
36+ /// initializing the document instead of the upsert element — then set scripted_upsert to true
37+ /// </summary>
38+ bool ? ScriptedUpsert { get ; set ; }
39+
3440 /// <summary>
3541 /// A script to specify the update.
3642 /// </summary>
@@ -109,6 +115,12 @@ protected override object GetBody() =>
109115 /// </summary>
110116 public bool ? DocAsUpsert { get ; set ; }
111117
118+ /// <summary>
119+ /// If you would like your script to run regardless of whether the document exists or not — i.e. the script handles
120+ /// initializing the document instead of the upsert element — then set scripted_upsert to true
121+ /// </summary>
122+ public bool ? ScriptedUpsert { get ; set ; }
123+
112124 /// <summary>
113125 /// A script to specify the update.
114126 /// </summary>
@@ -128,6 +140,7 @@ public class BulkUpdateDescriptor<TDocument, TPartialDocument>
128140 TDocument IBulkUpdateOperation < TDocument , TPartialDocument > . Upsert { get ; set ; }
129141 TPartialDocument IBulkUpdateOperation < TDocument , TPartialDocument > . Doc { get ; set ; }
130142 bool ? IBulkUpdateOperation < TDocument , TPartialDocument > . DocAsUpsert { get ; set ; }
143+ bool ? IBulkUpdateOperation < TDocument , TPartialDocument > . ScriptedUpsert { get ; set ; }
131144 IScript IBulkUpdateOperation < TDocument , TPartialDocument > . Script { get ; set ; }
132145
133146 protected override object GetBulkOperationBody ( ) =>
@@ -136,7 +149,8 @@ protected override object GetBulkOperationBody() =>
136149 _PartialUpdate = Self . Doc ,
137150 _Script = Self . Script ,
138151 _Upsert = Self . Upsert ,
139- _DocAsUpsert = Self . DocAsUpsert
152+ _DocAsUpsert = Self . DocAsUpsert ,
153+ _ScriptedUpsert = Self . ScriptedUpsert
140154 } ;
141155
142156 protected override Id GetIdForOperation ( Inferrer inferrer ) =>
@@ -171,6 +185,13 @@ public BulkUpdateDescriptor<TDocument, TPartialDocument> DocAsUpsert(bool partia
171185 Assign ( a => a . DocAsUpsert = partialDocumentAsUpsert ) ;
172186
173187 /// <summary>
188+ /// If you would like your script to run regardless of whether the document exists or not — i.e. the script handles
189+ /// initializing the document instead of the upsert element — then set scripted_upsert to true
190+ /// </summary>
191+ /// <summary>
192+ public BulkUpdateDescriptor < TDocument , TPartialDocument > ScriptedUpsert ( bool scriptedUpsert = true ) =>
193+ Assign ( a => a . ScriptedUpsert = scriptedUpsert ) ;
194+
174195 /// A script to specify the update.
175196 /// </summary>
176197 public BulkUpdateDescriptor < TDocument , TPartialDocument > Script ( Func < ScriptDescriptor , IScript > scriptSelector ) =>
0 commit comments