Home / Documentation / REST APIs / Bulk Models API

Bulk Models API

Performs multiple Models API operations in series. Supported operations include: "create", "update", "delete"

POST _zentity/models/_bulk
{ OPERATION: PARAMETERS }
ENTITY_MODEL
...

The _bulk endpoint requires NDJSON syntax. The payload consists of pairs of lines. Each pair represents a single operation. The first line of the pair describes the operation and its parameters. The second line contains the entity model, or an empty object ({}) for "delete" operations. Each line must be an unindented JSON object.

The supported values for OPERATION are:

Example Request

This example performs three Models API operations in series. The first request creates an empty entity model for a "person" entity type. The second operation updates the entity model by adding an attribute called "first_name". The third operation deletes the entity model.

POST _zentity/models/_bulk
{"create":{"entity_type":"person"}}
{"attributes":{},"resolvers":{},"matchers":{},"indices":{}}
{"update":{"entity_type":"person"}}
{"attributes":{"first_name":{}},"resolvers":{},"matchers":{},"indices":{}}
{"delete":{"entity_type":"person"}}
{}

Example Response

{
  "took": 208,
  "errors": false,
  "items": [
    {
      "create": {
        "_index": ".zentity-models",
        "_id": "person",
        "_version": 1,
        "result": "created",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "_seq_no": 1,
        "_primary_term": 3
      }
    },
    {
      "update": {
        "_index": ".zentity-models",
        "_id": "person",
        "_version": 2,
        "result": "updated",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "_seq_no": 1,
        "_primary_term": 3
      }
    },
    {
      "delete": {
        "_index": ".zentity-models",
        "_id": "person",
        "_version": 3,
        "result": "deleted",
        "_shards": {
          "total": 2,
          "successful": 1,
          "failed": 0
        },
        "_seq_no": 1,
        "_primary_term": 3
      }
    }
  ]
}

HTTP Headers

Header Value
Content-Type application/x-ndjson

URL Parameters

Parameter Type Default Required Description
pretty Boolean false No Indents the JSON response data.

Notes

The _bulk endpoint optimizes performance in three ways:

 


Continue Reading

Models API Resolution API
© 2018 - 2024 Dave Moore.
Licensed under the Apache License, Version 2.0.
Elasticsearch is a trademark of Elasticsearch BV.
This website uses Google Analytics.