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

🐛 Bug Report: Can't create an index on string if string size is too big #6129

Closed
2 tasks done
stnguyen90 opened this issue Sep 3, 2023 · 14 comments
Closed
2 tasks done
Assignees
Labels
bug Something isn't working product / databases Fixes and upgrades for the Appwrite Database.

Comments

@stnguyen90
Copy link
Contributor

👟 Reproduction steps

  1. Create a string that is greater than 768
  2. Create a index on that string

👍 Expected behavior

The index should create

👎 Actual Behavior

Index fails to create on Cloud:

image

Error in 1.4:

image

The problem is on previous versions of Appwrite, it was possible to create an index on 1 big string attribute. We should preserve that functionality.

🎲 Appwrite version

Appwrite Cloud

💻 Operating system

Linux

🧱 Your Environment

No response

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@stnguyen90 stnguyen90 added bug Something isn't working product / databases Fixes and upgrades for the Appwrite Database. labels Sep 3, 2023
@joeyouss
Copy link

joeyouss commented Sep 4, 2023

Checked in latest version 1.4.1, still cannot create an index with type "key", only possible using Fulltext.

@fogelito
Copy link
Contributor

fogelito commented Sep 5, 2023

@joeyouss
This behavior is expected.
On fulltext you should be able to create
We added a validation on 1.4, but as I understand from Steven, it is not yet on the cloud only self-hosted.

@noob8boi
Copy link

Facing similar issue on 1.4.2 Self Hosted Instance.

Size of the string attribute is 128 and same issue for Strings[] array attribute
[Fulltext Index]

@fogelito
Copy link
Contributor

@noob8boi Do you get a PDO error?

@noob8boi
Copy link

@fogelito I see this error in docker logs appwrite .. or I should be checking smth else?
image

@fogelito
Copy link
Contributor

@noob8boi , Thanks, that's good.
The attribute you created is an array of String ? what is the length you provided on creatation?
You are trying to create a fulltext text Index for that single attribute?

@noob8boi
Copy link

noob8boi commented Sep 10, 2023

@fogelito yes an array of string.. tried with both 64 and 128 length. Then I created a fulltext index for that single attribute but failed and same happened for a normal string attribute - 128 length - fulltext index.

I think this error is only happening in a collection where i had fulltext index already on an array of strings attribute but then i deleted that attribute without deleting its fulltext index

@fogelito
Copy link
Contributor

@noob8boi We do not check length for fulltext indexes, so it feels like between delete and reCreate something is not updated properly, I will try to reproduce..

@noob8boi
Copy link

noob8boi commented Sep 10, 2023

@fogelito I think it's happening because of the unique url index. As soon as I deleted the unique URL index from that collection I was able to create full text index as expected but I am unable to create unique URL index.

So deleting the array of string attribute wasn't the real cause. It was the pre existing unique url index.

@fogelito
Copy link
Contributor

@noob8boi Let's try to reproduce this case. Can you give me information about that unique index?
what was the length of this string attribute? required? array?

@noob8boi
Copy link

noob8boi commented Sep 10, 2023

@fogelito we cant actually reproduce this because in appwrite 1.4.2 instance I am unable to create an unique index on URL attribute. We will need a pre existing collection with a unique index on required URL attribute and then migrate that instance from lets say 1.3.8 to 1.4.2.. After that u wont be able to create any new index whether its key/fulltext in the same collection.

Just my guess tho

@fogelito
Copy link
Contributor

OOh now I got it, URL field is default set to 2000 length, that's is why you can't create a unique index, there is a limit validation for this.
What you should do is create a regular URL as you did with no index +
Create a string attribute named "url_md5" length ~32 size and make it a unique index.
When creating a document md5 the URL and You will have a unique index field for URL :)

@noob8boi
Copy link

noob8boi commented Sep 10, 2023

gotcha 👍

@abnegate
Copy link
Contributor

Closing as expected behaviour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working product / databases Fixes and upgrades for the Appwrite Database.
Projects
None yet
Development

No branches or pull requests

5 participants