How to consume XML Files Into Sitefinity 7.3 Search

Posted by Community Admin on 04-Aug-2018 21:12

How to consume XML Files Into Sitefinity 7.3 Search

All Replies

Posted by Community Admin on 09-Jul-2015 00:00

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.

Posted by Community Admin on 14-Jul-2015 00:00

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";
    fields.Add(identityFld);
 
    var myTitleField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
    myTitleField.Name = "Title";
    myTitleField.Value = "My title";
    fields.Add(myTitleField);
 
    var myContentField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
    myContentField.Name = "Content";
    myContentField.Value = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
    fields.Add(myContentField);
 
    // In case of multilingual
    var myLanguageField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
    myLanguageField.Name = "Language";
    myLanguageField.Value = "en";
    fields.Add(myLanguageField);
 
    // Include the Url of the item
    var myUrlField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
    myUrlField.Name = "Link";
    myUrlField.Value = "http://www.sitefinity.com";
    fields.Add(myUrlField);
 
    var mySummaryField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
    mySummaryField.Name = "Summary";
    mySummaryField.Value = "Summary text";
    fields.Add(mySummaryField);
 
    var lastModifiedField = new Telerik.Sitefinity.Services.Search.Publishing.Field();
    lastModifiedField.Name = "LastModified";
    lastModifiedField.Value = DateTime.UtcNow;
    fields.Add(lastModifiedField);
 
    // 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.

Regards,
Svetoslav Manchev
Telerik
 
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
 

This thread is closed