[Bug]: Searches take too long, overwriting later, more specific searches
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
⚠️ This issue respects the following points: ⚠️
- This is a bug, not a question or a configuration/webserver/proxy issue.
- This issue is not already reported on Github OR Nextcloud Community Forum (I've searched it).
- Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
- I agree to follow Nextcloud's Code of Conduct.
Bug description
In our Nextcloud instance, when searching for a filename it happens reproducible that a small pause between the second and third character leads to a slow query which causes to overwrite search results which already came in after typing more characters.
Steps to reproduce
- Have a Nextcloud instance with many 100s of 1000s of files.
- Open the search box
- Type 2 characters of the name of an existing file, wait a short moment, continue typing
Expected behavior
I expect Nextcloud to know which search results are from which search and throw away search results which belong to an earlier, less specific search, and not to display them
Nextcloud Server version
31
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.4
Web server
Nginx
Database engine version
PostgreSQL
Is this bug present after an update or on a fresh install?
Upgraded to a MAJOR version (ex. 31 to 32)
Are you using the Nextcloud Server Encryption module?
None
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
{
"system": {
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"trusted_domains": [
"***REMOVED SENSITIVE VALUE***",
"***REMOVED SENSITIVE VALUE***",
"***REMOVED SENSITIVE VALUE***",
"***REMOVED SENSITIVE VALUE***"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"dbtype": "pgsql",
"version": "31.0.8.1",
"overwrite.cli.url": "http:\/\/localhost",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "",
"dbtableprefix": "oc_",
"dbuser": "***REMOVED SENSITIVE VALUE***",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"instanceid": "***REMOVED SENSITIVE VALUE***",
"loglevel": 2,
"maintenance": false,
"ldapIgnoreNamingRules": false,
"ldapProviderFactory": "\\OCA\\User_LDAP\\LDAPProviderFactory",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"memcache.local": "\\OC\\Memcache\\APCu",
"memcache.locking": "\\OC\\Memcache\\Redis",
"redis": {
"host": "***REMOVED SENSITIVE VALUE***",
"password": "***REMOVED SENSITIVE VALUE***",
"port": "6379"
},
"trusted_proxies": "***REMOVED SENSITIVE VALUE***",
"theme": "",
"maintenance_window_start": 1,
"default_phone_region": "DE",
"defaultapp": "dashboard,files",
"app_install_overwrite": [
"sharelisting",
"files_rightclick",
"files_texteditor"
]
}
}
List of activated Apps
Enabled:
- activity: 4.0.0
- announcementcenter: 7.1.4
- app_api: 5.0.2
- bruteforcesettings: 4.0.0
- calendar: 5.3.9
- camerarawpreviews: 0.8.7
- circles: 31.0.0
- cloud_federation_api: 1.14.0
- comments: 1.21.0
- contactsinteraction: 1.12.0
- dashboard: 7.11.0
- dav: 1.33.0
- drawio: 3.1.0
- federatedfilesharing: 1.21.0
- federation: 1.21.0
- files: 2.3.1
- files_downloadlimit: 4.0.0
- files_external: 1.23.0
- files_fulltextsearch: 31.0.0
- files_pdfviewer: 4.0.0
- files_reminders: 1.4.0
- files_sharing: 1.23.1
- files_texteditor: 2.15.1
- files_versions: 1.24.0
- firstrunwizard: 4.0.0
- fulltextsearch: 31.0.0
- fulltextsearch_elasticsearch: 31.0.0
- imageconverter: 2.0.5
- impersonate: 2.0.0
- keeweb: 0.6.21
- logreader: 4.0.0
- lookup_server_connector: 1.19.0
- nextcloud_announcements: 3.0.0
- notifications: 4.0.0
- oauth2: 1.19.1
- ownpad: 0.13.0
- password_policy: 3.0.0
- photos: 4.0.0
- previewgenerator: 5.9.0
- privacy: 3.0.0
- profile: 1.0.0
- provisioning_api: 1.21.0
- recommendations: 4.0.0
- related_resources: 2.0.0
- serverinfo: 3.0.0
- settings: 1.14.0
- sharebymail: 1.21.0
- sharereview: 1.4.0
- spreed: 21.1.3
- support: 3.0.0
- survey_client: 3.0.0
- systemtags: 1.21.1
- text: 5.0.0
- theming: 2.6.1
- thesearchpage: 1.2.12
- twofactor_backupcodes: 1.20.0
- user_ldap: 1.22.0
- user_status: 1.11.0
- viewer: 4.0.0
- weather_status: 1.11.0
- webhook_listeners: 1.2.0
- whiteboard: 1.1.3
- workflow_media_converter: 1.15.1
- workflowengine: 2.13.0
Disabled:
- admin_audit: 1.21.0
- encryption: 2.19.0 (installed 2.19.0)
- files_rightclick: 0.15.1 (installed 0.15.1)
- files_trashbin: 1.21.0 (installed 1.21.0)
- fulltextsearch_sql: 1.2.0
- suspicious_login: 9.0.1
- twofactor_nextcloud_notification: 5.0.0
- twofactor_totp: 13.0.0-dev.0
- updatenotification: 1.21.0 (installed 1.2.0)
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
no relevant lines in log
PotsgreSQL Logs
# tail -f /var/lib/postgresql/15/main/log/postgresql-2025-09-29_000000.log
2025-09-29 09:06:57.395 UTC [3675249] nextcloud@nextcloud LOG: duration: 4199.378 ms execute <unnamed>: SELECT "file"."fileid", "storage", "path", "path_hash", "file"."parent", "file"."name", "mimetype", "mimepart", "size", "mtime", "storage_mtime", "encrypted", "file"."etag", "file"."permissions", "checksum", "unencrypted_size", "meta"."json" AS "meta_json", "meta"."sync_token" AS "meta_sync_token" FROM "oc_filecache" "file" LEFT JOIN "oc_files_metadata" "meta" ON "file"."fileid" = "meta"."file_id" WHERE ("file"."name" ILIKE $1) AND ((("storage" = $2) AND (("path" = $3) OR ("path" LIKE $4))) OR ("storage" IN ($5, $6, $7, $8, $9, $10)) OR (("storage" = $11) AND ("path" = $12)) OR (("storage" = $13) AND (("path" = $14) OR ("path" LIKE $15)))) ORDER BY "mtime" + $16 desc LIMIT 5
2025-09-29 09:06:57.395 UTC [3675249] nextcloud@nextcloud DETAIL: parameters: $1 = '%17%', $2 = '138', $3 = 'files', $4 = 'files/%', $5 = '594', $6 = '602', $7 = '631', $8 = '616', $9 = '618', $10 = '590', $11 = '76', $12 = 'files/dbdump-otrs-wmfg/otrs-20201212-0300.sql.gz', $13 = '79', $14 = 'files/Austausch Spumi:Kom/Mitgliederversammlungen/Mitgliederversammlung_2021/2021_Mitgliederbereich', $15 = 'files/Austausch Spumi:Kom/Mitgliederversammlungen/Mitgliederversammlung\_2021/2021\_Mitgliederbereich/%', $16 = '0'
Additional info
We already pinpointed the issue to the query taking multiple seconds to complete. Without knowing the architecture of the search we cannot tell for sure if the search couldn't be cancelled after receiving more specific input or if Nextcloud delays execution of the search for a short moment while expecting more keypresses and only starts searching after 400ms or so.
We can provide screen recordings showing the behaviour.
When typing quick enough, this behaviour does not pop up. We even experimented using ElasticSearch and the corresponding FullTextSearch apps but it still happens. It seems that ElasticSearch isn't utilised for searching filenames which makes sense in a sense.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No repository file or test is named in the report. Start by tracing the search-box request that produces the logged oc_filecache query, then compare the request behavior with Elasticsearch enabled; done means results from an earlier, less specific search no longer overwrite results for the newer query.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elasticsearch, php, postgresql
- Domain
- backend, search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100