How to bulk insert documents?

(Frederes) #1


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

(Adrien Grand) #2

See 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.

(Frederes) #3

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)

(Adrien Grand) #4

This should be done at index creation time in the mappings section. See

(Frederes) #5

Ok, thanks.
What about templates ?

(Adrien Grand) #6

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

(system) #7