Bulk indexing nested fields and it's effect on queues?

Question, when bulk indexing a document with nested fields, does each nested field(nested doc) take an entry in the bulk_queue?

Hey,

I am sorry but I don't know if understand your question right.

Regularly bulk works like this:

client.bulk({
  body: [
    // action description
    { index:  { _index: 'myindex', _type: 'mytype', _id: 1 } },
     // the document to index
    { title: 'foo' },
    // action description
    { update: { _index: 'myindex', _type: 'mytype', _id: 2 } },
    // the document to update
    { doc: { title: 'foo' } },
    // action description
    { delete: { _index: 'myindex', _type: 'mytype', _id: 3 } },
    // no document needed for this delete
  ]
}, function (err, resp) {
  // ...
});

So If you want to index multiple documents at once you do that with:

client.bulk({
  body: [
    // FIRST DOCUMENT -  action description (you want do index)
    { index:  { _index: 'myindex', _type: 'mytype', _id: 1 } },
     // the first document to index
    { title: 'foo' },
    // SECOND DOCUMENT -  action description (you want do index)
    { index:  { _index: 'myindex', _type: 'mytype', _id: 2 } },
     // the second document to index
    { title: 'bar' },
    (...)
  ]
}, function (err, resp) {
  // ...
});

So every document with its fields has to have two entries in the bulk array. First is action description with id, index and type and second is the document.

Does this answer your question?

Source: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html

My question is regarding nested types. Nested field type | Elasticsearch Guide [8.11] | Elastic or Nested Objects | Elasticsearch: The Definitive Guide [master] | Elastic

The nested type is a specialised version of the object datatype that allows arrays of objects to be indexed and queried independently of each other.
Internally, nested objects index each object in the array as a separate hidden document, meaning that each nested object can be queried independently of the others, with the nested query:

Because internally nested types are stored as separate documents I was wondering if inserting a document with N number of nested documents required N+1 queue slots or just 1.

for example with a mapping of:

PUT /my_index
{
"mappings": {
"blogpost": {
"properties": {
"comments": {
"type": "nested",
"properties": {
"name": { "type": "string" },
"comment": { "type": "string" },
"age": { "type": "short" },
"stars": { "type": "short" },
"date": { "type": "date" }
}
}
}
}
}
}

PUT /my_index/blogpost/1
{
"title": "Nest eggs",
"body": "Making your money work...",
"tags": [ "cash", "shares" ],
"comments": [
{
"name": "John Smith",
"comment": "Great article",
"age": 28,
"stars": 4,
"date": "2014-09-01"
},
{
"name": "Alice White",
"comment": "More like this please",
"age": 31,
"stars": 5,
"date": "2014-10-22"
}
]
}

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