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 500 posts 3318 karma points MVP 2x 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 2848 posts 14796 karma points MVP 7x 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 94 posts 245 karma points
    Aug 30, 2019 @ 15:19
    Remko
    1

    Hi,

    I simply use this:

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

    where id is string

  • Søren Kottal 500 posts 3318 karma points MVP 2x c-trib
    Aug 30, 2019 @ 15:46
    Søren Kottal
    101

    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 150 posts 942 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