Getting Started

In this section, we are going to examine the structure of the client library.

You will be using KimolaClient class to work with Kimola Search. KimolaClient is simply a highly encapsulated HttpClient which makes the necessary requests and returns corresponding objects or throw corresponding exceptions.

To use KimolaClient we will need some minor configurations in the App.config or Web.config file of your project. To configure Kimola Search client, you will need an API Key and a service url provided to you by Kimola Team. If you don't have an API Key you can request one here for free trial..

Add the following lines to your config file:
  <configSections>
    <section name="kimola" type="Kimola.Config.KimolaConfigurationSection, Kimola.Search" />
  </configSections>

  <kimola>
    <api url="http://api.kimola.com/search/v1" key="0123456789ABCDEF" />
    <document defaultPartSpace="ps" defaultCulture="en" />
  </kimola>
Now you are ready to go. Let's begin with a simple search query:
KimolaClient kimolaClient = new KimolaClient();

KResult result = kimolaClient.Search("test", "BlackBerry+IPhone", KCriteria.RelationalDescending, 0, 10);
Console.WriteLine("ApproximateCount: " + result.ApproximateCount);
Console.WriteLine("Duration: " + result.Duration);

foreach (KResultItem item in result.Items)
{
    Console.WriteLine(item.Title);
    Console.WriteLine(item.Content);
    Console.WriteLine(item.ImageUrl);
    Console.WriteLine();
}

Let's explain what we did here. First line is to create a new instance of KimolaClient. KimolaClient's empty constructor tries to read needed values (API Key & service Url) from config file. If you did a mistake in config file you will get an exception about it. Always double check your config file.

KimolaClient's Search method wants some parameters to run. Following table explains some details about parameters passed:

Parameter Description
partspace A Part Space name to search only in that part space. Pass null to search in all part spaces under your API Key
term The term needed to be search. Search term can be made of one or more words. eg. "Microsoft", "United Nations", "NASA" etc.
criteria Determines the sort order of the search results. See KCriteria for more detailed informaton about sort order.
pageIndex This is the result page number for search results to create paging structure
pageLength This is the result page length that determines how many result will be returned in a single result page.

Search method returns a KResult object with ApproximateCount, Duration and an Items field possibly filled with documents related to the query. Then you can use these results to construct your UI.

Last edited Jul 4, 2014 at 11:01 AM by Kimola, version 11

Comments

No comments yet.