Important Note: If you didn't prepare a config section in your App.config or Web.config, see the first tutorial before reading this one.
In this tutorial we will see how to search your documents.

Search method, returns a KResult it has four properties, ApproximateCount, Duration, Phrases and Items as KResultItem array. Later you can use this Items property to traverse the search results.

Let's start:
KimolaClient kimolaClient = new KimolaClient();

KResult kResult = kimolaClient.Search("test", "Mashable", KCriteria.RelationalDescending, 0, 10);
//or
KResult kResult = kimolaClient.Search("test", "Mashable", KCriteria.RelationalDescending, 0, 10, new DateTime(2014, 7, 12, 0, 0, 0), new DateTime(2014, 7, 14, 0, 0, 0));

// Get ApproximateCount and Duration
int count = kResult.ApproximateCount;
double duration = kResult.Duration;

// Get first item's Title
string FirstTitle = kResult.Items.FirstOrDefault().Title;

Let me explain parameters first:
partSpace: In this example part space passed test. so we tell to API that we want to search inside all the documents which has partspace as test of our API Key. Partspace parameter can't passed as null.
term: This is the term that will be searched. In this case it is "Mashable"
criteria: We passed HarisCriteria.RelationalDescending enum. Thus our result set will be sorted by correlation value from most related to least related.
pageIndex: This parameter will be used to implement a pagination. In this case we tell to API to get first page of result set.
pageLength: This parameter will also be used to implenet pagination. In this case we tell to API that we want to get 10 items per page.
startDate: This value specifies the UTC date range for documents to be searched. If passed null, search will perform from the very begining.
endDate: This value specifies the UTC date range for documents to be searched. If passed null, search will perform until UTC now.

You can now use your results to do whatever you want to do. Simple, isn't it?

Last edited Jul 15, 2014 at 3:58 PM by Kimola, version 7

Comments

No comments yet.