Description:
Execute the put command and return a table sequence.
Syntax:
es_put(fd, endpoint, entity,header)
Note:
The external library function (See External Library Guide) executes the put command. Parameter header can be omitted; the REST API address can reach the index, the type or the record.
Option:
@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
Example:
|
A |
|
1 |
=es_open("localhost:9200","user":"un1234") |
Connect to the ES server. |
2 |
=es_put@f(A1, "/shirts", "D: /put_index.txt") |
Create an index for records under the shirts index. |
3 |
=es_put@f(A1, "/shirts/doc/2", "D:/put_index_record.txt") |
Insert a record whose id is 2 under doc type in the newly-created shirts index. |
Note: Here’s the file put_ index.txt:
{
"mappings": {
"_doc": {
"properties": {
"brand": { "type": "keyword"},
"color": { "type": "keyword"},
"model": { "type": "keyword"}
}
}
}
}
The file put_shirt_ record.txt:
{
"brand": "coop",
"color": "blue",
"model": "girl"
}