Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Carlos Gomes 38 posts 184 karma points
    Apr 18, 2019 @ 10:06
    Carlos Gomes
    0

    Accessing Media library files without accessing Examine Internal Index

    Hi guys,

    Is there any way to access all the media files in Umbraco without using the Examine Indexes?

    We are facing some issues in our client environments because of the following: per each environment, we have two servers: one that has access to the Umbraco back office (only accessible on their network), and another that doesn't.

    The problem here is: we don't use the Examine indexes, we use the FullTextSearch (https://our.umbraco.com/packages/website-utilities/full-text-search/). Since we don't use that, we are not building the indexes in the environments.

    Our client has requested to create a PDF index sitemap, and that is working properly in the server that has access to the Umbraco backoffice because I'm able to create the indexes through the Examine Management screen (in the developer tools). However, since we don't have access to the Umbraco backoffice on the other environment, we are not able to create the Examine Indexes in there, and we have some cache issues because the PDF files are not being indexed in the page.

    A possible solution would be to build the indexes in all the environments, but I'm just trying to understand if we have any other solution for that without accessing the Examine Internal Indexes.

    We are accessing the media library this way:

    @ListPDFFiles(Umbraco.TypedMediaAtRoot())

    @helper ListPDFFiles(IEnumerable

    foreach (var mediaNode in mediaStartNode)
    {
        if (mediaNode.DocumentTypeAlias == "File")
        {
            if (mediaNode.GetPropertyValue<string>("UmbracoExtension") == "pdf")
            {
                <url>
                    <loc>@GetUrlWithDomainPrefix(mediaNode.Url)</loc>
                    <lastmod>@(string.Format("{0:s}+00:00", mediaNode.UpdateDate))</lastmod>
                </url>
            }
        }
    
        if (mediaNode.Children.Any())
        {
            @ListPDFFiles(mediaNode.Children)
        }
    }
    

    }

    Thanks for your help in advance,

  • Alex Skrypnyk 6175 posts 24176 karma points MVP 8x admin c-trib
    Apr 18, 2019 @ 14:13
    Alex Skrypnyk
    100

    Hi Carlos

    One more possible solution - use MediaService to access the media instead of Umbraco helper, it will be slower, but it works without ExamineIndexes and it retrieves the data directly from the database.

    Maybe if you add caching it will work for you.

    Thanks,

    Alex

  • Carlos Gomes 38 posts 184 karma points
    Apr 24, 2019 @ 17:27
    Carlos Gomes
    0

    Hi Alex,

    Thanks for your help on this! I was able to accomplish the request with the suggestion that u gave.

    I did the following:

    XML sitemap - hitting umbraco file cache, since I have a model in context when the user accesses the sitemap page PDF sitemap - hitting the DB directly. I haven't cached the files because the performance were not that difference between hitting the Examine Index and hitting the DB (I'm assuming that's because our client doesn't have that much files)

    Thanks,

Please Sign in or register to post replies

Write your reply to:

Draft