Skip to content

Instantly share code, notes, and snippets.

@secabstraction
Last active February 16, 2016 18:42
Show Gist options
  • Save secabstraction/883f0af456c54678add4 to your computer and use it in GitHub Desktop.
Save secabstraction/883f0af456c54678add4 to your computer and use it in GitHub Desktop.
begin { $JsonStrings = [Collections.Generic.List[String]]::new() }
process {
foreach ($Object in $InputObject) {
$IndexProperties = @{
index = @{
_index = $Index
_type = $Type
_id = $Id
}
}
$IndexMarker = $IndexProperties | ConvertTo-Json -Compress
$Document = $Object | ConvertTo-Json -Compress
# Elastic bulk index format
$JsonStrings.Add("$IndexMarker`n$Document`n")
}
}
end { Write-Output (-join $JsonStrings) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment