Exemplo n.º 1
0
 private static void CreateIndexIfNotExists()
 {
     var indexTankClient = new IndexTankClient(_indexTankApiUrl);
     if (!indexTankClient.GetIndexes().Any(x => x.Name == _indexName))
     {
         indexTankClient.CreateIndex(_indexName);
     }
 }
Exemplo n.º 2
0
        public void Cleanup()
        {
            IndexTankClient client = new IndexTankClient(APIURL);
            IndexTank.IndexTankClient.Index index = client.GetIndex(INDEX_NAME);

            if (index.Exists())
                index.Delete();
        }
Exemplo n.º 3
0
        public void CanCreateIndex()
        {
            IndexTankClient client = new IndexTankClient(APIURL);
            IndexTank.IndexTankClient.Index index = client.GetIndex(INDEX_NAME);

            if (index.Exists())
                index.Delete();

            index.Create();

            Assert.IsTrue(index.Exists());

            index.Delete();

            Assert.IsFalse(index.Exists());
        }
Exemplo n.º 4
0
        public void CanAddDocumentToIndexAndSearch()
        {
            IndexTankClient client = new IndexTankClient(APIURL);
            IndexTank.IndexTankClient.Index index = client.GetIndex(INDEX_NAME);

            if (!index.Exists())
                index.Create();

            Assert.IsTrue(index.Exists());

            while (index.HasStarted() == false)
                System.Threading.Thread.Sleep(1000);

            var fields = new Dictionary<string, string>{
                             {"text", "This is a test document"}, 
                             {"category", "test material"}
            };

            index.AddDocument("DOC1", fields);

            fields = new Dictionary<string, string>{
                             {"text", "This is another document"}, 
                             {"category", "test material"}
            };

            index.AddDocument("DOC2", fields);

            fields = new Dictionary<string, string>{
                             {"text", "Nothing better then localhost"}, 
                             {"category", "test material"},
                             {"price", "4,00"}
            };

            index.AddDocument("DOC3", fields);

            // Sleep to they can get processed
            System.Threading.Thread.Sleep(3000);

            var query = new Query("text:document");
            query.WithFetchFields(new[] { "text", "category", "price" });

            var results = index.Search(query);

            Assert.IsNotNull(results);

        }
Exemplo n.º 5
0
        public void CanAddDocumentToIndex()
        {
            IndexTankClient client = new IndexTankClient(APIURL);
            IndexTank.IndexTankClient.Index index = client.GetIndex(INDEX_NAME);

            if (!index.Exists())
                index.Create();

            Assert.IsTrue(index.Exists());

            while (index.HasStarted() == false)
                System.Threading.Thread.Sleep(1000);

            var fields = new Dictionary<string, string>{
                             {"text", "This is a test document"}, 
                             {"category", "test material"}
            };

            index.AddDocument("DOC1", fields);

        }
Exemplo n.º 6
0
 public static Index GetIndexTankIndex()
 {
     var indexTankClient = new IndexTankClient(_indexTankApiUrl);
     return indexTankClient.GetIndex(_indexName);
 }