예제 #1
0
        public async Task FreeTextSearchWithProximityOperatorTest()
        {
            var prefix = Unique.String;
            var suffix = Unique.String;

            // Create one object with only the mandatory token.
            var obj1 = new APObject("object");

            obj1.Set <string>("stringfield", prefix + " word1" + " word2" + " word3 " + suffix);


            // Create one object with the mandatory token and optional token.
            var obj2 = new APObject("object");

            obj2.Set <string>("stringfield", prefix + " word1" + " word2" + " word3" + " word4" + " word5 " + suffix);

            #if NET40
            await TaskEx.WhenAll(obj1.SaveAsync(), obj2.SaveAsync());
            #else
            await Task.WhenAll(obj1.SaveAsync(), obj2.SaveAsync());
            #endif

            var results = await APObjects.FreeTextSearchAsync("object", "\"" + prefix + " " + suffix + "\"~4");

            Assert.IsTrue(results != null);
            Assert.IsTrue(results.Count == 1);
            Assert.IsTrue(results[0].Id == obj1.Id);
        }
예제 #2
0
        public async Task FreeTextSearchWithMinusOperatorTest()
        {
            var mandatoryToken = Unique.String;
            var optionalToken  = Unique.String;

            // Create one object with only the mandatory token.
            var obj1 = new APObject("object");

            obj1.Set <string>("stringfield", mandatoryToken);


            // Create one object with the mandatory token and optional token.
            var obj2 = new APObject("object");

            obj2.Set <string>("stringfield", mandatoryToken + " " + optionalToken);


            // Create one object with only optional token
            var obj3 = new APObject("object");

            obj3.Set <string>("stringfield", optionalToken);

            #if NET40
            await TaskEx.WhenAll(obj1.SaveAsync(), obj2.SaveAsync(), obj3.SaveAsync());
            #else
            await Task.WhenAll(obj1.SaveAsync(), obj2.SaveAsync(), obj3.SaveAsync());
            #endif
            var results = await APObjects.FreeTextSearchAsync("object", mandatoryToken + " -" + optionalToken);

            Assert.IsTrue(results != null);
            Assert.IsTrue(results.Count == 1);
            Assert.IsTrue(results[0].Id == obj1.Id);
        }
예제 #3
0
        public async Task FreeTextSearchWithQuestionMarkOperatorTest()
        {
            var prefix = Unique.String;
            var suffix = Unique.String;

            // Create one object with only the mandatory token.
            var obj1 = new APObject("object");

            obj1.Set <string>("stringfield", prefix + "X" + suffix);


            // Create one object with the mandatory token and optional token.
            var obj2 = new APObject("object");

            obj2.Set <string>("stringfield", prefix + "Y" + suffix);

            #if NET40
            await TaskEx.WhenAll(obj1.SaveAsync(), obj2.SaveAsync());
            #else
            await Task.WhenAll(obj1.SaveAsync(), obj2.SaveAsync());
            #endif

            // Delay for index propagation on test bench.
            await Utilities.Delay(1500);

            var results = await APObjects.FreeTextSearchAsync("object", prefix + "?" + suffix);

            Assert.IsTrue(results != null);
            Assert.IsTrue(results.Count == 2);
            Assert.IsTrue(results[0].Id == obj1.Id || results[0].Id == obj2.Id);
            Assert.IsTrue(results[1].Id == obj1.Id || results[1].Id == obj2.Id);
        }
예제 #4
0
        public async Task FreeTextSearchTest()
        {
            var value = Unique.String + " " + Unique.String;
            var obj   = new APObject("object");

            obj.Set <string>("stringfield", value);
            await obj.SaveAsync();

            // Delay for index propagation on test bench.
            await Utilities.Delay(1500);

            var results = await APObjects.FreeTextSearchAsync("object", value);

            Assert.IsTrue(results != null);
            Assert.IsTrue(results.Count == 1);
            Assert.IsTrue(results[0].Id == obj.Id);
        }