Example #1
0
        public void Execute(IQuery query, long[] expected)
        {
            var notQuery = new NotQuery(query);
            var index    = Substitute.For <IFullTextIndex>();

            index.IndexedDocuments.Returns(Files);
            var actual = notQuery.Execute(index);

            actual.Should().BeEquivalentTo(expected);
        }
Example #2
0
        public void false_in_inverted()
        {
            var mockGameObject = new Mock <GameObject>();
            var mockChildQuery = new Mock <IQuery>();

            mockChildQuery
            .Setup(m => m.Match(mockGameObject.Object))
            .Returns(false);

            var testObject = new NotQuery(mockChildQuery.Object);

            Assert.True(testObject.Match(mockGameObject.Object));
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            var options = new DbOptions();

            options.SetCreateIfMissing();
            IStorageEngine storage = new RocksDbStorage(options, @"C:\Users\Gaetan\RiderProjects\API\Indexer\bin\Debug\net5.0\Index");
            // for (int i = 0; i < 5000; i++)
            // {
            //       JsonDocument gg = JsonSerializer.Deserialize<JsonDocument>("{\"name\":\"john\",\"age\":22,\"class\":\"mca\",\"test\":{\"gg\":2.5}}");
            //       storage.Index(gg);
            // }
            // for (int i = 0; i < 10; i++)
            // {
            //     JsonDocument gg = JsonSerializer.Deserialize<JsonDocument>("{\"name\":\"john\",\"age\":23,\"class\":\"mca\",\"test\":{\"gg\":2.5}}");
            //     storage.Index(gg);
            // }
            // storage.Index(JsonSerializer.Deserialize<JsonDocument>("{\"name\":\"gaetan\",\"age\":25,\"class\":\"mca1\",\"test\":{\"gg\":2.5}}"));
            // storage.Index(JsonSerializer.Deserialize<JsonDocument>("{\"name\":\"amelia\",\"age\":24,\"class\":\"mca2\",\"test\":{\"gg\":2.5}}"));
            // storage.Index(JsonSerializer.Deserialize<JsonDocument>("{\"name\":\"test1\",\"age\":20,\"class\":\"mca3\",\"test\":{\"gg\":2.5}}"));
            // storage.Index(JsonSerializer.Deserialize<JsonDocument>("{\"name\":\"test2\",\"age\":20,\"class\":\"mca3\",\"test\":{\"gg\":2.5}}"));
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();


            // var query = new OrQuery(new List<IQuery>{new TermQuery(Term.FromLong(24)), new TermQuery(Term.FromString("mca3"))});
            var query = new NotQuery(new AndQuery(new List <IQuery>()
            {
                new NotQuery(new TermQuery(".StrainId", Term.FromString("ERR245662"))), new NotQuery(new TermQuery(".StrainId", Term.FromString("DRR034342")))
            }));
            // var query = new AndQuery(new NotQuery(new TermQuery(".StrainId", Term.FromString("DRR034342"))));
            var executor   = query.GetExecutor(storage);
            var enumerator = executor.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.Current);
            }

            stopWatch.Stop();
            // Get the elapsed time as a TimeSpan value.
            TimeSpan ts = stopWatch.Elapsed;

            // Format and display the TimeSpan value.
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                               ts.Hours, ts.Minutes, ts.Seconds,
                                               ts.Milliseconds / 10);

            Console.WriteLine("RunTime " + elapsedTime);
        }
 private Lucene.Net.Search.Query GetNotQuery(NotQuery input)
 {
     var result = new Lucene.Net.Search.BooleanQuery();
     result.Add(ResolveQuery(input.Query), Lucene.Net.Search.BooleanClause.Occur.MUST_NOT);
     return result;
 }