Back

Queries

  • 0
  • Databases
  • Flutter
  • Cloud
OppositeDragon
16 May, 2023, 23:50

Hello, I am trying to create a query mixing search, greaterThanEqual and lessThanEqual.

TypeScript
...
 queries: [
          Query.greaterThanEqual("date", startDate),
          Query.lessThanEqual("date", endDate),
          Query.search('name', query),
        ],
...

I have already tried creating an index for this, but it is failing. Can I get an explanation why?, or advice on a workaround please.

TL;DR
The user is asking for help regarding a query issue involving search, greaterThanEqual, and lessThanEqual. They mention that they have tried creating an index for it, but it is failing. They are looking for an explanation or workaround. No solution is provided in the thread.
Drake
17 May, 2023, 00:05

You cannot include non-text attributes in a full text index.

In 1.3, we removed the requirement to have an index over all attributes so this wouldn't be a problem anymore

Drake
17 May, 2023, 00:06

question though...what do you plan on passing for query and what documents are you expecting to find?

OppositeDragon
17 May, 2023, 01:20

query would be part of the name of a client, and I woul expect to retrieve all documents matching that name, emitted within the date range

Drake
17 May, 2023, 01:22

So you're trying to do an exact match? A concrete example would be helpful

OppositeDragon
17 May, 2023, 01:26

query="mar"

Pool of all names: marcelo, maria, juan, mateo, mimar, zamarcia, esteban, lucas, arturo, mimace

Expected results marcelo, maria, mimar, zamarcia

OppositeDragon
17 May, 2023, 01:29

Something like:

TypeScript
... WHERE NAME LIKE '%mar%' ...

In SQL

Drake
17 May, 2023, 01:34

I see. The search query uses mariadb's full text search which does not behave like LIKE '%mar%'. For more info on how it works, see https://github.com/appwrite/appwrite/discussions/5005#discussioncomment-4681079

Appwrite 1.3 introduced 2 new queries: ends with and starts with. Those can be used like what you're trying to do...but we don't support OR logic yet

OppositeDragon
17 May, 2023, 01:37

Thank you for answering me

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