Back

Queries

  • 0
  • Flutter
Joshima
1 Sep, 2023, 13:13

and this below is my function in which i want nested query to get the desired result - @override Future<List<Document>> getSavedBlogsByHashtag( String hastag, UserModel user) async { final documents = await _db.listDocuments( databaseId: AppConstants.APPWRITE_DATABASE_ID, collectionId: AppConstants.APPWRITE_BLOGS_COLLECTION, queries: [ Query.equal('\$id', user.SavedPosts), Query.search('hastags', hastag), Query.orderDesc('createdAt'), Query.limit(100), ]); return documents.documents; }

TL;DR
The user is experiencing issues with queries in Appwrite 1.3. They mention that strict indexes for queries are no longer necessary in this version. However, they question if using the "fullText" option is still allowed. The user also suggests that there may be an issue with the "hashtags" index and asks if trying other hashtags would work. They provide code that should print the documents but instead get an instance of 'DocumentList'. Another user suggests surrounding the code with try-catch and printing the error message. The original user also mentions that they are getting a blank screen with a loader when printing the hashtag in the function.
Binyamin
1 Sep, 2023, 13:14

The last one should work

Binyamin
1 Sep, 2023, 13:14

What are you getting back?

Joshima
1 Sep, 2023, 13:14

i am getting a blank screen with a laoder

Joshima
1 Sep, 2023, 13:15

but i tried printing hashtag in function

Joshima
1 Sep, 2023, 13:15

it is correct

Joshima
1 Sep, 2023, 13:15

the function is getting the hashtag

Binyamin
1 Sep, 2023, 13:16

Try to print it and surround it with try catch like so and share the results

TypeScript
  @override
  Future<List<Document>> getSavedBlogsByHashtag(
      String hastag, UserModel user) async {
      try {
            final documents = await _db.listDocuments(
        databaseId: AppConstants.APPWRITE_DATABASE_ID,
        collectionId: AppConstants.APPWRITE_BLOGS_COLLECTION,
        queries: [
          Query.equal('\$id', user.SavedPosts),
          Query.search('hastags', hastag),
          Query.orderDesc('createdAt'),
          Query.limit(100),
        ]);
        print(documents);
       return documents.documents;
      } catch (e){
        print(e);
        return null;
      }
  }
Joshima
1 Sep, 2023, 13:19

getting this - Documents: Instance of 'DocumentList'

Binyamin
1 Sep, 2023, 13:19

And this

TypeScript
print(documents.documents);
Joshima
1 Sep, 2023, 13:23

Documents.documents: []

Binyamin
1 Sep, 2023, 13:29

So

  • $id alone works
  • hashtags alone works
  • Togther doesn't work ?
Joshima
1 Sep, 2023, 13:37

Yeah first two functions are working fine but not the third one

Binyamin
1 Sep, 2023, 13:59

This is weird just tested it and it should work

Binyamin
1 Sep, 2023, 13:59

Can you try with other hashtags?

Guille
1 Sep, 2023, 14:00

maybe is a index issue? πŸ€”

Binyamin
1 Sep, 2023, 14:01

I think in that case it should give error that hastags is not a fulltext index But it's worth checking is hashtags has fulltext index on it?

Guille
1 Sep, 2023, 14:04

If I'm not wrong from v1.3 you won't get index error

Binyamin
1 Sep, 2023, 14:04

Also for fullText?

Guille
1 Sep, 2023, 14:04

I'm not sure to be honest

Guille
1 Sep, 2023, 14:05

Strict indexes for queries in Appwrite 1.3 are no longer necessary! If you ever used Appwrite Databases, chances are, you have seen the error ⚠️Index Not Found. Such strict indexes can get in the way during development and can be a blocker to some use cases with complex filtering possibilities. With Appwrite 1.3, you are no longer going to get errors telling you to set up an index.

Guille
1 Sep, 2023, 14:05

I found this from v1.3 release

VincentGe
1 Sep, 2023, 22:23

🀣 I hope we don't let you full text search without index

VincentGe
1 Sep, 2023, 22:23

Tha

VincentGe
1 Sep, 2023, 22:23

That's not a good idea at all

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more