Back

[SOLVED] how to do `search` in a string and `greaterThanEqual` in a datetime, in one query

  • 0
  • Databases
  • Web
manazo
11 Apr, 2023, 09:24

as the title suggests, I'm in a situation, where I need to do a search query on a string-type array, but that query also includes a DateTime attribute. if I go into detail, I need to do a search on a String[], and a greaterThanEqual on a DateTime attribute, in a single query. And as we all know, the search query requires a FullText type index. I tried creating a FullText index with DateTime attribute included, but the creation fails (as expected). I made a post about this previously, and there, someone mentioned that I cannot create a FullText index with types other than string. I lost that post, so here I'm posting it again. Is there any workaround to accomplish this?

TL;DR
The OP is having trouble performing a search query on a string-type array while also including a greater than or equal condition on a DateTime attribute. They tried creating a FullText index with the DateTime attribute included, but it failed. Another user suggested creating a dummy FullText index with both attributes included to resolve the "Index not found" error. Another suggestion was to create separate indexes for each attribute. The post ends with the OP asking for a workaround to accomplish this task.
joeyouss
11 Apr, 2023, 09:30

Hi

manazo
11 Apr, 2023, 09:32

hello

joeyouss
11 Apr, 2023, 09:38

Let me look into this and brb

joeyouss
11 Apr, 2023, 09:49

So,

joeyouss
11 Apr, 2023, 09:53

You can create 2 indexes for this to work separately. If your app does not do very much heavy lifting, this shouldnt impact the performance by a lot. MariaDB should be smart enough and always look for the best possible option. Separate indexes are still faster than no indexes, so it should be used under the hood.

joeyouss
11 Apr, 2023, 09:59

If you want to get rid of "index not found" error, it's fine to leave it as it. Create index, it will be failed, ignore it.

manazo
11 Apr, 2023, 10:19

For someone in future checking this post and didn't get what actually to do: so I created one FullText index with the attr that I wanna do search query. one key index with the DateTime attribute. it does the job. but still returns "Index not found". to tackle that, I created a dummy FullText index with both attr included (tho the creation failed, but it resolved the "Index not found" error)

Thanks @joeyouss

manazo
11 Apr, 2023, 10:35

[SOLVED] how to do search in a string and greaterThanEqual in a datetime, in one query

joeyouss
11 Apr, 2023, 14:15

Thank you @manazo ❤️ this msg is helpful

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