Best practice for indexing and filtering different contents #699
-
Hi everyone, after trying out Pagefind with AstroJS and reading throught the documentation (especially Node-API, Filtering and Multisite), I am struggling on how to index & filter different contents independently and bundle them all together on one site. Heres what I want to index:
Now I would like to implement different searches on my site, searching only for the relevant indexes like:
What I've tried so far:
Then for example on the new PagefindUI({
element: "#search",
mergeFilter: {
resource: "Content"
},
mergeIndex: [{
bundlePath: "/pagefind-product",
mergeFilter: {
resource: "Product"
}
}],
showSubResults: true,
showImages: true,
processResult: function (result: any) {
console.log("pagefind result", result);
return result;
}
}); But I get the following error: pagefind.js:1 Failed to load Pagefind metadata:
SyntaxError: Unexpected end of JSON input
loadEntry @ pagefind.js:1
await in loadEntry
init @ pagefind.js:1
mergeIndex @ pagefind.js:9
await in mergeIndex
mergeIndex @ pagefind.js:9
an @ pagefind-ui.js:2
pagefind.js:2 Uncaught (in promise) Error: Failed to load Pagefind metadata
at PagefindInstance.loadEntry (pagefind.js:2:26)
at async PagefindInstance.init (pagefind.js:1:19619)
at async Pagefind.mergeIndex (pagefind.js:9:1860)
at async Module.mergeIndex (pagefind.js:9:3826)
at async HTMLInputElement.an (pagefind-ui.js:2:210) What also confused me is that using the Node-API only will generate empty files for Would love to hear your feedback or even sample code/projects of people that may already implemented such a usecase. Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @codejanovic 👋 For this use-case I would usually just generate a single Pagefind instance with filtering to demarcate each specific search. Searching as one combined index has better (network) performance than the merged-index style, so when it's possible to do it's always preferred. The NodeJS API can be used for it all, both ingesting current content and merging it with the standard directory-crawl behavior.
Oop — if true that's definitely a bug 🤔 I'll add an integration test for the node api / ui crossover and see if it smokes anything out. |
Beta Was this translation helpful? Give feedback.
Hi @codejanovic 👋
For this use-case I would usually just generate a single Pagefind instance with filtering to demarcate each specific search. Searching as one combined index has better (network) performance than the merged-index style, so when it's possible to do it's always preferred. The NodeJS API can be used for it all, both ingesting current content and merging it with the standard directory-crawl behavior.
Oop — if true that's definitely a bug 🤔 I'll add an integration test for the node api / ui crossov…