Try Now
More in this section

Forums / Developing with Sitefinity / How to consume XML Files Into Sitefinity 7.3 Search

How to consume XML Files Into Sitefinity 7.3 Search

2 posts, 0 answered
  1. Andres
    Andres avatar
    1 posts
    09 Jul 2015
    09 Jul 2015
    Link to this post
    Looking to add\update an index with xml information.  The parsing of the xml I can take care of, but whenever I try to run UpdateIndex featured here http://docs.sitefinity.com/for-developers-index-external-content it throws back an error "Object reference not set to an instance of an object"   I'm not changing anything about the code and using the name I use when implementing a custom search widget and I'm not getting anywhere.  Any suggestions on why its not working or what information I am missing.
  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    17 Oct 2016
    14 Jul 2015
    Link to this post
    Hi Andres,

    You can try the following code sample in order to add additional information in your search index. This is extended sample that includes url and multilingual support, if needed:
    public void AddSearchDocument()
        var fields = new List<IField>();
        // The identity field
        var identityFld = new Telerik.Sitefinity.Services.Search.Publishing.Field();
        identityFld.Name = "Id";
        identityFld.Value = "Some unique identifier3";
        var myTitleField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
        myTitleField.Name = "Title";
        myTitleField.Value = "My title";
        var myContentField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
        myContentField.Name = "Content";
        myContentField.Value = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
        // In case of multilingual
        var myLanguageField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
        myLanguageField.Name = "Language";
        myLanguageField.Value = "en";
        // Include the Url of the item
        var myUrlField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
        myUrlField.Name = "Link";
        myUrlField.Value = "http://www.sitefinity.com";
        var mySummaryField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
        mySummaryField.Name = "Summary";
        mySummaryField.Value = "Summary text";
        var lastModifiedField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
        lastModifiedField.Name = "LastModified";
        lastModifiedField.Value = DateTime.UtcNow;
        // Create the document, containing the fields that we constructed
        var doc = new Telerik.Sitefinity.Services.Search.Model.Document(fields, "Id");
        // index the created document
        ServiceBus.ResolveService<ISearchService>().UpdateIndex("testindex", new List<IDocument>() { doc });

    please also check the Using you have (for example Field and Document) if corresponds to the mentioned in the above sample.

    Svetoslav Manchev
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
2 posts, 0 answered