Back

[SOLVED] Error trying to list documents using 2 queries

  • 1
  • Flutter
  • Cloud
Ivan
11 May, 2023, 17:00

When i try to search trough a collection using search queries I get error 500, bellow is an image how I wrote it in flutter and how i made an index in the cloud console.

TL;DR
The user had an error trying to list documents using 2 queries. They solved it by creating 2 additional indexes, one for each query, and using `.equal` instead of `search`.
safwan
11 May, 2023, 17:02

not sure if this will work, but can you try creating 2 seperate indexes for the 2 attributes?

safwan
11 May, 2023, 17:03

another point - is there a reason why you're using Query.search instead of Query.equal?

safwan
11 May, 2023, 17:04

If you're trying to return the values that match the date and userId, I think Query.equal will work better.

Ivan
11 May, 2023, 17:06

I did try creating both but it then said it can’t find index “date, userId” even tho I had them created. And I found that using equal throws an error for some reason. Both userId and date are strings

safwan
11 May, 2023, 17:33

what error does equal throw?

safwan
11 May, 2023, 17:34

as for the search query, I'm not sure what could be causing this issue. have you checked your collection Id?

safwan
11 May, 2023, 17:35

Also, what's the data type of the date attribute in the collection? Is it a String or DateTime

Ivan
11 May, 2023, 18:07

String

Drake
11 May, 2023, 18:35

Whenever you get a 500 error, you need to check the docker logs for the appwrite container to see the details of the error.

That said, your problem is probably that you need a full text indext on each attribute. So 1 for date and another for userId.

Also...why are you searching on these? What's are you passing for the value and what are you expecting to get back?

Ivan
11 May, 2023, 19:01

I am using the cloud, I expect to get back one document that meets both of those criteria.

Drake
11 May, 2023, 19:32

See my 2nd paragraph

Would you please provide exact input and the matching document?

Ivan
12 May, 2023, 14:59

An update, I solved it by creating 2 more indexes one for each (date, userId), and instead of using search i used .equal and now I get precisely what I want.

Ivan
12 May, 2023, 14:59

thanks for help

Ivan
12 May, 2023, 15:00

[SOLVED] Error trying to list documents using 2 queries

Drake
12 May, 2023, 17:30

Btw, if you're using equal, you don't need the full text indexes

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