es_put()

阅读(447) 标签: 执行put, 序表,

描述:

执行put指令,返回序表。

语法:

es_put(fd, endpoint, entityheader)

备注:

执行put指令,header可以省略;Rest Api 参数的地址可以到index,到type,或者到记录。

选项:

@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_put@f(A1, "/shirts", "D: /put_index.txt")

建立indexshirts的索引

3

=es_put@f(A1, "/shirts/doc/2", "D:/put_index_record.txt")

在新建的shirts索引typedoc中插入id2的记录

注:文件put_ index.txt内容:

{

"mappings": {

 "_doc": {

 "properties": {

 "brand": { "type": "keyword"},

 "color": { "type": "keyword"},

 "model": { "type": "keyword"}

}

}

}

}

文件put_shirt_ record.txt内容:

{

"brand": "coop",

 "color": "blue",

 "model": "girl"

}