es_post()

Read(2768) Label: execute post, table sequence, cursor,

Description:

Execute the post command and return a table sequence or a cursor.

Syntax:

es_post(fd, endpoint, entityheader)

Note:

The external library function (See External Library Guide) queries data through the post command and by default returns 10 records at most. If the JSON data in the result set contains multiple _index, they will be fully displayed. Parameter entity can be omitted.

Option:

@c

Query a cursor

@f

Parameter entity can be a file

Parameter:

fd

A REST Client object

endpoint

Rest API address

entity

A parameter transmitted through http body, which is a JSON string or the name of JSON file

header

A variable parameter that passes http header; it is a key type JSON string

Return value:

A table sequence/cursor

Example:

 

A

 

1

=es_open("localhost:9200 ","user":"un1234")

Connect to the ES server.

2

=es_post(A1,"/accounts/_search?q=user:kimchy")

Query in the bank index the record where user is kimchy.

3

=es_post(A1,"/_all/_search?q=_id:5")

Query the record where _id is 5 across different databases.

4

=es_post@c(A1,"/accounts/person/_search")

Query records where index is accounts and type is person via the cursor.

5

=A4.fetch()

Return records fetched from the cursor.

6

=es_post@f(A1,"/bank/person/_search","D:/entity_post_accounts.txt")

Parameter entity is a file, from which the function queries records where _gender=“F” under /bank/person and sort them.

Note: Here’s the file entity_post_accounts.txt:
{

  "query" : {

  "match" : { "gender" : "F" }

  },

  "track_scores": true,

  "sort" : [

  { "account_number" : {"order" : "desc"} },

  { "firstname" : "desc" },

  { "lastname" : "desc" }

  ]

}