Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Index Creation in Amazon Amplify Backend #2484

Open
2 tasks done
FrancescBagur opened this issue Apr 20, 2024 · 6 comments
Open
2 tasks done

Issue with Index Creation in Amazon Amplify Backend #2484

FrancescBagur opened this issue Apr 20, 2024 · 6 comments

Comments

@FrancescBagur
Copy link

How did you install the Amplify CLI?

npm

If applicable, what version of Node.js are you using?

v20.9.0

Amplify CLI Version

12.11.1

What operating system are you using?

Ubuntu

Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes made

Describe the bug

I have noticed that sometimes, when saving a recipe, the corresponding index is not created successfully. Here is an example of the entity type Recipe that I am using:

type Recipe
@model
@searchable
@auth(rules: [{ allow: owner }, { allow: public, operations: [read] }]) {
id: ID!
typeIndex: String!
@Index(name: "recipeByDate", queryField: "recipeByDate", sortKeyFields: ["createdAt"])
createdAt: String!
slug: ID! @Index
title: String
description: String
image: String
}

In this schema, the field "slug" is indexed for efficient search. However, in some cases, after saving a recipe, I am unable to retrieve it using the "bySlug" index.

This issue is affecting the functionality of my application and is causing inconvenience to our users. We rely on the index creation to ensure smooth retrieval of recipe data.

Could you please investigate this issue and provide guidance on how to ensure consistent index creation for the "slug" field?

Thank you for your attention to this matter. If you require any further information or clarification, please do not hesitate to reach out.

Best regards,

Expected behavior

I espect the indexes are not lost

Reproduction steps

I don't know, the users have created more than 100 recipes and it works well but now, to recipes had loose the index.

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@biller-aivy
Copy link

What do you mean with lost their index? You can't find it by DynamoDB console or only by GraphQL?

Try to find per dynamodb console, just to be sure this is not related to an other issue with some Auth problems.

@FrancescBagur
Copy link
Author

Dear team,

I have applied the "@searchable" directive to our recipe entities. However, I have noticed that these particular recipes are not appearing in the results when using the "listRecipe" query, nor are they retrieved when using any key in the query. Strangely, I am able to locate these recipes successfully using the "searchRecipe" query.

Upon inspecting the database table via the Amazon Web Console, I can confirm that the records for these recipes do exist. The only workaround I have found to retrieve these missing recipes is by duplicating the record and deleting the original. It seems as though the indexes associated with these recipes are somehow being lost or corrupted.

This issue has occurred twice now, despite having a large number of recipes in our database, and it is causing significant concern. I would greatly appreciate your assistance in investigating and resolving this matter promptly.

Thank you for your attention to this issue. Please let me know if you require any further information or clarification.

@FrancescBagur
Copy link
Author

Here we go again, I have another recipe without an index. It's a recipe that hasn't been edited for a long time and has always worked. The issue is very serious...

@biller-aivy
Copy link

Here we go again, I have another recipe without an index. It's a recipe that hasn't been edited for a long time and has always worked. The issue is very serious...

So you are using the searchable or the graphql query?

@phani-srikar
Copy link
Contributor

Hi @FrancescBagur, did you change the type of slug from being optional to a required when adding that index? Can you post some examples of items that you're able to query but not list? Also, when you query, is the current user also the owner of the missing item? It could be that the client is signed-in as a cognito user and doesn't own the records that you're claiming as missing.

@FrancescBagur
Copy link
Author

Hi @phani-srikar,

Yes, the slug is required. And the item have public access to read operations:

type Recipe
@model
@searchable
@auth(rules: [{ allow: owner }, { allow: public, operations: [read] }]) {
id: ID!
typeIndex: String! #Siempre se tiene que informar como "recipe" y nos sirve para crear el índice y ordenar por fecha.
@Index(name: "recipeByDate", queryField: "recipeByDate", sortKeyFields: ["createdAt"])
createdAt: String!
slug: ID! @Index
title: String
description: String
image: String
diners: Int
.....
}

Anyway, if it were a permissions error, it would throw an error when querying. Right now, I don't have any item that could trigger it because with the ones that did, I duplicated them and deleted the original, and it worked fine again. It hasn't happened to me for a few days, but just when it happened again, I'll send you an example. Thank you very much for the help, regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants