es_get()

Read(2391) Label: execute get, table sequence, cursor,

Description:

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

Syntax:

es_get(fd, endpoint, entityheader)

Note:

The external library function (See External Library Guide) queries data through a get command and by default returns 10 records at most. There is no restriction about the number of returned records when the function queries a cursor or the ES system. 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 and by default return all records

@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 ES server.

2

=es_get(A1, "/_cat/health")

Display the health data retrieved from ES server by complete values.

3

=es_get(A1, "/_cat/health?v")

Display the health data retrieved from ES server by key values.

4

=es_get(A1,"/accounts/person/1")

Query the record where index is accounts, type is person and id is 1.

5

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

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

6

=A5.fetch()

Return records fetched from the cursor.

7

=es_get(A1,"/person/_mget","{\"ids\":[\"1\",\"2\",\"5\"]}")

Query in /person the records where ids is 1,2 and 5.

8

=es_get@f(A1,"/person/_mget","D:/entity_docs_accounts.txt")

Same as the previous.

Note: Here’s the file entity_docs_accounts.txt:

{"ids" : ["1", "2", "5"]}