es_get ()

阅读(1911) 标签: 执行get, 序表, 游标,

描述:

执行get指令,返回序表或者游标。

语法:

es_get(fd, endpoint, entityheader)

备注:

外部库函数,外部库的使用请参考《外部库使用指南》。

通过get指令查询,缺省最大返回10条记录, 对于游标查询,返回记录数不受此约束;对于查询ES系统信息,返回记录数也不受此约束。若返回结果集json中包括多个_index,则采用展开方式显示Entity参数可省略
选项:

@c

游标查询,缺省返回所有记录。

@f

支持entity参数为文件。

参数:

fd

restclient对象。

endpoint

Rest Api 参数的地址。

entity

通过 http body 传递的参数,参数可以是符合json格式的字符串或内容为符合json格式的文件名。

header

一个可变参数,可以传入对应的 http 头信息,参数为符合json格式的键值类型字符串。

返回值:

序表/游标

示例:

 

A

 

1

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

连接ES server

2

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

值方式显示es server健康信息。

3

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

键值方式显示es server健康信息。

4

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

查询indexaccountstypepersonid1的记录。

5

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

游标形式查询indexaccountstypeperson的记录。

6

=A5.fetch()

返回游标记录。

7

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

查询/personids1, 2, 5的记录。

8

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

同上。

注:文件entity_docs_accounts.txt中的内容:

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