When I use Query.search() instead of returning rows with the keywords provided it just returns all the rows in the table.
TL;DR
Issue: Query.search() function is returning all rows in the table instead of filtering by the provided keywords.
Solution:
Instead of passing the 'content' column directly, use Query.field("content") inside Query.search() to specify the field to search in. Update the code as follows:
```typescript
queries: [Query.search(Query.field("content"), query)],
```
This will correctly filter rows based on the provided keywords.TypeScript
try {
return await tablesDB.listRows<Post>({
databaseId: CRIC_TALK_DATABASE_ID,
tableId: POSTS_TABLES_ID,
queries: [Query.search("content", query)],
});
} catch (error) {
console.log(`Error while searching posts ${error}`);
throw error;
}
}```
this is the code i am using
[SOLVED] Query.search() returning all rows in the table
Recommended threads
- Relation Question
How do I create a relation from table y to an others x.$id. in my example I have a users table where I use Appwrites unique User IDs and I want other tables fo...
- Unknown attribute type: varchar / text
Since the `string` type is deprecated I tried using `varchar` and `text` in some newer tables, but when running `appwrite pull tables && appwrite types ./src/li...
- Query.search limitation
Since `string` is deprecated I used `varchar`, and now I cant use `Query.contains` , so I setup fulltext index and started using `Query.search` the issue is `Qu...