Closed slavanossar closed 4 months ago
+1 experiencing the same issue.
"dependencies": {
"@azure/storage-blob": "^12.17.0",
"@nouance/payload-better-fields-plugin": "^1.3.5",
"@payloadcms/bundler-webpack": "^1.0.6",
"@payloadcms/db-postgres": "^0.x",
"@payloadcms/plugin-cloud-storage": "^1.1.2",
"@payloadcms/plugin-search": "^1.1.0",
"@payloadcms/richtext-lexical": "^0.7.0",
"cross-env": "^7.0.3",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"payload": "^2.11.2"
},
I did some investigating and it seems like the issue actually originates within the db-mongodb
adaptor, although haven't been able to pinpoint where.
Looking at the code in db-mongodb
it's clear that relationTo
isn't a supported operation and so is completely ignored by parseParams
, buildSearchParam
, etc., due to not being a included in validOperators
or in the operatorMap
.
It seems like the issue actually stems from the generation of the collection's schema, since relationTo
should actually contain an operator when used within a where
query.
The Search_where
inputs are defined as
input Search_where {
title: Search_title_operator
priority: Search_priority_operator
doc: Search_doc_Relation
updatedAt: Search_updatedAt_operator
createdAt: Search_createdAt_operator
id: Search_id_operator
AND: [Search_where_and]
OR: [Search_where_or]
}
input Search_doc_Relation {
relationTo: Search_doc_Relation_RelationTo
value: JSON
}
enum Search_doc_Relation_RelationTo {
articles
artists
episodes
hosts
programs
trackPlays
}
where in reality it should be something like
input Search_where {
title: Search_title_operator
priority: Search_priority_operator
doc: Search_doc_Relation
updatedAt: Search_updatedAt_operator
createdAt: Search_createdAt_operator
id: Search_id_operator
AND: [Search_where_and]
OR: [Search_where_or]
}
input Search_doc_Relation {
relationTo: Search_doc_Relation_RelationTo_operator
value: JSON
}
input Search_doc_Relation_RelationTo_operator {
equals: Search_doc_Relation_RelationTo
not_equals: Search_doc_Relation_RelationTo
like: Search_doc_Relation_RelationTo
contains: Search_doc_Relation_RelationTo
in: [Search_doc_Relation_RelationTo]
not_in: [Search_doc_Relation_RelationTo]
all: [Search_doc_Relation_RelationTo]
exists: Boolean
}
enum Search_doc_Relation_RelationTo {
articles
artists
episodes
hosts
programs
trackPlays
}
Closed in favour of #6399
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.
Link to reproduction
No response
Describe the Bug
I am writing a query to retrieve search results that belong to a specific collection
When executing the query for a specified
$collectionSlug
, the results include documents that are from all collectionsWhen a value that doesn't exist on
Search_doc_Relation_RelationTo
is used, the response correctly states that the value isn't part of the enum.To Reproduce
Payload Version
2.11.2
Adapters and Plugins
@payloadcms/plugin-search@1.1.0