API
Version 7.x > API > GetSearchedContent in API View modes: 
User avatar
Member
Member
jwynveen - 11/21/2013 11:29:12 AM
   
GetSearchedContent in API
I am setting up a search through the API (so I can return json results and search via ajax) and am trying to figure out how to format the content that's returned. It returns the values of each of the web parts in XML and CDATA sections. In the default transformation for search results, there is a method used called GetSearchedContent that I'm guessing pulls the content out of that XML. Is that method in the API somewhere? I looked through the methods of SearchHelper and can't find anything like it.

User avatar
Kentico Support
Kentico Support
kentico_romank - 12/10/2013 9:05:36 AM
   
RE:GetSearchedContent in API
Hi,

Could you please check the following file ~/CMSModules/SmartSearch/Controls/SearchResults.ascx.cs. In that file around the line 1401 there is "DataSet results = SearchHelper.Search(parameters);", this dataset contains records from index, that means it contains fields marked as searchable plus some internal fields. If you want to render the results, you can use the dataset and get the real objects from database via this dataset or you can use repeater and aply transformation to it, this transformation will generate JSON format as you need.

Please note, when you perform the search through API it is important to set search parameters (see line 1378).

Best Regards,
Roman Konicek