In this tutorial we will see how to:
  • Set up development environment,
  • indexing,
  • batch indexing,
  • unindexing documents.

Set Up Development Environment

Let's start by opening a new Console Application project in Visula Studio. Then add following lines into App.config file:
    <section name="kimola" type="Kimola.Config.KimolaConfigurationSection, Kimola.Search" />
    <api url="" key="0123456789ABCDFE" />
    <document defaultPartSpace="ps" defaultCulture="en" />
First section with the configSection tag tells that there should be a kimola tag in the file that represents KimolaConfigurationSection.

Second section with kimola tags contains actual configuration information. url property will be set to API's service url, this url seems likely will not change, when it changes we'll inform. key property is where you will put your API Key. If you didn't get your API Key yet, request one now. Other two property inside document tag, defaultPartSpace and defaultCulture are self-explaining themselves. Let's continue to real action (:


First thing is first, you will need a KimolaClient instance to work with. Then we will create a new KimolaDocument and then index it:
KimolaClient kimolaClient = new KimolaClient();

// Get a fresh new KimolaDocument instance from kimolaClient then populate properties however you want.
KimolaDocument kimolaDocument = kimolaClient.CreateDocument();
kimolaDocument.PartSpace = "test";
kimolaDocument.Tag = "ghandi";
kimolaDocument.DocumentDate = DateTime.Now;
kimolaDocument.Url = "";
kimolaDocument.Title = "Sample Blog Post";
kimolaDocument.Content = "This is a blog post authored by Mohandas Gandhi.";
kimolaDocument.Fields.Add("ImageURI", "");

// Finally send the document to client to index

That's it! You just indexed a document and you can use it to get search results. But we will discuss it later. Let's do some batch indexing.

Batch Indexing

It's also simple enough. Only difference is you will be sending KimolaDocument array instead of single KimolaDocument. Let's see the codes:
KimolaClient kimolaClient = new KimolaClient();

// Instantiate a List<KimolaDocument> then add 10 KimolaDocument and populate properties however you want.
List<KimolaDocument> kimolaDocuments = new List<KimolaDocument>();
KimolaDocument kimolaDocument = null;

for (int i = 0; i < 10; i++)
     kimolaDocument = kimolaClient.CreateDocument();
     kimolaDocument.PartSpace = "test";
     kimolaDocument.Tag = i;
     kimolaDocument.Url = string.Format("{0}.html", i);
     kimolaDocument.Title = string.Format("Page Title {0}", i);
     kimolaDocument.Content = string.Format("This is smaple page content for page {0}", i);
     kimolaDocument.Fields.Add("ImageURI", "");


// Finally send the document to client to index

Only difference is this time we used BatchIndex method and passed a KimolaDocument array as parameter. Your documents are indexed like a boss.
Important Note: Maximum length limit of the array you send is 10! And also every KimolaDocument has a size limit of 1 MB.

Unindexing Documents

Now it's unindexing time. Let's see how to do it with a few lines of code:
KimolaClient kimolaClient = new KimolaClient();

Uri uri = new Uri("");
string partSpace = "test";
kimolaClient.UnIndex(uri, partSpace);

It's that simple. You just passed the url (as you will remember it's also unique identifier of a document), then rest is handled by Kimola Search API.

As far, we learned how to do index, batch index, unindex and how to set up our KimolaClient with config file. From now on, other tutorials will use the set up section of this tutorial to prepare config file.

Last edited Jul 24, 2014 at 1:29 PM by Kimola, version 8


No comments yet.