fulltextsearch
fulltextsearch copied to clipboard
Deleting a file causes `Exception while improving searchresult` in Nextcloud log
Steps to reproduce:
- Install the Full text search, Full text search - Elasticsearch Platform, and Full text search - Files apps on Nextcloud.
- Set up the Full text search app in the settings of Nextcloud (with "Extract Office" feature enabled and the "ingest-attachment" elasticsearch plugin installed).
- Create a .docx file (in either a group folder or a local user folder) via the OnlyOffice Nextcloud app.
- Add some random text to the .docx OnlyOffice file and save it.
- Run Nextcloud
cron.phpandocc fulltextsearch:index(or even create asystemctlservice for live indexing). - Search the random text in the .docx file to verify it was indexed (which it is indeed indexed and both the "Navigation Icon" search and the Nextcloud search show the file the text is located in correctly).
- Delete the .docx file.
- Run Nextcloud
cron.phpandocc fulltextsearch:index(or use thesystemctlservice for live indexing). - Search for the random text which generates the warning log message below and yields the following result in this image:

As shown, the result shows that "Test" returned 1 results in 7 ms, but doesn't show the file it's in since there isn't any un-deleted file that contains the "Test" text on my Nextcloud instance. Additionally, here is the warning that gets logged in the Nextcloud log:
[files_fulltextsearch] Warning: Exception while improving searchresult: - trace: [{"file":"\/var\/www\/<redacted>\/apps\/files_fulltextsearch\/lib\/Service\/SearchService.php","line":275,"function":"getFileFromId","class":"OCA\\Files_FullTextSearch\\Service\\FilesService","type":"->"},{"file":"\/var\/www\/<redacted>\/apps\/files_fulltextsearch\/lib\/Service\/SearchService.php","line":235,"function":"setDocumentInfo","class":"OCA\\Files_FullTextSearch\\Service\\SearchService","type":"->"},{"file":"\/var\/www\/<redacted>\/apps\/files_fulltextsearch\/lib\/Provider\/FilesProvider.php","line":362,"function":"improveSearchResult","class":"OCA\\Files_FullTextSearch\\Service\\SearchService","type":"->"},{"file":"\/var\/www\/<redacted>\/apps\/fulltextsearch\/lib\/Service\/SearchService.php","line":203,"function":"improveSearchResult","class":"OCA\\Files_FullTextSearch\\Provider\\FilesProvider","type":"->"},{"file":"\/var\/www\/<redacted>\/apps\/fulltextsearch\/lib\/Service\/SearchService.php","line":166,"function":"searchFromProviders","class":"OCA\\FullTextSearch\\Service\\SearchService","type":"->"},{"file":"\/var\/www\/<redacted>\/apps\/fulltextsearch\/lib\/Controller\/ApiController.php","line":129,"function":"search","class":"OCA\\FullTextSearch\\Service\\SearchService","type":"->"},{"file":"\/var\/www\/<redacted>\/apps\/fulltextsearch\/lib\/Controller\/ApiController.php","line":103,"function":"searchDocuments","class":"OCA\\FullTextSearch\\Controller\\ApiController","type":"->"},{"file":"\/var\/www\/<redacted>\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":225,"function":"search","class":"OCA\\FullTextSearch\\Controller\\ApiController","type":"->"},{"file":"\/var\/www\/<redacted>\/lib\/private\/AppFramework\/Http\/Dispatcher.php","line":133,"function":"executeController","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"\/var\/www\/<redacted>\/lib\/private\/AppFramework\/App.php","line":172,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->"},{"file":"\/var\/www\/<redacted>\/lib\/private\/Route\/Router.php","line":298,"function":"main","class":"OC\\AppFramework\\App","type":"::"},{"file":"\/var\/www\/<redacted>\/lib\/base.php","line":1023,"function":"match","class":"OC\\Route\\Router","type":"->"},{"file":"\/var\/www\/<redacted>\/index.php","line":36,"function":"handleRequest","class":"OC","type":"::"}]
GET /apps/fulltextsearch/v1/search?request=%7B%22providers%22%3A%22all%22%2C%22options%22%3A%7B%22files_local%22%3A%220%22%2C%22files_group_folders%22%3A%220%22%2C%22files_extension%22%3A%22%22%7D%2C%22search%22%3A%22Test%22%2C%22page%22%3A1%7D
from 191.96.206.13 by <redacted> at 2022-05-23T20:01:13+00:00
Edit: it appears that after an hour or so, the problem fixes itself. Perhaps after several indexes have been run, the elasticsearch index on the deleted file is finally deleted. This is still an issue though.