How to bulk insert documents?

Hello,

I need to index a lot of documents (types) into my index, what is the best mehod ? bulk ?
How do i pass all the document fields to the bulk statement ? (because in the doc i only see '_id')
thank you

See https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html. You need to pass a body that contains a number of lines that is a multiple of 2. Every even line contains metadata about the document (its id, which index it should go into, etc.) and every odd line contains the source of the json document that you want to index.

Thank you for your quick response :slight_smile:
OK, i just tested it works.
How do i specify the type of the fields in the index ? (string, float, date etc)

This should be done at index creation time in the mappings section. See https://www.elastic.co/guide/en/elasticsearch/reference/2.4/indices-create-index.html#mappings

Ok, thanks.
What about templates ?

Templates are fine too, they are a way to autematically put mappings at index creation time.