Copied to clipboard

Flag this post as spam?

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


  • Søren Kottal 702 posts 4497 karma points MVP 5x c-trib
    Aug 30, 2019 @ 15:08
    Søren Kottal
    0

    Reindex single node in v8

    Anyone know how to reindex a single node in ExternalIndex in v8?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Aug 30, 2019 @ 15:14
    Matt Brailsford
    0

    I used to do the following in v7

    public static class LuceneHelper
    {
        public static void ReindexNode(int id, string indexName, string indexType)
        {
            var xmlStr = umbraco.library.GetXmlNodeById(id.ToString()).Current.OuterXml;
            var xml = XElement.Parse(xmlStr);
    
            ExamineManager.Instance.IndexProviderCollection[indexName]
                .ReIndexNode(xml, indexType);
        }
    }
    

    I'm not sure how you get the XML for a node now in v8, but hopefully it gives you a starting point.

  • Remko 118 posts 283 karma points
    Aug 30, 2019 @ 15:19
    Remko
    2

    Hi,

    I simply use this:

    ExamineManager.Instance.Indexes.FirstOrDefault(i => i.Name == "ExternalIndex")?.IndexItem(new ValueSet(id));
    

    where id is string

  • Søren Kottal 702 posts 4497 karma points MVP 5x c-trib
    Aug 30, 2019 @ 15:46
    Søren Kottal
    102

    Ooh, didn't know you could just new ValueSet(id)

    I got it working by doing index.IndexItems(_valueSetBuilder.GetValueSets(arrayOfIContents));

    index is the IIndex, _valueSetBuilder is IPublishedContentValueSetBuilder, and e is coming from the Published event on the content service

  • Steve Megson 151 posts 1022 karma points MVP c-trib
    Aug 30, 2019 @ 15:59
    Steve Megson
    1

    I think you have to do it your way. Unless I'm missing something, new ValueSet(id) will just create an object with that ID and no other fields populated, so indexing that won't do the right thing.

Please Sign in or register to post replies

Write your reply to:

Draft