Indexing files saved under wwwroot in Umbraco 10

34 Views Asked by At

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;
}
0

There are 0 best solutions below