using GroupDocs.Search;
using GroupDocs.Search.Results;

namespace PerformBooleanSearchUsingCSharp
{
    internal class Program
    {
        static void Main(string[] args)
        {
            // Apply the license to remove the restrictions 
            // imposed by the Search library
            License lic = new License();
            lic.SetLicense(@"GroupDocs.Search.lic");

            string indexFolder = @"d:\MyIndex\";
            string documentsFolder = @"d:\MyDocuments\";

            // Creating an index in the specified folder
            Index index = new Index(indexFolder);

            // Indexing documents from the specified folder
            index.Add(documentsFolder);

            // Search with text query
            SearchResult result1 = index.Search("theory AND relativity");

            // Search with object query
            SearchQuery wordQuery1 = SearchQuery.CreateWordQuery("theory");
            SearchQuery wordQuery2 = SearchQuery.CreateWordQuery("relativity");
            SearchQuery andQuery = SearchQuery.CreateAndQuery(wordQuery1, wordQuery2);
            SearchResult result2 = index.Search(andQuery);
        }
    }
}