mirror of
https://github.com/mendableai/firecrawl.git
synced 2025-06-27 00:41:33 +00:00
feat(index): store short titles and descriptions (#1677)
This commit is contained in:
parent
9710bdffc0
commit
5ca8e2e98e
@ -60,6 +60,27 @@ export async function sendDocumentToIndex(meta: Meta, document: Document) {
|
|||||||
return document;
|
return document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let title = document.metadata.title ?? document.metadata.ogTitle ?? null;
|
||||||
|
let description = document.metadata.description ?? document.metadata.ogDescription ?? document.metadata.dcDescription ?? null;
|
||||||
|
|
||||||
|
if (typeof title === "string") {
|
||||||
|
title = title.trim();
|
||||||
|
if (title.length > 60) {
|
||||||
|
title = title.slice(0, 57) + "...";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
title = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof description === "string") {
|
||||||
|
description = description.trim();
|
||||||
|
if (description.length > 160) {
|
||||||
|
description = description.slice(0, 157) + "...";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
description = null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await addIndexInsertJob({
|
await addIndexInsertJob({
|
||||||
id: indexId,
|
id: indexId,
|
||||||
@ -82,6 +103,8 @@ export async function sendDocumentToIndex(meta: Meta, document: Document) {
|
|||||||
...a,
|
...a,
|
||||||
[`domain_splits_${i}_hash`]: x,
|
[`domain_splits_${i}_hash`]: x,
|
||||||
}), {})),
|
}), {})),
|
||||||
|
...(title ? { title } : {}),
|
||||||
|
...(description ? { description } : {}),
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
meta.logger.error("Failed to add document to index insert queue", {
|
meta.logger.error("Failed to add document to index insert queue", {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user