Back

[Solved] Query search not working even though I have created fullText indexes for the attribute

  • 0
  • Databases
  • Web
Drake
23 Mar, 2023, 20:54

What indexes do you have and what's the query you're making?

TL;DR
Title: [Solved] Query search not working even though I have created fullText indexes for the attribute Solution: The issue was resolved by recreating the indexes. The user also mentioned separating data into separate collections and using normalization to simplify the process of renaming or deleting parent folder documents.
BI
24 Mar, 2023, 16:23

Here are the two collections with virtually the same indexes

BI
24 Mar, 2023, 16:26

Here's the queryArray that produces the server error:

['orderDesc("$createdAt")', 'equal("parent_folder", ["test3"])', 'search("question", ["music"])']

BI
24 Mar, 2023, 16:27

Do indexes need to have unique names across collections

Drake
24 Mar, 2023, 16:28

which one has the error?

BI
24 Mar, 2023, 16:34

Both of them though the second one only works with the parent_folder and orderDesc queries. The first one works with all the queries except any that involve searchTerm (for the question attribute)

BI
24 Mar, 2023, 16:35

The docker error suggests the same thing showing that there's an issue with the fullText indexes

BI
24 Mar, 2023, 16:37

btw, is there a way to nest documents so that I don't have to use the parent_folder attribute?

Drake
24 Mar, 2023, 16:49

Would you please try adding a full text index on question only?

Drake
24 Mar, 2023, 16:50

normalization is the best approach. so separating out data into separate collections.

We are working on relationships which could simplify some of that, though.

BI
24 Mar, 2023, 16:54

Oh ok, yeah, I've separated out the data with the parent folder being in a different collection but renaming the parent folder means I have to update the parent_folder attributes of all the documents the parent_folder relates to. Similar case with deletion. That's why I was wondering if there was a nesting mechanism since updating all of that would take up a significant amount of resources just to rename or delete one parent folder document

BI
24 Mar, 2023, 17:03

I deleted the old attributes and added just a question one and then a question one with a parent_folder one combined and it worked

BI
24 Mar, 2023, 17:04

I think there might have been an error or glitch in the creation of the old indexes. Maybe something to do with the name because I only used one underscore this time

BI
24 Mar, 2023, 17:05

I'll add indexes one by one and see if they still work. If they do, I'll mark this as solved

BI
24 Mar, 2023, 17:08

Also, I will add the independent indexes of the attributes in case that maybe the problem even though they won't be used independently during a query

Drake
24 Mar, 2023, 17:31

I'm not sure what you mean....to link things, I would use IDs so the name is only in 1 place...

Drake
24 Mar, 2023, 17:32

it's only required for the full text since you're searching on 1 attribute

BI
24 Mar, 2023, 20:02

Oh ok, thanks. Do you have any suggestions for how I should handle deletion or should I just do it the normal way of deleting everything with the matching parent_folder when the parent folder document is deleted

Drake
24 Mar, 2023, 20:12

Ya that sounds reasonable. Probably recursively

BI
24 Mar, 2023, 20:35

Sorry, I'm relatively new to web development, why would I need to do the deletion recursively? My idea was to use a for loop after obtaining the document IDs of the documents matching my criteria

Drake
24 Mar, 2023, 20:47

for path a/b/c/d, if i delete a, i have to delete b. then, c, then d

BI
24 Mar, 2023, 23:05

Oh, ok, I understand now, thanks!

BI
24 Mar, 2023, 23:06

Also, recreating the indexes like this solved the issue so I'll mark the problem as solved

BI
24 Mar, 2023, 23:07

Thanks for the help with everything!

BI
24 Mar, 2023, 23:07

[Solved] Query search not working even though I have created fullText indexes for the attribute

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