Skip to content

Commit

Permalink
Fix bulk indexing batches
Browse files Browse the repository at this point in the history
  • Loading branch information
rudolf committed May 24, 2023
1 parent 1314315 commit 2c57bc0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('createBatches', () => {
expect(
createBatches({
documents,
maxBatchSizeBytes: (DOCUMENT_SIZE_BYTES + 43) * 2, // add extra length for 'index' property
maxBatchSizeBytes: (DOCUMENT_SIZE_BYTES + 49) * 2, // add extra length for 'index' property
typeIndexMap: buildTempIndexMap(
{
'.kibana': ['dashboard'],
Expand All @@ -108,7 +108,7 @@ describe('createBatches', () => {
{
index: {
_id: '',
_index: '.kibana_8.8.0_reindex_temp',
_index: '.kibana_8.8.0_reindex_temp_alias',
},
},
{ type: 'dashboard', title: 'my saved object title ¹' },
Expand All @@ -117,7 +117,7 @@ describe('createBatches', () => {
{
index: {
_id: '',
_index: '.kibana_8.8.0_reindex_temp',
_index: '.kibana_8.8.0_reindex_temp_alias',
},
},
{ type: 'dashboard', title: 'my saved object title ²' },
Expand All @@ -128,7 +128,7 @@ describe('createBatches', () => {
{
index: {
_id: '',
_index: '.kibana_cases_8.8.0_reindex_temp',
_index: '.kibana_cases_8.8.0_reindex_temp_alias',
},
},
{ type: 'cases', title: 'a case' },
Expand All @@ -137,7 +137,7 @@ describe('createBatches', () => {
{
index: {
_id: '',
_index: '.kibana_cases_8.8.0_reindex_temp',
_index: '.kibana_cases_8.8.0_reindex_temp_alias',
},
},
{ type: 'cases-comments', title: 'a case comment #1' },
Expand All @@ -148,7 +148,7 @@ describe('createBatches', () => {
{
index: {
_id: '',
_index: '.kibana_cases_8.8.0_reindex_temp',
_index: '.kibana_cases_8.8.0_reindex_temp_alias',
},
},
{ type: 'cases-user-actions', title: 'a case user action' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ describe('createBulkIndexOperationTuple', () => {
Object {
"index": Object {
"_id": "",
"_index": ".kibana_cases_8.8.0_reindex_temp",
"_index": ".kibana_cases_8.8.0_reindex_temp_alias",
},
},
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,9 @@ export const createBulkIndexOperationTuple = (
{
index: {
_id: doc._id,
...(typeIndexMap[doc._source.type] && { _index: typeIndexMap[doc._source.type] }),
...(typeIndexMap[doc._source.type] && {
_index: typeIndexMap[doc._source.type] + '_alias',
}),
// use optimistic concurrency control to ensure that outdated
// documents are only overwritten once with the latest version
...(typeof doc._seq_no !== 'undefined' && { if_seq_no: doc._seq_no }),
Expand Down

0 comments on commit 2c57bc0

Please sign in to comment.