Back

[SOLVED] Unable to add fulltext index to $id field

  • 0
  • Self Hosted
  • Databases
WhiteWalker72
31 Oct, 2023, 14:23

I've been trying to run a single query where I find multiple documents by a list of document ids. I found out you can find multiple documents by an array by using Query.search, if the attribute has an index with fulltext as type. So in order to find multiple documents I want to add a fulltext index on the $id field. When I try to add this index I get this error back:

TypeScript
{
    "message": "Invalid `key` param: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char",
    "code": 400,
    "type": "general_argument_invalid",
    "version": "1.4.7"
}

Is it in any way possible to do query with an array as input?

TL;DR
Issue: Unable to add fulltext index to $id field; Solution: - The error is due to the invalid `key` parameter. It must contain at most 36 characters and only include valid characters such as a-z, A-Z, 0-9, period, hyphen, and underscore. It cannot start with a special character. - Instead of using `Query.search()`, to filter by document ids, use `Query.equal('$id', [id1, id2, id3])`. - When creating the index, make sure to include the attributes in the attributes array. - An example of a valid
Drake
31 Oct, 2023, 14:56

first of all, if you want to filter by document ids, you don't need Query.search(). You can use Query.equal('$id', [id1, id2, id3]).

secondly, when you tried creating your index, what did you put as the key?

WhiteWalker72
31 Oct, 2023, 15:00

Ahh, now I feel stupid. But thank you, that works πŸ˜… My input when creating the index was:

TypeScript
{
    "key":"$id",
    "type":"fulltext",
    "attributes":[],
    "orders":["ASC"]
}
Drake
31 Oct, 2023, 20:30

ya, $id is now allowed for key. FYI, key is just a name for you. the important part in creating indexes is included the attributes in the attributes array

WhiteWalker72
1 Nov, 2023, 06:56

Ah, that makes sense. Thank you!

WhiteWalker72
1 Nov, 2023, 06:57

[SOLVED] Unable to add fulltext index to $id field

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