public void Setup()
 {
     SKIndex.LoadDefaultExtractorPlugIns();
     if (File.Exists(path))
     {
         File.Delete(path);
     }
 }
        public void TestCreate()
        {
            var idx = SKIndex.CreateWithUrl(new NSUrl("file://" + path), "myIndex", SKIndexType.InvertedVector, null);

            if (idx == null)
            {
                throw new Exception();
            }


            var d1 = new SKDocument(new NSUrl("file:///etc/passwd"));
            var d2 = new SKDocument(new NSUrl("file:///etc/fstab"));

            idx.AddDocument(d1, "text/plain", true);

            idx.AddDocumentWithText(d2, "This file contains some text like an Apple and an Orange", true);

            const int max = 10;

            nint [] ids    = new nint [max];
            float[] scores = new float[max];
            nint    nfound;
            bool    more;

            using (var search = idx.Search("some", SKSearchOptions.SpaceMeansOr)) {
                more = search.FindMatches(max, ref ids, ref scores, 1, out nfound);
                Assert.IsFalse(more);

                for (nint i = 0; i < nfound; i++)
                {
                    var doc = idx.GetDocument(ids [i]);
                    Assert.IsNotNull(doc, "TestCreate - GetDocument returned null");
                }
            }

            using (var search = idx.Search("some", SKSearchOptions.SpaceMeansOr)) {
                more = search.FindMatches(max, ref ids, 1, out nfound);
                for (nint i = 0; i < nfound; i++)
                {
                    var doc = idx.GetDocument(ids [i]);
                    Console.WriteLine("Got {0}", doc);
                }
            }

            idx.Compact();
            idx.Flush();
            idx.Close();

            // Now open
            idx = SKIndex.FromUrl(new NSUrl("file://" + path), "myIndex", true);
            Assert.NotNull(idx);
        }
        public void TestInMemory()
        {
            var m   = new NSMutableData();
            var idx = SKIndex.CreateWithMutableData(m, "indexName", SKIndexType.Inverted, null);

            Assert.NotNull(idx);
            idx.AddDocumentWithText(new SKDocument(new NSUrl("file:///etc/passwd")), "These are the contents of the passwd file, well, not really", true);
            idx.Flush();
            idx.Compact();
            idx.Close();

            idx = SKIndex.FromMutableData(m, "indexName");
            Assert.NotNull(idx);
            idx.Close();
        }
        public void TestTextAnalysis()
        {
            var m          = new NSMutableData();
            var properties = new SKTextAnalysis()
            {
                StartTermChars = "",
                EndTermChars   = "",
                TermChars      = "\"-_@.'",
                MinTermLength  = 3,
                StopWords      = new NSSet("all", "and", "its", "it's", "the")
            };

            var idx = SKIndex.CreateWithMutableData(m, "indexName", SKIndexType.Inverted, properties);

            Assert.NotNull(idx);
        }