Alex Susanu

Es_1

https://www.elastic.co/guide/en/elasticsearch/reference/7.17/removal-of-types.html#removal-of-types

Specifying types in requests is deprecated. For instance, indexing a document no longer requires a document type. The new index APIs are PUT {index}/_doc/{id} in case of explicit ids and POST {index}/_doc for auto-generated ids. Note that in 7.0, _doc is a permanent part of the path, and represents the endpoint name rather than the document type.

curl -X POST localhost:9200/accounts/_doc/1 -H 'Content-Type: application/json' -d '
{
"name" : "John",
"lastname" : "Doe",
"job_description" : "Systems administrator and Linux specialit"
}'
curl -X GET localhost:9200/accounts/_doc/1
# update document with id 1
# note _doc is not used in the path, only when creating
curl -X POST localhost:9200/accounts/_update/1 -H 'Content-Type: application/json' -d '
{
      "doc":{
          "job_description" : "Systems administrator and Linux specialist"
       }
}'

# it will create a new document with id 2
curl -X POST localhost:9200/accounts/_doc/2 -H 'Content-Type: application/json' -d '
{
"name" : "John",
"lastname" : "Smith",
"job_description" : "Systems administrator"
}'
# get by id
curl -X GET localhost:9200/accounts/_doc/2
curl -X GET localhost:9200/_search?q=john
curl -X POST localhost:9200/accounts/_update/1 -H 'Content-Type: application/json' -d '
{
        "doc":{
          "job_description" : "Linux specialist"
         }
}'
curl -X DELETE localhost:9200/accounts/_doc/1