Show language: C# VB.NET Both

Programmatic Searching

To run programmatic searches is fairly straight forward, it involves setting the Configuration to the correct Index Directory and using SearchAgent to run the actual search.

Example Searcher

C#
using System;
using Keyoti.SearchEngine;
using Keyoti.SearchEngine.Search;


public class MyClass
{
	public static void Main()
	{
			
		// Put user code to initialize the page here
		Configuration configuration = new Configuration();
		configuration.IndexDirectory =
		@"C:\...path to your index directory...";
		
		//this Search Pro license key will expire June 2010, evaluators should email support
		//for a key
		string licensekey =
		"59546960665C68616A5B6C6B635C5325413F43453A3F3C463E44434545434F4D51539";
		
		//run a search for "the"
		SearchAgent sa = new SearchAgent(licensekey, configuration);

		//retrieve results 1 through 10
		SearchResult results = sa.Search("the", 1, 10);
		
		//the number of results there actually are in total
		int totalNumberOfResults = results.NumberOfResults;
		
		foreach(ResultItem i in results)
		{
			//the summary from the docmuent
			string summary = i.Summary;
		
			//the title of the document
			string title = i.Title;
		
			//the document URL
			string url = i.UriString;
		
		
			//the weight of the document in the results
			int weight = i.Weight;
			Console.WriteLine(url);
		}
	}
}
VB.NET
Imports System
Imports Keyoti.SearchEngine
Imports Keyoti.SearchEngine.Search


Public Class MyClass1
    
    Public Shared Sub Main()
        ' Put user code to initialize the page here
        Dim configuration As Configuration = New Configuration
        configuration.IndexDirectory = "C:\...path to your index directory..."
        'this Search Pro license key will expire June 2008, evaluators should email support
        'for a key
        Dim licensekey As String = "59546960665C68616A5B6C6B635C5325413F43453A3F3C463E44434545434F4D51539"
        'run a search for "the"
        Dim sa As SearchAgent = New SearchAgent(licensekey, configuration)

        'retrieve results 1 through 10
        Dim results As SearchResult = sa.Search("the", 1, 10)
        'the number of results there actually are in total
        Dim totalNumberOfResults As Integer = results.NumberOfResults
        For Each i As ResultItem In results
            'the summary from the docmuent
            Dim summary As String = i.Summary
            'the title of the document
            Dim title As String = i.Title
            'the document URL
            Dim url As String = i.UriString
            'the weight of the document in the results
            Dim weight As Integer = i.Weight
            Console.WriteLine(url)
        Next
    End Sub
End Class