Copied to clipboard

Flag this post as spam?

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


  • Damion 96 posts 331 karma points
    Oct 02, 2023 @ 13:28
    Damion
    0

    Indexing pdfs stored in wwwroot

    I'm re-writing an old Umbraco 7 site in Umbraco 10. The v 7 site allowed pdfs to be stored in a folder in wwwroot and indexed them for search purposes.

    In the new site they must still be saved under wwwroot but I cannot find how to index them.

    In the old site the indexing was done in the code below, can anyone suggest how this should be amended?

    public ReturnInformation GetRebuildIndex(int nodeId)
    

    { var status = "Error re-indexing the files. Fact sheets have been made live, but are not indexed correctly.";

    try
    {
        _umbracoContextAccessor.TryGetUmbracoContext(out var context);
        var node = context.Content.GetById(nodeId);
        if (node != null && node.ContentType.Alias == "pdfCollection")
        {
            var clientSpecific = node.GetProperty("clientSpecific")?.GetValue() != null &&
                                 (bool)node.GetProperty("clientSpecific").GetValue();
            if (!clientSpecific)
            {
                // Rebuild the fact sheet index, so non-client-specific fact sheets will be included in the site search
                _examineManager.GetIndex("pdfIndexer").CreateIndex();
                status = "File uploaded and unpacked. Contents are now live and have been re-indexed.";
            }
            else
            {
                status = "File uploaded and unpacked. Contents are now live.";
            }
        }
    }
    catch (Exception e)
    {
        Log.Error( "Rebuilding index", e);
    }
    
    ReturnInformation rtn = new ReturnInformation();
    rtn.ReturnStr = status;
    
    return rtn;
    

    }

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Oct 02, 2023 @ 16:07
Please Sign in or register to post replies

Write your reply to:

Draft