public void FullTextIndexCreationLucenePredicates()
        {
            IFullTextIndexer indexer = null;

            try
            {
                indexer = new LucenePredicatesIndexer(LuceneTestHarness.Index, LuceneTestHarness.Analyzer, LuceneTestHarness.Schema);
                indexer.Index(this.GetTestData());
            }
            finally
            {
                if (indexer != null)
                {
                    indexer.Dispose();
                }
            }
        }
Пример #2
0
        public void FullTextIndexSearchLucenePredicatesWithLimitAndThreshold()
        {
            IFullTextIndexer        indexer  = null;
            IFullTextSearchProvider provider = null;

            try
            {
                indexer = new LucenePredicatesIndexer(LuceneTestHarness.Index, LuceneTestHarness.Analyzer, LuceneTestHarness.Schema);
                indexer.Index(this.GetTestData());
            }
            finally
            {
                if (indexer != null)
                {
                    indexer.Dispose();
                }
            }

            try
            {
                provider = new LuceneSearchProvider(LuceneTestHarness.LuceneVersion, LuceneTestHarness.Index);
                NTriplesFormatter formatter = new NTriplesFormatter();

                int i = 0;
                foreach (IFullTextSearchResult result in provider.Match("http", 1.0d, 5))
                {
                    i++;
                    Console.WriteLine(result.Node.ToString(formatter) + " - Scores " + result.Score);
                    Assert.IsTrue(result.Score >= 1.0d, "Score should be higher than desired threshold");
                }
                Assert.IsTrue(i <= 5, "Should be a max of 5 results");
            }
            finally
            {
                if (provider != null)
                {
                    provider.Dispose();
                }
            }
        }
Пример #3
0
        public void FullTextIndexSearchLucenePredicates()
        {
            IFullTextIndexer        indexer  = null;
            IFullTextSearchProvider provider = null;

            try
            {
                indexer = new LucenePredicatesIndexer(LuceneTestHarness.Index, LuceneTestHarness.Analyzer, LuceneTestHarness.Schema);
                indexer.Index(this.GetTestData());
            }
            finally
            {
                if (indexer != null)
                {
                    indexer.Dispose();
                }
            }

            try
            {
                provider = new LuceneSearchProvider(LuceneTestHarness.LuceneVersion, LuceneTestHarness.Index);
                NTriplesFormatter formatter = new NTriplesFormatter();

                foreach (IFullTextSearchResult result in provider.Match("http"))
                {
                    Console.WriteLine(result.Node.ToString(formatter) + " - Scores " + result.Score);
                }
            }
            finally
            {
                if (provider != null)
                {
                    provider.Dispose();
                }
            }
        }
        public void FullTextIndexDestructionLucenePredicates()
        {
            IFullTextIndexer indexer = null;

            try
            {
                LuceneSearchProvider provider = null;
                int origCount;
                try
                {
                    provider  = new LuceneSearchProvider(LuceneTestHarness.LuceneVersion, LuceneTestHarness.Index);
                    origCount = provider.Match("http").Count();
                    provider.Dispose();
                }
                catch
                {
                    origCount = 0;
                }
                finally
                {
                    if (provider != null)
                    {
                        provider.Dispose();
                    }
                }
                Console.WriteLine("Prior to indexing search returns " + origCount + " result(s)");

                indexer = new LucenePredicatesIndexer(LuceneTestHarness.Index, LuceneTestHarness.Analyzer, LuceneTestHarness.Schema);
                IGraph g = this.GetTestData();
                indexer.Index(g);
                indexer.Dispose();
                indexer = null;

                int currCount;
                try
                {
                    provider  = new LuceneSearchProvider(LuceneTestHarness.LuceneVersion, LuceneTestHarness.Index);
                    currCount = provider.Match("http").Count();
                    provider.Dispose();
                }
                catch
                {
                    currCount = 0;
                }
                finally
                {
                    if (provider != null)
                    {
                        provider.Dispose();
                    }
                }
                Console.WriteLine("After indexing search returns " + currCount + " result(s)");

                indexer = new LucenePredicatesIndexer(LuceneTestHarness.Index, LuceneTestHarness.Analyzer, LuceneTestHarness.Schema);
                indexer.Unindex(g);
                indexer.Dispose();
                indexer = null;
                try
                {
                    provider  = new LuceneSearchProvider(LuceneTestHarness.LuceneVersion, LuceneTestHarness.Index);
                    currCount = provider.Match("http").Count();
                    Console.WriteLine("After unindexing search returns " + currCount + " result(s)");
                }
                finally
                {
                    if (provider != null)
                    {
                        provider.Dispose();
                    }
                }

                Assert.Equal(origCount, currCount);
            }
            finally
            {
                if (indexer != null)
                {
                    indexer.Dispose();
                }
                LuceneTestHarness.Index.Dispose();
            }
        }