I just installed search plugin and made this basic configuration
searchPlugin({
collections: ["universities", "colleges", "schools"],
defaultPriorities: {
universities: ({ doc }) => doc.ratings.overall_rating,
colleges: ({ doc }) => doc.ratings.overall_rating,
schools: ({ doc }) => doc.ratings.overall_rating,
},
searchOverrides: {
slug: "search-results",
},
beforeSync: ({ originalDoc, searchDoc }) => {
return {
...searchDoc,
slug: originalDoc.slug,
name: originalDoc.institution_name,
};
},
}),And when I started the dev server it immediately started throwing this error
Import trace for requested module:
./node_modules/@payloadcms/ui/dist/providers/ComponentMap/buildComponentMap/fields.js
./node_modules/@payloadcms/ui/dist/utilities/buildComponentMap.js
./node_modules/@payloadcms/richtext-lexical/dist/generateComponentMap.js
./node_modules/@payloadcms/richtext-lexical/dist/index.js
./payload.config.ts
./app/(payload)/api/[...slug]/route.ts
⨯ ./node_modules/@payloadcms/ui/dist/providers/ComponentMap/buildComponentMap/fields.js
Attempted import error: 'MissingEditorProp' is not exported from 'payload/errors' (imported as 'MissingEditorProp').When I remove the plugin the app works right again.
Currently using
payload and search plugin both at 3.0.0-beta.45@967118574445547650
@191776538205618177
is there any fix for this? I have tried using never and older versions but none of them help
Or is there a way to fill another collection with just the fields you need for search using hooks? I tried using local api and afterchange hook and I got an error saying collection slug was not found
Hey can you please not @ people for issues, it’s not good Discord etiquette
People will help you however they can, but remember this is a community discord, it’s mostly made up of folks like yourself who are using Payload in their projects
Sorry about that, I will keep that in mind for the next time
Won't happen again
What version is your payload/lexical?
3.0.0-beta.45
Because v3 is still in Beta, the Lexical Plugin goes through a lot of refactoring and there are often breaking changes between minor versions. Try upgrading all of your packages to the latest version of the Payload beta and checking the change notes for migration info;
I did give it a try, but going from 45 to 53 gave more errors, rather than solving them so I went back to 45
out of desperation to fix this issue I created an hook at my collection
afterChange: [
async ({ doc, req, operation }) => {
const data = {
original_id: doc.id,
name: doc.institution_name,
slug: doc.slug,
type: "universities", // Change to 'colleges' or 'schools' as appropriate
};
if (operation === "create") {
console.log("Create Ran");
await req.payload.create({
collection: "institute-search",
data,
});
} else if (operation === "update") {
console.log("Update Ran");
await req.payload.update({
collection: "institute-search",
id: doc.id,
data,
});
}
},
async ({ doc, req }) => {
// This removes the consolidated record when the original is deleted
await req.payload.delete({
collection: "institute-search",
where: {
originalId: {
equals: doc.id,
},
},
});
},
],
},that would work similarly to the search plugin, atleast for my use case but I keep getting this error
ERROR: ValidationError: The following field is invalid: original_idthis is the collection I am trying to get the data filled in
import { CollectionConfig } from "payload/types";
const InstituteSearch: CollectionConfig = {
slug: "institute-search",
labels: {
singular: "Institute Search",
plural: "Institutions Search",
},
access: {
read: () => true,
},
admin: {
useAsTitle: "name",
group: "Institutions",
},
fields: [
{
name: "original_id",
type: "text",
label: "Original ID",
required: true,
},
{
name: "name",
type: "text",
label: "Institution Name",
required: true,
},
{
name: "slug",
type: "text",
label: "Institution Slug",
required: true,
},
{
name: "type",
type: "text",
label: "Institution Type",
required: true,
},
],
versions: {
drafts: true,
},
};
export default InstituteSearch;did I make a mistake with the hook or something else?
Are any of your collections using rich text?
I was just about to say I figured it out and yes that was the issue
The hook was correct just an issue with the type I selected for the collection
Anyways thanks for all the help Mark, and the next time I will remember about not using @ people to get help
Star
Discord
online
Get dedicated engineering support directly from the Payload team.