Bulk index app search API

Hello!
First and foremost I wonder if the bulk-API applies to Elastic AppSearch?

If so, the bulk API for indexing requires data in the following format:

{ "index" : { "_index" : "test", "_id" : "1" } }
{ "field1" : "value1" }

I have not explicitly created an index for my app search, so I wonder how I would format the index row? Would it work to do it like this?: (Removing the _index field)
{ "index" : { "_id" : "1" } }
{ "field1" : "value1" }

Best,
Axel

Hi @Meurling ,

We never recommend indexing data into AppSearch indices directly. Those indices are internal, their schema and settings can change with any release, and you can't expect your code to keep working if that happens.

However, AppSearch has its own API that you can call to index multiple documents. See documentation here:

Example request to index 3 documents:

curl -X POST 'https://[instance id].ent-search.[region].[provider].cloud.es.io/api/as/v1/engines/my-engine-name/documents' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer private-xxxxxxxxxxxxxxxxxxxx' \
-d '[
  {"id": "1", "field1": "value1"},
  {"id": "2", "field1": "value2"},
  {"id": "3", "field1": "value3"}
]'

Note that AppSearch has some limits on the size of a bulk request, and those may not be the same as limits that Elasticsearch sets on bulk requests. Currently they are:

  • There is a 100 document per request limit.
  • Each document must be less than 100kb.
  • The indexing request may not exceed 10mb.

When using the API that AppSearch provides, you don't need to worry about creating indices, AppSearch will do that for you on your first indexing request.

Refer to the documentation link above for more information.

I hope this helps.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.