Skip to content

Instantly share code, notes, and snippets.

@TomonoriSoejima
Last active November 6, 2020 07:23
Show Gist options
  • Save TomonoriSoejima/a64b3b3ac8f4f38976dea6748f83755d to your computer and use it in GitHub Desktop.
Save TomonoriSoejima/a64b3b3ac8f4f38976dea6748f83755d to your computer and use it in GitHub Desktop.
_msearch sample in powershell
$USER = "elastic"
$PASS = "changeme"
$secpasswd = ConvertTo-SecureString $PASS -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($USER, $secpasswd)


$uri = "http://localhost:9200/_msearch"

# make sure to add extra epmty line in $body
$body = '
{"index":"hotel","ignore_unavailable":true,"preference":1499950407224}
{"query":{"bool":{"must":[{"query_string":{"query":"*","analyze_wildcard":true}},{"query_string":{"query":"*","analyze_wildcard":true}}],"must_not":[]}},"size":0,"_source":{"excludes":[]},"aggs":{},"version":true,"highlight":{"pre_tags":["@kibana-highlighted-field@"],"post_tags":["@/kibana-highlighted-field@"],"fields":{"*":{"highlight_query":{"bool":{"must":[{"query_string":{"query":"*","analyze_wildcard":true,"all_fields":true}},{"query_string":{"query":"*","analyze_wildcard":true,"all_fields":true}}],"must_not":[]}}}},"fragment_size":2147483647}}


'

$result = Invoke-RestMethod -Method Post -Uri $uri -Credential $cred  -ContentType 'application/x-ndjson' -Body $body

$result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment