How to index data from a api in Find

Vote:
 

Hi guys, 

In a project, I have built a news archive page type and a news page type in CMS for showing the press releases. 

The data that shows on a news page get from a api (with querystring parmeter in url Http://locallsot:17000/news/?item_id=123456&type_of_media=news)

http://www.mynewsdesk.com/services/pressroom/view/unique key/?[item_id=id]&[type_of_media=pressrelease]

My question is how can I index the data in Find? The data gets directly from api and send to frontend in a reach compoent. 

string xmlStr;
using (var wc = new WebClient())
{
wc.Encoding = Encoding.UTF8;
xmlStr = wc.DownloadString(Api);
}
XmlDocument doc = new XmlDocument();
doc.LoadXml(xmlStr);
var item = new News();

foreach (XmlNode node in doc.SelectNodes("item"))
{
item.Header = node.SelectSingleNode("header").InnerText;
item.PublishDate = node.SelectSingleNode("published_at").InnerText;
item.Body = node.SelectSingleNode("body").InnerText;
if (node.SelectSingleNode("image") != null)
item.Image = node.SelectSingleNode("image").InnerText;

News = item;
}


public News news { get; set; }



Thanks!


                    
#197131
Sep 24, 2018 14:30
Vote:
 

Yes, you can basically index any data in Find: https://world.episerver.com/documentation/developer-guides/find/NET-Client-API/Indexing/

In your case you need a list of all the items you want to index, and you could create a scheduled job that index all press releases.

Another option that I've used in these kind of scenarios, is to create pages in Episerver and fill them with data from the press releases. That way you atutomatically get a nice SEO friendly url. But if there are thousands of press releases that might not be the best approach.

#197132
Sep 24, 2018 14:51
Vote:
 

Hi Erik, 

I am considering your second option to create news page programmtically since the website has around 100 press releases. 

Thanks for the tips! 

#197139
Sep 24, 2018 15:42
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.