Exemplo n.º 1
0
        private static void CreateEmployeeIndex()
        {
            var settings = new IndexSettings();
              var typeMapping = new TypeMapping("employee");
              var stringNotAnalyzed = new TypeMappingProperty
              {
            Type = "string",
            Index = "not_analyzed"
              };
              //ElasticSearch camel-cases field names
              typeMapping.Properties = new Dictionary<string, TypeMappingProperty>();
              typeMapping.Properties.Add("id", stringNotAnalyzed);
              typeMapping.Properties.Add("companyId", stringNotAnalyzed);

              settings.Mappings.Add(typeMapping);

              settings.NumberOfReplicas = 1;
              settings.NumberOfShards = 5;

              //default analyzer is Standard

              var result = esClient.CreateIndex("employees", settings);
              if (!result.OK)
              {
            Log("Unable to create and configure employees ElasticSearch index");
            return;
              }
              Log("Employees index created");
        }
Exemplo n.º 2
0
 private void TestMapping(TypeMapping typeMapping)
 {
     Assert.NotNull(typeMapping);
     Assert.AreEqual("string", typeMapping.Properties["content"].Type);
     Assert.AreEqual("string", typeMapping.Properties["country"].Type);
     Assert.AreEqual("double", typeMapping.Properties["doubleValue"].Type);
     Assert.AreEqual("long", typeMapping.Properties["longValue"].Type);
     Assert.AreEqual("multi_field", typeMapping.Properties["name"].Type);
     Assert.AreEqual("date", typeMapping.Properties["startedOn"].Type);
     Assert.AreEqual("long", typeMapping.Properties["stupidIntIWantAsLong"].Type);
 }
Exemplo n.º 3
0
        public void CreateIndexMultiFieldMap()
        {
            var client = this.ConnectedClient;

            var typeMapping = new TypeMapping(Guid.NewGuid().ToString("n"));
            var property = new TypeMappingProperty
                           {
                               Type = "multi_field"
                           };

            var primaryField = new TypeMappingProperty
                               {
                                   Type = "string",
                                   Index = "not_analyzed"
                               };

            var analyzedField = new TypeMappingProperty
                                {
                                    Type = "string",
                                    Index = "analyzed"
                                };

            property.Fields = new Dictionary<string, TypeMappingProperty>();
            property.Fields.Add("name", primaryField);
            property.Fields.Add("name_analyzed", analyzedField);

            typeMapping.Properties.Add("name", property);

            var settings = new IndexSettings();
            settings.Mappings.Add(typeMapping);
            settings.NumberOfReplicas = 1;
            settings.NumberOfShards = 5;
            settings.Analysis.Analyzer.Add("snowball", new SnowballAnalyzerSettings { Language = "English" });

            var indexName = Guid.NewGuid().ToString();
            var response = client.CreateIndex(indexName, settings);

            Assert.IsTrue(response.IsValid);
            Assert.IsTrue(response.OK);

            Assert.IsNotNull(this.ConnectedClient.GetMapping(indexName, typeMapping.Name));

            response = client.DeleteIndex(indexName);

            Assert.IsTrue(response.IsValid);
            Assert.IsTrue(response.OK);
        }
Exemplo n.º 4
0
		public void Accept(TypeMapping mapping)
		{
			if (mapping == null) return;
			this._visitor.Visit(mapping);
			this.Accept(mapping.Properties);
		}
Exemplo n.º 5
0
		public virtual void Visit(TypeMapping mapping) { }
Exemplo n.º 6
0
 public virtual void Visit(TypeMapping mapping)
 {
 }