Copied to clipboard

Flag this post as spam?

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


  • Marky 26 posts 65 karma points
    Sep 08, 2018 @ 02:17
    Marky
    0

    Direct Lucene.Api is not working after Umbraco Updates

    Hi,

    It's my first to post hope someone can help me or give some ideas.

    It is working in Umbraco 7.5.6 but when I update it to 7.10.3 this code is not working properly, it is getting the old totalproducts.

    var machineName = Environment.MachineName;
    string indexPath = string.Format($"~/App_Data/TEMP/ExamineIndexes/{machineName}/External/Index");
    
    var indexDirectory = FSDirectory.Open(new DirectoryInfo(HttpContext.Current.Server.MapPath(indexPath)));
    
    var searcher = new IndexSearcher(indexDirectory, true);
    TopDocs resp = searcher.Search(masterQuery, null, searcher.MaxDoc());
    
    Debug.WriteLine(resp.TotalHits, "Total Products")
    // Output is always getting the old total which is 79, even if I add/delete product..
    

    I've done rebuilding the Examine, but still doesn't work.

    Can anyone what's wrong with the code? Or does the Examine moved to another folder after Umbraco Updates?

    Appreciate any help and ideas.

    Thanks,

    Marky

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Sep 08, 2018 @ 23:13
    Marc Goodson
    100

    Hi Marky

    If you have a look in your /config/examine.config file in your solution, you'll see the location on disk specified for your external index:

     <!-- Default Indexset for external searches, this indexes all fields on all types of nodes-->
      <IndexSet SetName="ExternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/External/" />
    

    In Umbraco 7.5, this 'used' to include a machine name in the path eg:

    So my guess is during the upgrade, you perhaps switched to use the version of the examine.config shipped with 7.10.3

    Therefore whenever you build your indexes via the backoffice, the build correctly, however they now are located in this folder:

    /App_Data/TEMP/ExamineIndexes/External/

    (you can have a look on disk and see if they are there)

    However your custom code above is looking for the files in the following location:

    ~/App_Data/TEMP/ExamineIndexes/{machineName}/External/Index

    and so isn't reading the 'latest' version of the indexes...

    but instead a snapshot of the indexes before the upgrade! hence the old value for totalproducts

    So if you can have a couple of options: either change your custom code to point to the new index location:

    eg

    string indexPath = string.Format($"~/App_Data/TEMP/ExamineIndexes/External/Index");
    
    var indexDirectory = FSDirectory.Open(new DirectoryInfo(HttpContext.Current.Server.MapPath(indexPath)));
    

    or change your current post upgrade ExamineIndex.config location to point to your path that contains the machinename variable.

    regards

    Marc

  • Marky 26 posts 65 karma points
    Sep 10, 2018 @ 03:18
    Marky
    0

    Hi Marc,

    Ohh Crap, it's working now.

    But how this happen? When I look into my ExamineIndex.config file, {machineName} is missing after Updates, but I don't receive any logs/messages during the updates.

    Anyways, thanks for your help.

    Good day to you,

    Cheers,

    Marky

Please Sign in or register to post replies

Write your reply to:

Draft