So while coding against examine to get my search engine working the MediaById calls in all my Razor scripts just suddenly stopped returning a value for the umbracoFile and its really obvious since no images are shown anywhere on the site! Just huge gapping wholes everywhere an image should be.. The only thing that has been done recently was that I installed the Examine Dashboard package in the back office and used it to delete and rebuild some examine indexes. Then out of no where this happened. Do the calls to MediaById rely on the examine indexes?
I went into the back office and pulled up a media image file and re-saved it and that one particular image now shows up. The physical media folder is on the drive and all the image files are there, so thats not the issue. I'm freaking out that this has happened and starting to re-think using Umbraco at all if it can get fubard so easily. I can just imagine three months from now with thousands of image files and having to load and save each one by hand if this were to ever happen again. ugh..
Any thoughts insights into how to get the rest of the files to show up without having to manually re-save each one?
Yes, MediaById() ultimately calls GetUmbracoMedia() which first attemps to look into the InternalIndexSet examine index to find the media then if not found there it has various fallback routines. It seems that these fallback routines have a major defect because if its not in the examine index or in the cache then it should go get it from the database. There is no reason it should return an empty string.
To reproduce:
Open ExamineSettings.config and change the analyzer for the InternalIndexer to Lucene.Net.Analysis.Standard.StandardAnalyzer and rebuild the index.
The solution:
Open ExamineSettings.config and change the analyzer for the InternalIndexer back to its out-of-box value: Lucene.Net.Analysis.WhitespaceAnalyzer and rebuild the index.
So why did I ever change the analyzer in the first place? Thanks for asking. It's because I needed a case-insenstive analyzer for creating a search engine for my site and this change is recommended on numerous forum posts. So what did we learn today kids? Never touch the out-of-box examine indexes and search providers. Invest the five hours of reading through poor documentation and forum posts to figure out how to properly add your own indexes..
Sometimes I seriously question if all the grief Umbraco causes me if it's really worth it.
Example: It took me 10's of hours to find out how to use GetMediaId just to display an <a> to a file uploaded to the media section via Razor... now, files I uploaded a month ago work but new ones don't. WTF??? I saw you post here after spending an hour searching WHY the GetMediaID is return an empty string and I guess when I implemented a PDF searching capability (another 40 some ood hours figuring THAT out) that my indexees are not working properly...
I don't know... I cannot seem to get the GetMediaID to work on NEW files I'm uploading yet the old one do... here is the code that works on some file yet not others????
finding any decent information and/or people to have actual valued responses other than "try this - this should work...." replies from people wanted to just increase their karma is getting very old
DynamicNode MediaById umbracoFile returning empty string
So while coding against examine to get my search engine working the MediaById calls in all my Razor scripts just suddenly stopped returning a value for the umbracoFile and its really obvious since no images are shown anywhere on the site! Just huge gapping wholes everywhere an image should be.. The only thing that has been done recently was that I installed the Examine Dashboard package in the back office and used it to delete and rebuild some examine indexes. Then out of no where this happened. Do the calls to MediaById rely on the examine indexes?
I went into the back office and pulled up a media image file and re-saved it and that one particular image now shows up. The physical media folder is on the drive and all the image files are there, so thats not the issue. I'm freaking out that this has happened and starting to re-think using Umbraco at all if it can get fubard so easily. I can just imagine three months from now with thousands of image files and having to load and save each one by hand if this were to ever happen again. ugh..
Any thoughts insights into how to get the rest of the files to show up without having to manually re-save each one?
And to answer my own question...
Yes, MediaById() ultimately calls GetUmbracoMedia() which first attemps to look into the InternalIndexSet examine index to find the media then if not found there it has various fallback routines. It seems that these fallback routines have a major defect because if its not in the examine index or in the cache then it should go get it from the database. There is no reason it should return an empty string.
To reproduce:
Open ExamineSettings.config and change the analyzer for the InternalIndexer to Lucene.Net.Analysis.Standard.StandardAnalyzer and rebuild the index.
The solution:
Open ExamineSettings.config and change the analyzer for the InternalIndexer back to its out-of-box value: Lucene.Net.Analysis.WhitespaceAnalyzer and rebuild the index.
So why did I ever change the analyzer in the first place? Thanks for asking. It's because I needed a case-insenstive analyzer for creating a search engine for my site and this change is recommended on numerous forum posts. So what did we learn today kids? Never touch the out-of-box examine indexes and search providers. Invest the five hours of reading through poor documentation and forum posts to figure out how to properly add your own indexes..
Joey,
Sometimes I seriously question if all the grief Umbraco causes me if it's really worth it.
Example: It took me 10's of hours to find out how to use GetMediaId just to display an <a> to a file uploaded to the media section via Razor... now, files I uploaded a month ago work but new ones don't. WTF??? I saw you post here after spending an hour searching WHY the GetMediaID is return an empty string and I guess when I implemented a PDF searching capability (another 40 some ood hours figuring THAT out) that my indexees are not working properly...
I don't know... I cannot seem to get the GetMediaID to work on NEW files I'm uploading yet the old one do... here is the code that works on some file yet not others????
<p class="ColumnTwoList"><a target="_blank" href="@Model.MediaById(System.Convert.ToInt32(@item.mediaDocument.ToString())).umbracoFile">@item.resourceLinkName</a>
<img src="/media/6603/newpdficon.png" alt="PDFDocument" class="IconStyle"/><br /></p>
finding any decent information and/or people to have actual valued responses other than "try this - this should work...." replies from people wanted to just increase their karma is getting very old
I had the same issue, but solution proposed by Joey did not help, so I did som debugging and found a different cause and solution, see here:
http://allan-laustsen.blogspot.com/2012/04/umbraco-razor-dynamicmedia-umbracofile.html
I have also submitted the patch here:
http://umbraco.codeplex.com/workitem/30778
is working on a reply...