Ejemplo n.º 1
0
 public void TestTextIndexCreation()
 {
     if (_primary.InstanceType != MongoServerInstanceType.ShardRouter)
     {
         if (_primary.Supports(FeatureId.TextSearchCommand))
         {
             var collection = _database.GetCollection <BsonDocument>("test_text");
             collection.Drop();
             collection.CreateIndex(IndexKeys.Text("a", "b").Ascending("c"), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
             var indexes = collection.GetIndexes();
             var index   = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");
             Assert.AreEqual("idioma", index["language_override"].AsString);
             Assert.AreEqual("spanish", index["default_language"].AsString);
             Assert.AreEqual(1, index["key"]["c"].AsInt32);
         }
     }
 }
Ejemplo n.º 2
0
        public void TestTextIndexCreation()
        {
            RequireServer.Check().VersionGreaterThanOrEqualTo("2.6.0").ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet);
            var collection = _database.GetCollection <Test>("test_text");

            collection.Drop();
            collection.CreateIndex(IndexKeys <Test> .Text(x => x.A, x => x.B).Ascending(x => x.C), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
            var indexes = collection.GetIndexes();
            var index   = indexes.RawDocuments.Single(i => i["name"].AsString == "custom");

            Assert.Equal("idioma", index["language_override"].AsString);
            Assert.Equal("spanish", index["default_language"].AsString);
            Assert.Equal(1, index["key"]["c"].AsInt32);
        }
Ejemplo n.º 3
0
 public void TestTextIndexCreation()
 {
     if (_primary.InstanceType != MongoServerInstanceType.ShardRouter)
     {
         if (_primary.Supports(FeatureId.TextSearchCommand))
         {
             using (_server.RequestStart(null, _primary))
             {
                 var collection = _database.GetCollection <Test>("test_text");
                 collection.Drop();
                 collection.CreateIndex(IndexKeys <Test> .Text(x => x.A, x => x.B).Ascending(x => x.C), IndexOptions.SetTextLanguageOverride("idioma").SetName("custom").SetTextDefaultLanguage("spanish"));
                 var indexCollection = _database.GetCollection("system.indexes");
                 var result          = indexCollection.FindOne(Query.EQ("name", "custom"));
                 Assert.AreEqual("custom", result["name"].AsString);
                 Assert.AreEqual("idioma", result["language_override"].AsString);
                 Assert.AreEqual("spanish", result["default_language"].AsString);
                 Assert.AreEqual(1, result["key"]["c"].AsInt32);
             }
         }
     }
 }