nextcloud / server

☁️ Nextcloud server, a safe home for all your data
https://nextcloud.com
GNU Affero General Public License v3.0
27.38k stars 4.07k forks source link

Search by user / fileid / whatever #32549

Open Mer0me opened 2 years ago

Mer0me commented 2 years ago

Is your feature request related to a problem? Please describe. We are using Nextcloud as an Electronic Document Management, and we would like to be able to search files by their owner or fileid. We've tried to add these metadatas as comments, in order to allow the search form to find documents by these metadatas. Each document receive automatically 2 comments like "OWNER:John Smith" and "CID:123456". When you search "Smith", all his files are retrieved. But adding thousand of comments in table oc_comments causes a Mysql crash because each time a user opens a session, oc_comments table seems to be reindexed by nextcloud. We can see multiple occurrence of this sql statement in the mysql process list :

MariaDB [nextcloud]> show full processlist;

| 113 | nextcloud_db_user | [next.dummy.fr:55116](http://next.dummy.fr:55116/) | nextcloud | Query | 0 | Creating sort index | SELECT * FROM oc_comments WHERE object_type = ‘files’ ORDER BY creation_timestamp DESC, id DESC LIMIT 100 OFFSET 76500 | 0.000 |
| 166 | nextcloud_db_user | [next.dummy.fr:55268](http://next.dummy.fr:55268/) | nextcloud | Query | 0 | Creating sort index | SELECT * FROM oc_comments WHERE object_type = ‘files’ ORDER BY creation_timestamp DESC, id DESC LIMIT 100 OFFSET 76400 | 0.000 |
| 198 | nextcloud_db_user | [next.dummy.fr:55340](http://next.dummy.fr:55340/) | nextcloud | Query | 0 | Creating sort index | SELECT * FROM oc_comments WHERE object_type = ‘files’ ORDER BY creation_timestamp DESC, id DESC LIMIT 100 OFFSET 76500 | 0.000 |

Mysql/MariaDB then runs out of memory and crashes.

Describe the solution you'd like

  1. Nextcloud shouldn't reindex oc_comments table like this. Why ?
  2. Maybe Nextcloud should propose another way to add searchable metadatas ?

Describe alternatives you've considered We can build our own search engine and add metadatas in our own table.

Mer0me commented 2 years ago

It is the recommendation App that causes the forced reindexation of oc_comments table. Disabling Recommendation App solve this problem, but the enhancement is still useful : it could be great to search files by their owner or other metadata.

q-wertz commented 2 years ago

What about the Tags feature? Maybe in combination with the Automated tagging app (see e.g. https://portal.nextcloud.com/article/tagging-and-workflows-32.html)?

(Don't use it myself, just know about it and randomly stumbled into your thread :smile: )

As far as I know it is highly not recommended to change entries directly in the DB…

Mer0me commented 2 years ago

I think Tags are not pertinent for this (we have tried) Tags are designed to be shared with all users, and to regroup multiple documents under shared subject. It's a nonsense to create a tag with a file id as only one file can be tagged by it. And tags can only be a filtering criteria, not a search term.

But thank you for your help !

noseshimself commented 2 years ago

What about the Tags feature? Maybe in combination with the Automated tagging app (see e.g. https://portal.nextcloud.com/article/tagging-and-workflows-32.html)?

See https://github.com/nextcloud/server/issues/32455 -- as long as there are no "tag namespaces" or however you want to call it) to privately classify documents for limited groups tags will not help

As far as I know it is highly not recommended to change entries directly in the DB…

It's also not highly recommended to treat a database like some local in-memory array of records but a lot of Nextcloud apps do that 8-).