Skip to content

Commit

Permalink
reverting removal of createdIndex and createdPipelineId
Browse files Browse the repository at this point in the history
  • Loading branch information
jgowdyelastic committed Sep 27, 2024
1 parent 33974d4 commit 5a06661
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions x-pack/plugins/file_upload/server/import_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ export function importDataProvider({ asCurrentUser }: IScopedClusterClient) {
ingestPipeline: IngestPipelineWrapper | undefined,
data: InputData
): Promise<ImportResponse> {
let createdIndex;
let createdPipelineId;
const docCount = data.length;
const pipelineId = ingestPipeline?.id;
const pipeline = ingestPipeline?.pipeline;

try {
const pipelineId = ingestPipeline?.id;
const pipeline = ingestPipeline?.pipeline;

if (id === undefined) {
// first chunk of data, create the index and id to return
id = generateId();

await createIndex(index, settings, mappings);
createdIndex = index;

// create the pipeline if one has been supplied
if (pipelineId !== undefined) {
Expand All @@ -42,11 +46,15 @@ export function importDataProvider({ asCurrentUser }: IScopedClusterClient) {
throw resp;
}
}
createdPipelineId = pipelineId;
} else {
createdIndex = index;
createdPipelineId = pipelineId;
}

let failures: ImportFailure[] = [];
if (data.length) {
const resp = await indexData(index, pipelineId, data);
const resp = await indexData(index, createdPipelineId, data);
if (resp.success === false) {
if (resp.ingestError) {
// all docs failed, abort
Expand All @@ -62,17 +70,17 @@ export function importDataProvider({ asCurrentUser }: IScopedClusterClient) {
return {
success: true,
id,
index,
pipelineId,
index: createdIndex,
pipelineId: createdPipelineId,
docCount,
failures,
};
} catch (error) {
return {
success: false,
id: id!,
index,
pipelineId,
index: createdIndex,
pipelineId: createdPipelineId,
error: error.body !== undefined ? error.body : error,
docCount,
ingestError: error.ingestError,
Expand Down

0 comments on commit 5a06661

Please sign in to comment.