Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions packages/neo4j/src/conceptGraphIndexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,22 @@ const FULLTEXT_INDEXES = [
];

export async function ensureConceptGraphIndexes(): Promise<void> {
for (const cypher of [...CONSTRAINTS, ...FULLTEXT_INDEXES]) {
try {
await _runCypher(cypher);
} catch (cause: unknown) {
const msg = cause instanceof Error ? cause.message : String(cause);
if (msg.includes("already exists") || msg.includes("EquivalentSchemaRuleAlreadyExists")) {
process.stderr.write(`[neo4j] concept-graph schema already present, skipping: ${cypher.slice(0, 60)}…\n`);
continue;
}
throw cause;
const results = await Promise.allSettled(
[...CONSTRAINTS, ...FULLTEXT_INDEXES].map((cypher) =>
_runCypher(cypher).catch((cause: unknown) => {
const msg = cause instanceof Error ? cause.message : String(cause);
if (msg.includes("already exists") || msg.includes("EquivalentSchemaRuleAlreadyExists")) {
process.stderr.write(`[neo4j] concept-graph schema already present, skipping: ${cypher.slice(0, 60)}…\n`);
return;
}
throw cause;
}),
),
);

for (const result of results) {
if (result.status === "rejected") {
throw result.reason;
}
}
}
26 changes: 16 additions & 10 deletions packages/neo4j/src/flatFolderIndexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,22 @@ const FULLTEXT_INDEXES = [
];

export async function ensureFlatFolderIndexes(): Promise<void> {
for (const cypher of [...CONSTRAINTS, ...FULLTEXT_INDEXES]) {
try {
await _runCypher(cypher);
} catch (cause: unknown) {
const msg = cause instanceof Error ? cause.message : String(cause);
if (msg.includes("already exists") || msg.includes("EquivalentSchemaRuleAlreadyExists")) {
process.stderr.write(`[neo4j] flat-folder schema already present, skipping: ${cypher.slice(0, 60)}…\n`);
continue;
}
throw cause;
const results = await Promise.allSettled(
[...CONSTRAINTS, ...FULLTEXT_INDEXES].map((cypher) =>
_runCypher(cypher).catch((cause: unknown) => {
const msg = cause instanceof Error ? cause.message : String(cause);
if (msg.includes("already exists") || msg.includes("EquivalentSchemaRuleAlreadyExists")) {
process.stderr.write(`[neo4j] flat-folder schema already present, skipping: ${cypher.slice(0, 60)}…\n`);
return;
}
throw cause;
}),
),
);

for (const result of results) {
if (result.status === "rejected") {
throw result.reason;
}
}
}
26 changes: 16 additions & 10 deletions packages/neo4j/src/indexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,22 @@ const FULLTEXT_INDEXES = [
];

export async function ensureKnowledgeIndexes(): Promise<void> {
for (const cypher of [...CONSTRAINTS, ...FULLTEXT_INDEXES]) {
try {
await _runCypher(cypher);
} catch (cause: unknown) {
const msg = cause instanceof Error ? cause.message : String(cause);
if (msg.includes("already exists") || msg.includes("EquivalentSchemaRuleAlreadyExists")) {
process.stderr.write(`[neo4j] schema already present, skipping: ${cypher.slice(0, 60)}…\n`);
continue;
}
throw cause;
const results = await Promise.allSettled(
[...CONSTRAINTS, ...FULLTEXT_INDEXES].map((cypher) =>
_runCypher(cypher).catch((cause: unknown) => {
const msg = cause instanceof Error ? cause.message : String(cause);
if (msg.includes("already exists") || msg.includes("EquivalentSchemaRuleAlreadyExists")) {
process.stderr.write(`[neo4j] schema already present, skipping: ${cypher.slice(0, 60)}…\n`);
return;
}
throw cause;
}),
),
);

for (const result of results) {
if (result.status === "rejected") {
throw result.reason;
}
}
}
Loading