appwrite icon indicating copy to clipboard operation
appwrite copied to clipboard

🐛 Bug Report: Index not found, when using getIndex, but createIndex and listIndexes reports index is present

Open FirzenYogesh opened this issue 3 years ago • 2 comments

👟 Reproduction steps

I am trying to create index through dart_appwrite package. This is my code snippet here.

    try {
      await database.getIndex(
        collectionId: collectionId,
        key: indexKey,
      );
    } on AppwriteException {
      print(
          "Index (${database.databaseId}):($collectionId):($indexKey) does not exist, creating one!");
      await database.createIndex(
        collectionId: collectionId,
        key: indexKey,
        type: type,
        attributes: [key],
      );
      return true;
    }

The try block is throwing error stating my indexKey is not there, it goes into the catch block where it tries to create an index. This also fails, because the index actually exists on my collection.

I checked in the CLI too it is able to listIndex, but not query them image

image

image

Made an API call through post man too, same behaviour. I double checked my api key too. Databases, Collections, Attributes, Indexes, Documents were given read write access.

Note: I checked with indexKey with no special characters too, and also created an index in the web ui and tried to get the index, still no luck.

Am I missing something here?

👍 Expected behavior

Get the index that was requested by key

👎 Actual Behavior

Indexes are not found by key, throws AppwriteException

🎲 Appwrite version

Version 0.15.x

💻 Operating system

Linux

🧱 Your Environment

This is a fresh build hosted on DigitalOcean Droplet using the 1-click setup.

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

  • [X] I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

FirzenYogesh avatar Aug 10 '22 20:08 FirzenYogesh

@FirzenYogesh, thanks for raising this issue! I can confirm I am able to reproduce this issue. List Indexes shows my index, but when I make the API call to Get Index, I get 404. We'll look into this as soon as we can.

In the meantime, I recommend using the result from List Indexes instead.

stnguyen90 avatar Aug 11 '22 04:08 stnguyen90

@stnguyen90 thanks for the reply, I will use the results from listIndexes for now until this is resolved

FirzenYogesh avatar Aug 11 '22 05:08 FirzenYogesh

Closing as resolved in version 1.2.0

abnegate avatar Jan 11 '23 03:01 abnegate