Media files usage index doesn't exist (when upload media file with code)

Ömer Karagülmez asked on September 22, 2022 10:11

Hello,

In my web project developed with Kentico 13, i have a problem.

When i uploaded a media file (.pdf) with code. We are getting error like “Media files usage index doesn't exist.”. I can see this exception logs in EventLog and SmartSearch Local tasks. (btw. IISUSER has all permissions for upload a file to file system)

--Event-Log-- https://prnt.sc/-vEdbUot3pKW

--Smart Search-- https://prnt.sc/tpZsNkaUZ74Q

Thanks.

Recent Answers


Brenden Kehren answered on September 22, 2022 18:49

Did you upgrade to this version you're on and apply the latest hotfix? If so, check the Smart Search > Local Indexes and ensure the Media file usage search index exists. If it doesn't, I'd suggest doing a clean install of v13 and applying at least refresh 5 then exporting that scheduled task out and importing it into your instance.

If the index is in the system, then ensure the user running the app pool has access to read/write in the App_Data directory.

0 votesVote for this answer Mark as a Correct answer

Ömer Karagülmez answered on September 22, 2022 22:04 (last edited on September 22, 2022 22:07)

Thank you for quick answer Brenden.

I cannot upgrade because of some reasons.(about our client) I tought upgrade isn't necessary because it was working properly.

I don't have any local indexes. How can i create media file usage search index? And why should i create local index? I didn't define an index until now. The app pool has all accesses by the way. (I checked it)

And this files could be saved to Live site File System ({libName}/media/{FolderName}). Just not exist in media library.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 22, 2022 22:08

What hotfix of version 13 are you on? Something happened that caused that search index to be removed or not created. You're not able to delete it because it's a system index. So my guess is when the hotfix was applied and you moved to Refresh 5 (hotfix 65 or higher) the index didn't get created however there is a scheduled task or some other Kentico code looking to rebuild that index and it can't find the index so it errors out.

0 votesVote for this answer Mark as a Correct answer

Ömer Karagülmez answered on September 22, 2022 22:24

The search index never exists. Actually, I uploaded some IFormFile objects and the files can be uploaded to file system. I just can't see these in media library. And after your answer i create a local index. (i chose object name is media file). Now i can see the files in local tasks. I know importance of actual hotfixes but i don't use Kentico Installer and another kentico tools. (because we copied only CMS files when we had been migrated this site.)

Maybe it will be helpful if you review my code about upload file. Image Text

Thanks.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 22, 2022 22:27

The code isn't the problem, the problem is you are missing some pieces within the database that were deleted/removed/never added.

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.