Open pgrafix opened 2 years ago
Hello and thanks for the report!
Searching from the root returns matching results from any and all folders. Search from Folder 1 returns no matching results since it is not searching within the sub-folders (like a search from root does) and this folder contains no documents, just more sub-folders for organization. Searching from a Sub-folder [to Folder 1] returns matching results from within that folder only.
Is this the behavior you actually see or the behavior that you would like to see? If the former, how do you think it ought to work? If the latter, what are you actually seeing?
Is this the behavior you actually see or the behavior that you would like to see? If the former, how do you think it ought to work? If the latter, what are you actually seeing?
This is what I am seeing now. Normal search routines would search the subfolders as well. To clarify, the subfolders do contain documents. Therefore, when searching from the parent folder it should see the documents in the subfolder.
Got it, thanks for the clarification. I agree with your intuition that search ought to match items in subfolders of the current folder.
The search query works via the main bp_docs_has_docs()
loop. For most uses of this function, you don't want to recurse into subfolders. So we'd want to add a flag around here https://github.com/boonebgorges/buddypress-docs/blob/49b310741b467f7b87625b4109e51fb789fd8795/includes/templatetags.php#L81 that says something like: if this is a search, then we should pass a recurse_subfolders
parameter to BP_Docs_Query
. Then, when processing 'folder_id'
(which happens at https://github.com/boonebgorges/buddypress-docs/blob/49b310741b467f7b87625b4109e51fb789fd8795/includes/addon-folders.php#L899), if we detect recurse_subfolders
, we must recurse down the folder tree, and include all subfolder IDs in the folder_id
tax query.
I don't have the resources to pursue this in the very short term. If someone were to offer up a PR, I'd be happy to consider it. Otherwise perhaps I will be able to implement myself the next time I've got available resources.
I appreciate your responses. Alas, I am unsure of my ability to contribute to the solution of the issue on my own via a PR.
@boonebgorges
I installed 2.1.8 this month. I am assuming that this wasn't addressed in 2.1.8 as I am still having the same issue with nested searching after the update. Is that correct? If so, when do you anticipate a fix for this? This seems to be a crucial aspect of a document management system.
Thanks again for your plugin and development efforts!
Hi @pgrafix - No, I'm afraid I haven't found time to work on this. It's likely I'll devote some resources to this plugin sometime during the summer of 2023. Please continue to watch this space for updates.
@boonebgorges Hope your summer has been a good one. Can you please give me a quick update? Thanks!
I didn't get time to work on this as part of my paid development time. I did spend a bit of time yesterday working up a proof of concept, which is in 9246bdf. Feel free to test it. It could have odd side-effects. It could also definitely use some visual refinement. If you are searching in folder A with a nested folder B, and you turn up a document that lives in B, then there should probably be something in the search results that indicates that. So, I think it needs more thought and work before it can be merged in, but perhaps this is enough for you to experiment with.
I didn't get time to work on this as part of my paid development time. I did spend a bit of time yesterday working up a proof of concept, which is in 9246bdf. Feel free to test it. It could have odd side-effects. It could also definitely use some visual refinement. If you are searching in folder A with a nested folder B, and you turn up a document that lives in B, then there should probably be something in the search results that indicates that. So, I think it needs more thought and work before it can be merged in, but perhaps this is enough for you to experiment with.
I am happy to report that this appears to work well. I have put into production and have yet to encounter any issues. I am sure it is by design, but I did notice that searching only returns documents and not folders. While I wouldn't call that an issue I could see how returning documents AND folders may be useful. Perhaps a an additional search filter?
Have an issue where searching within a private group doesn't always return results when it should. For example:
Documents root
Searching from the root returns matching results from any and all folders. Search from Folder 1 returns no matching results since it is not searching within the sub-folders (like a search from root does) and this folder contains no documents, just more sub-folders for organization. Searching from a Sub-folder [to Folder 1] returns matching results from within that folder only.
Any help (or a fix) for where search fails when it shouldn't would be greatly appreciated.