예제 #1
0
        public void MergeDocument_GetItBack()
        {
            IIndex index    = indexCreationOptions.CreateIndex();
            var    document = new DocumentInfo("id1", TestDocumentSource.Instance);
            var    words    = new[] { "cat", "category" };

            index.Merge(document, words).Wait();

            foreach (var word in words)
            {
                Assert.That(index.GetExactWord(word).Single(), Is.EqualTo(document));
            }

            foreach (var partialWord in new[] { "cat", "ca" })
            {
                var catDocuments = index.GetWordsStartWith(partialWord);
                Assert.That(catDocuments, Has.Count.EqualTo(words.Count()));
                foreach (var documents in catDocuments)
                {
                    Assert.That(documents.Single(), Is.EqualTo(document));
                }
            }
            Assert.That(index.GetWordsStartWith("cate"), Has.Count.EqualTo(1));

            index.Merge(document, Enumerable.Empty <string>()).Wait();
            foreach (var word in words)
            {
                Assert.That(index.GetExactWord(word), Is.Empty);
            }
            Assert.That(index.GetIndexedWords(), Is.Empty);
        }
예제 #2
0
        /// <summary>
        ///  Creates Indexer with the specified <see cref="IndexerCreationOptions"/>
        /// </summary>
        /// <param name="options">Options that define indexer behavior: word comparsion, index locking, document parser</param>
        public static IndexerSet Create([NotNull] IndexerCreationOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            var index  = options.CreateIndex();
            var parser = options.GetDefaultStreamParser();

            return(new IndexerSet(index, parser));
        }
예제 #3
0
        public void StartsWith_UsingInvariantComparison()
        {
            var indexCreationOptions = new IndexerCreationOptions()
            {
                IndexLocking   = this.indexCreationOptions.IndexLocking,
                WordComparison = StringComparison.InvariantCultureIgnoreCase
            };
            IIndex index    = indexCreationOptions.CreateIndex();
            var    document = new DocumentInfo("id1", TestDocumentSource.Instance);
            var    words    = new[] { "Schrœdinger", "Schroedinger", "Schroeder" };

            index.Merge(document, words).Wait();
            Assert.That(index.GetIndexedWords(), Has.Count.EqualTo(2));

            Assert.That(index.GetWordsStartWith("schroe"), Has.Count.EqualTo(2));
            Assert.That(index.GetWordsStartWith("schrœ"), Has.Count.EqualTo(2));
        }