Unable to search on enum field with @searchable
Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker
Describe the bug It is not possible to search in an enum field, the transform does not construct the search query with that field.
Amplify CLI Version 4.12.0
To Reproduce
Make a @model and @searchable type, add a enum field type, and build.
Expected behavior The enum type field were included
Any updates on this?
+1
+1
+1 - enterprise blocker, any workarounds known?
+1
+1
Hi all, we understand this is a pain-point and will prioritize accordingly but we can't commit to a timeline for the fix at this point.
In the meantime, the workaround is to modify the generated search query to include the enum in your schema.
@edwardfoyle We don't want to change generated code files, so we copyied the Searchable FilterInput to our schema.graphql:
- Copy the generated input called
SearchableFooBarFilterInputfrombuild/schema.graphqlto yourschema.graphql. (Where FooBar is the name of your model.) - Copy all
*FilterInputdependencies of the aboveinputas well. - Add
myEnum: SearchableStringFilterInputto theSearchableFooBarFilterInputinschema.graphql. amplify push
This unblocks us, but obviously the workaround is not great in the long term, so I appreciate that you're prioritizing a fix in Amplify.
On our end, we worked around this issue from the application layer by creating a proxy string field to replicate the enum field value.
Order @model @searchable {
paymentStatus: OrderPaymentStatusEnum!
paymentState: String! # Proxy for paymentStatus to enable filtering on searchable
I share the same sentiments with @mmiermans on this issue.
This unblocks us, but obviously the workaround is not great in the long term, so I appreciate that you're prioritizing a fix in Amplify.
Thanks!
+1 - facing the same issue and would expect enum types to behave like string input types when it comes to sorting/filtering
- 1
+1 I think I will go with the Proxy solution but it's a pain.
+1
+1 please fix it team :-)
+1
+1
+1
Hey @edwardfoyle. Do you have good news to share with us about this missing feature?
+1
Getting the same issue,
type Note
@model
@searchable
{
id: ID!
userID: ID!
textContent: String
htmlContent: String
imageFilename: String
noteType: NoteTypeEnum!
createdAt: AWSDateTime
updatedAt: AWSDateTime
}
enum NoteTypeEnum {
text
annotation
}
@idanlo Thank you for your quick solution, But Adding manual searchField into the schema from the Amplify console is a temporary solution. It should be generated automatically. @amplify Team Please look at the issue. @SwaySway