es_rest()

Read(34) Label: rest, elasticsearch,

Description:

Handle data using Elasticsearch REST interface.

Syntax:

es_rest(url, method, content; httpHeader1, httpHeader2, …)

Note:

The external library handles data using Elasticsearch REST interface.

Parameters:

url

A URL file that supports both HTTP and HTTPS; different operations have their own extensions

method

An HTTP method, whose value can be GET/PUT/POST/DELETE

content

The to-be-submitted content an HTTP request contains; the parameter can be absent when an operation does not submit anything

httpHeader

An HTTP header, including information such as token for authenticating a user agent and specification of content format

Example:

 

A

 

1

>apikey="Authorization:ApiKey a2x6aEF……KZ29rT2hoQQ=="

Set API Key

2

'{

 

"counter" : 1,

 

"tags" : ["red"]

 

,"beginTime":"2022-01-03"

 

,"endTime":"2022-02-15"

 

}

 

3

=es_rest("https://localhost:9200/index1/_doc/1", "PUT",A2;"Content-Type: application/x-ndjson",apikey)

Execute write operation and list information in the HTTP response