Skip to content

Commit

Permalink
fix document import
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Sep 27, 2024
1 parent 3efe114 commit c3f04f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async function installKibanaKnowledgeBaseEntry(
await savedObjectsClient.create(
knowledgeBaseEntrySavedObjectType,
{
// TODO: update the mappings / props once the KB PR has been merged
// TODO: update the props to the full set once the KB PR has been merged
name: entry.manifest.name,
type: 'index',
description: entry.manifest.description,
Expand All @@ -133,9 +133,13 @@ const indexContentFile = async ({
}) => {
const fileContent = contentBuffer.toString('utf-8');
const lines = fileContent.split('\n');
const documents = lines.map((line) => {
return JSON.parse(line.trim());
});

const documents = lines
.map((line) => line.trim())
.filter((line) => line.length > 0)
.map((line) => {
return JSON.parse(line);
});

const operations = documents.reduce((ops, document) => {
ops!.push(...[{ index: { _index: indexName } }, document]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const entryPathsFromManifestPath = (manifestPath: string) => {
const splits = manifestPath.split('/');
const rootFolderPath = splits.slice(0, splits.length - 1).join('/');
const entryName = splits[splits.length - 2];
const contentFolderPath = [...rootFolderPath, 'content'].join('/');
const contentFolderPath = [rootFolderPath, 'content'].join('/');

return {
entryName,
Expand Down

0 comments on commit c3f04f9

Please sign in to comment.