Back

Search query after 1.4.3 cloud upgrade

  • 0
  • Databases
Martin
22 Sep, 2023, 21:02

Hi dear, after updating the new version of the cloud, has anything changed in the search method? Previously I was successfully using search("attribute", [value1, value2]) as specified in the documentation (REST). Now the response from the server is error: "Search queries require exactly one value". Is this a bug? Any solution?

TL;DR
Title: Issue with search query after 1.4.3 cloud upgrade Messages: - User is experiencing an issue with the search query after the upgrade. - They provided examples of the search query they were using before the upgrade. - They suggest removing the array check on the full-text search query. - They mention that their older REST API calls don't work anymore due to the change in the validator of the search query. - They inquire if there is a solution to this issue and request assistance from the core team. Solution: - It is suggested to pass the values in a single string instead of an array in the search query.
Christy Jacob
22 Sep, 2023, 21:36

which SDK and which version ( of the SDK ) are you using?

Christy Jacob
22 Sep, 2023, 21:38

I quickly checked the SDKs for web V10.0.2 https://github.com/appwrite/sdk-for-web/blob/10.2.0/src/query.ts#L24

and V13.0.0 https://github.com/appwrite/sdk-for-web/blob/13.0.0/src/query.ts#L42

The value for a search query has always been a single string rather than a list 🤔

Martin
22 Sep, 2023, 23:18

I use Appwrite via HTTP requests without SDK, using a direct REST API call with queries[] parameter something like: https://cloud.appwrite.io/v1/databases/{databaseId}/collections/{collectionId}/documents?queries[]=search("attribute", [value1, value2])

Before the update this was functional, that's for sure. The same loss is when calling equal("attribute", [value ...]).

This functionality is described in the REST API documentation here: https://appwrite.io/docs/rest

In Appgyver, where I use it, I don't have better API consumption or loop programming capabilities, so this functionality is essential for me. (and is one of the important motivations for switching from Firebase to Appwrite) 🤨

Drake
23 Sep, 2023, 02:48

To get things working, can you pass the values in a single string instead of an array?

Martin
23 Sep, 2023, 05:07

@Steven No, it doesn't work that way, the values in the array were originally evaluated as or. That was elegant and simple. This is not the solution. Can someone from the core team working on the rest api take a look at this? @Meldiron @Christy Jacob

Passing the values in a single string breaks the logic of all rest api calls according to the above documentation (and breaks my app). https://appwrite.io/docs/rest

It is mentioned as an array parameter. select select([attribute]) equal equal("attribute", [value]) search("attribute", [value]) ...

Drake
23 Sep, 2023, 14:52

It should still be or. What exactly are you passing?

Martin
23 Sep, 2023, 18:13

The books have genres e.g. Genre: young adult, for girls, romance, literary fiction, ... Genre: young adult, for boys, action, literary fiction, ... Genre: young adult, for boys, spy, non fiction, ... I want to construct a query 'all books for girls and boys', something like: search("genre", ["for girls", "for boys"]) or 'fiction for boys': search("genre", ["for boys", "literary fiction"]) I've tried replacing array with string (looks ok), I still can't cope with two words separated with space ( or ...?) search("genre", "for boys, literary fiction")

Drake
23 Sep, 2023, 18:27

So the query in the network request should look something like search("genre", ["\"for girls\" \"fiction\""]

Martin
23 Sep, 2023, 19:42

No, query with one keyword is ok but response with two search strings is empty.

Martin
24 Sep, 2023, 07:44

Hi, I've experimented with different formats and it only works with single-word comma-separated arguments search("genres", ["boys,girls"]) - with or without square brackets, both. I can already solve this somehow (slug instead of separate words). But in all this experimenting, I tried reindexing the database and got stuck somewhere. (delete index) 😵‍💫

Martin
24 Sep, 2023, 15:09

Any help with stucked index?

Drake
24 Sep, 2023, 17:07

What's your project id?

Martin
25 Sep, 2023, 17:05

@Steven We can't solve this?

Drake
25 Sep, 2023, 21:11

actually, can you try with 2 backslashes? Here's an example of my test:

Drake
25 Sep, 2023, 21:27

were these processing when you deleted them?

Martin
2 Oct, 2023, 19:04

1.) I solved the stacked index by deleting the current collection and creating a new one. All operations are very slow lately and often end with error 500 (clearly beta).

2.) I found that the search query uses the MATCH AGAINST construct, so it doesn't matter if square brackets are used or not (pure is without). BOOLEAN gives other options. Validator in search query was changed in the last version: public function isValid($value): bool { ... case Query::TYPE_GREATER_EQUAL: case Query::TYPE_SEARCH: case Query::TYPE_STARTS_WITH: case Query::TYPE_ENDS_WITH: if (count($value->getValues()) != 1) { $this->message = \ucfirst($method) . ' queries require exactly one value.'; return false; } ... this was not before. That's why all my older REST API calls don't work: search("genre", ["for boys", "literary fiction"]) evaluates to an array. If it was delivered to AGAINST like this it would probably work anyway.

Drake
2 Oct, 2023, 19:08

Right, I was suggesting to pass 1 value

Martin
19 Oct, 2023, 21:00

@Steven could you please consider having someone remove this array check on the full-text search query? It's useless and doesn't allow to submit a correct full-text query with multiple words. As described in the documentation for fulltext search, e.g. here: https://mariadb.com/kb/en/full-text-index-overview/ ... Multiple words: SELECT * FROM ft_myisam WHERE MATCH(copy) AGAINST('wicked,witch');

Anything enclosed in double quotes is taken as a whole (so you can compare phrases, for example). ... And so it is correct to send a query in the format: search("genre", ["books for boys", "literary fiction"])

Drake
19 Oct, 2023, 21:40

this would be equivalent to:

TypeScript
"\"books for boys\" \"literary fiction\""

or maybe

TypeScript
"\\"books for boys\\" \\"literary fiction\\""

depending on how escaping works

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