ASPX templates
Version 5.x > ASPX templates > Search API access View modes: 
User avatar
Member
Member
john-brando - 6/17/2010 5:58:27 AM
   
Search API access
Hi,

I'm doing a web service which will search the content of my Kentico site. I'm trying to find some sample C# code for the recommended way to search the Kentico content.

Does anybody know what is the best way to do this? There is a SearchHelper object, but I'm not sure this is what I should be calling. Or am I supposed to be using the GetDocuments call. I would like to take advantage of the smart search system if possible.

Cheers
John

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 6/17/2010 8:03:48 AM
   
RE:Search API access
Hi,

You can take a look into ~\CMSModules\SmartSearch\Controls\SearchResults.ascx.cs file into OnPreRender method how to get search results of given search expression.

Basically, you just need to call SearchHelper.Search() method to get search result DataSet.

Best regards,
Miroslav Remias.

User avatar
Member
Member
john-brando - 6/22/2010 4:51:39 AM
   
RE:Search API access
thanks Miroslav

I've been playing around with this for the last couple of days, really cool functionality, very powerful

There is one thing I'm having trouble figuring out though, and that's the syntax of the SearchHelper.GetSort function call. Can you give me some pointer on the syntax of the searchCondition parameter? I would like to sort on various dates attached to a document type.


ps.
A small note, in one of your help articles, it states that the date format is yyyymmddhhmm. When I tried to use this though, it didn't work. I had to use the format yyyymmdd to get it to work (http://devnet.kentico.com/docs/devguide/index.html).

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 6/24/2010 2:16:37 AM
   
RE:Search API access
Hi,

You can configure your smart search filter web part to be not conditional (Filter is conditional: False) and use for example following expression in Values property:

Values:

##SCORE##;;Score (default)
documentcreatedwhen;;Creation date

More information can be found in following documentation:

http://devnet.kentico.com/docs/devguide/smart_search_filter.htm

So, the input value to SearchHelper.GetSort() method would be "documentcreatedwhen" when second option from the smart search filter web part is selected.

Best regards,
Miroslav Remias.