Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Nest/Document/Multiple/Bulk/BulkOperation/BulkUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public interface IBulkUpdateOperation<TDocument, TPartialDocument> : IBulkOperat
/// </summary>
bool? DocAsUpsert { get; set; }

/// <summary>
/// If you would like your script to run regardless of whether the document exists or not — i.e. the script handles
/// initializing the document instead of the upsert element — then set scripted_upsert to true
/// </summary>
bool? ScriptedUpsert { get; set; }

/// <summary>
/// The script language to use
/// </summary>
Expand Down Expand Up @@ -130,6 +136,9 @@ protected override object GetBody() =>
/// </summary>
public bool? DocAsUpsert { get; set; }

/// <inheritdoc/>
public bool? ScriptedUpsert { get; set; }

/// <summary>
/// The script language to use
/// </summary>
Expand Down Expand Up @@ -201,6 +210,7 @@ public class BulkUpdateDescriptor<TDocument, TPartialDocument>
TDocument IBulkUpdateOperation<TDocument, TPartialDocument>.Upsert { get; set; }
TPartialDocument IBulkUpdateOperation<TDocument, TPartialDocument>.Doc { get; set; }
bool? IBulkUpdateOperation<TDocument, TPartialDocument>.DocAsUpsert { get; set; }
bool? IBulkUpdateOperation<TDocument, TPartialDocument>.ScriptedUpsert { get; set; }
string IBulkUpdateOperation<TDocument, TPartialDocument>.Lang { get; set; }
string IBulkUpdateOperation<TDocument, TPartialDocument>.Script { get; set; }
string IBulkUpdateOperation<TDocument, TPartialDocument>.ScriptId { get; set; }
Expand All @@ -214,7 +224,8 @@ protected override object GetBulkOperationBody() =>
_PartialUpdate = Self.Doc,
_Script = CreateScriptFromProperties(),
_Upsert = Self.Upsert,
_DocAsUpsert = Self.DocAsUpsert
_DocAsUpsert = Self.DocAsUpsert,
_ScriptedUpsert = Self.ScriptedUpsert
};

protected override Id GetIdForOperation(Inferrer inferrer) => Self.Id ?? new Id(new[] { Self.InferFrom, Self.Upsert }.FirstOrDefault(o=>o != null));
Expand Down Expand Up @@ -246,6 +257,9 @@ public BulkUpdateDescriptor<TDocument, TPartialDocument> IdFrom(TDocument @objec
/// </summary>
public BulkUpdateDescriptor<TDocument, TPartialDocument> DocAsUpsert(bool partialDocumentAsUpsert = true) => Assign(a => a.DocAsUpsert = partialDocumentAsUpsert);

/// <inheritdoc/>
public BulkUpdateDescriptor<TDocument, TPartialDocument> ScriptedUpsert(bool scriptedUpdate = true) => Assign(a => a.ScriptedUpsert = scriptedUpdate);

/// <summary>
/// The script language to use
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ internal class BulkUpdateBody<TDocument, TPartialUpdate>

[JsonProperty("script")]
internal IScript _Script { get; set; }

[JsonProperty("scripted_upsert")]
public bool? _ScriptedUpsert { get; set; }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be internal

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in 72f058f

}
}