protected override void ExpectResponse(IGetMappingResponse response) { response.ShouldBeValid(); var visitor = new TestVisitor(); response.Accept(visitor); visitor.CountsShouldContainKeyAndCountBe("type", 1); //ranges property is ignored on versions before 5.2.0 var supportsRanges = TestClient.VersionUnderTestSatisfiedBy(">=5.2.0"); visitor.CountsShouldContainKeyAndCountBe("object", supportsRanges ? 5 : 4); visitor.CountsShouldContainKeyAndCountBe("date", 4); visitor.CountsShouldContainKeyAndCountBe("text", 11); visitor.CountsShouldContainKeyAndCountBe("keyword", 10); visitor.CountsShouldContainKeyAndCountBe("ip", 1); visitor.CountsShouldContainKeyAndCountBe("number", 3); visitor.CountsShouldContainKeyAndCountBe("geo_point", 2); visitor.CountsShouldContainKeyAndCountBe("completion", 2); visitor.CountsShouldContainKeyAndCountBe("nested", 1); if (supportsRanges) { visitor.CountsShouldContainKeyAndCountBe("date_range", 1); visitor.CountsShouldContainKeyAndCountBe("float_range", 1); visitor.CountsShouldContainKeyAndCountBe("integer_range", 1); visitor.CountsShouldContainKeyAndCountBe("double_range", 1); visitor.CountsShouldContainKeyAndCountBe("long_range", 1); } }
protected override void ExpectResponse(IGetMappingResponse response) { response.ShouldBeValid(); var visitor = new TestVisitor(); response.Accept(visitor); visitor.CountsShouldContainKeyAndCountBe("type", 1); visitor.CountsShouldContainKeyAndCountBe("join", 1); visitor.CountsShouldContainKeyAndCountBe("object", 7); visitor.CountsShouldContainKeyAndCountBe("date", 4); visitor.CountsShouldContainKeyAndCountBe("text", 18); visitor.CountsShouldContainKeyAndCountBe("keyword", 17); visitor.CountsShouldContainKeyAndCountBe("ip", 2); visitor.CountsShouldContainKeyAndCountBe("number", 7); visitor.CountsShouldContainKeyAndCountBe("geo_point", 3); visitor.CountsShouldContainKeyAndCountBe("completion", 2); visitor.CountsShouldContainKeyAndCountBe("nested", 1); visitor.CountsShouldContainKeyAndCountBe("date_range", 1); visitor.CountsShouldContainKeyAndCountBe("float_range", 1); visitor.CountsShouldContainKeyAndCountBe("integer_range", 1); visitor.CountsShouldContainKeyAndCountBe("double_range", 1); visitor.CountsShouldContainKeyAndCountBe("long_range", 1); }
public void Accept(IGetMappingResponse response) { if (response == null) { return; } this.Accept(response.Mapping); }
public void Accept(IGetMappingResponse response) { if (response == null) return; foreach (var indexMapping in response.Mappings) foreach (var typeMapping in indexMapping.Value) { this.Accept(typeMapping.Value); } }
private List <DataEntity> GetSchema(string index, IGetMappingResponse mappings, DataContainer container) { var properties = mappings.Indices[index].Mappings.Values.First().Properties.ToList(); var collection = new DataCollection(container, index); var dataEntities = properties.SelectMany(p => GetSchemaExtensions.GetSchema(p, container, collection)).ToList(); return(dataEntities); }
public static ITypeMapping GetMappingFor(this IGetMappingResponse response, IndexName index) { if (index.IsNullOrEmpty()) { return(null); } if (!response.Indices.TryGetValue(index, out var typeMapping)) { return(null); } return(typeMapping?.Mappings?.FirstOrDefault().Value); }
//hide private static void AssertExtensionMethods(IGetMappingResponse response) { /** The `GetMappingFor` extension method can be used to get a type mapping easily and safely */ response.GetMappingFor <Project>().Should().NotBeNull(); response.GetMappingFor(typeof(Project), typeof(Project)).Should().NotBeNull(); response.GetMappingFor(typeof(Project)).Should().NotBeNull(); /** The following should all return a `null` because we had asked for the mapping of type `doc` in index `project` */ response.GetMappingFor <Developer>().Should().BeNull(); response.GetMappingFor("dev", "dev").Should().BeNull(); response.GetMappingFor(typeof(Project), "x").Should().BeNull(); response.GetMappingFor("dev").Should().BeNull(); }
public static ITypeMapping GetMappingFor(this IGetMappingResponse response, IndexName index, TypeName type) { if (index.IsNullOrEmpty() || type.IsNullOrEmpty()) { return(null); } TypeMapping mapping = null; var hasValue = response.Indices.TryGetValue(index, out var typeMapping) && typeMapping?.Mappings != null && typeMapping.Mappings.TryGetValue(type, out mapping); return(mapping); }
public void Accept(IGetMappingResponse response) { if (response == null) { return; } foreach (var indexMapping in response.Mappings) { foreach (var typeMapping in indexMapping.Value) { this.Accept(typeMapping.Value); } } }
protected override void ExpectResponse(IGetMappingResponse response) { response.IsValid.Should().BeTrue(); var visitor = new TestVisitor(); response.Accept(visitor); visitor.CountsShouldContainKeyAndCountBe("type", 1); visitor.CountsShouldContainKeyAndCountBe("object", 2); visitor.CountsShouldContainKeyAndCountBe("date", 4); visitor.CountsShouldContainKeyAndCountBe("string", 17); visitor.CountsShouldContainKeyAndCountBe("ip", 1); visitor.CountsShouldContainKeyAndCountBe("number", 2); visitor.CountsShouldContainKeyAndCountBe("geo_point", 2); visitor.CountsShouldContainKeyAndCountBe("completion", 2); visitor.CountsShouldContainKeyAndCountBe("nested", 1); }
public void Accept(IGetMappingResponse response) { if (response?.Indices == null) { return; } foreach (var indexMapping in response.Indices) { if (indexMapping.Value?.Mappings == null) { continue; } foreach (var typeMapping in indexMapping.Value.Mappings) { this.Accept(typeMapping.Value); } } }
//hide private static void AssertVisitedProperies(IGetMappingResponse response) { var visitor = new TestVisitor(); var b = TestClient.Configuration.Random.SourceSerializer; response.Accept(visitor); visitor.CountsShouldContainKeyAndCountBe("type", 1); visitor.CountsShouldContainKeyAndCountBe("text", b ? 19 : 18); visitor.CountsShouldContainKeyAndCountBe("keyword", b ? 19 : 18); visitor.CountsShouldContainKeyAndCountBe("object", 8); visitor.CountsShouldContainKeyAndCountBe("number", 7); visitor.CountsShouldContainKeyAndCountBe("ip", 2); visitor.CountsShouldContainKeyAndCountBe("geo_point", 3); visitor.CountsShouldContainKeyAndCountBe("date", 4); visitor.CountsShouldContainKeyAndCountBe("join", 1); visitor.CountsShouldContainKeyAndCountBe("completion", 2); visitor.CountsShouldContainKeyAndCountBe("date_range", 1); visitor.CountsShouldContainKeyAndCountBe("double_range", 1); visitor.CountsShouldContainKeyAndCountBe("float_range", 1); visitor.CountsShouldContainKeyAndCountBe("integer_range", 1); visitor.CountsShouldContainKeyAndCountBe("long_range", 1); visitor.CountsShouldContainKeyAndCountBe("nested", 1); }
protected override void ExpectResponse(IGetMappingResponse response) { response.ShouldBeValid(); response.Indices["project"]["doc"].Properties.Should().NotBeEmpty(); response.Indices[Index <Project>()].Mappings[Type <Project>()].Properties.Should().NotBeEmpty(); response.Indices[Index <Project>()][Type <Project>()].Properties.Should().NotBeEmpty(); var properties = response.Indices[Index <Project>()][Type <Project>()].Properties; var leadDev = properties[Property <Project>(p => p.LeadDeveloper)]; leadDev.Should().NotBeNull(); var props = response.Indices["x"]?["y"].Properties; props.Should().BeNull(); //hide AssertExtensionMethods(response); //hide AssertVisitedProperies(response); }
public void Accept(IGetMappingResponse response) { this.Accept(response.Mapping); }
public static ITypeMapping GetMappingFor <T>(this IGetMappingResponse response) => response.GetMappingFor(typeof(T), typeof(T));
public void Accept(IGetMappingResponse response) { if (response == null) return; this.Accept(response.Mapping); }
protected override void ExpectResponse(IGetMappingResponse response) { response.Indices.Should().BeEmpty(); response.ServerError.Should().NotBeNull(); }
protected override void ExpectResponse(IGetMappingResponse response) { response.Mappings.Should().BeEmpty(); response.Mapping.Should().BeNull(); }
private void EagerCreateIndex(Contexts.Mouths.Mouth destination) { IGetMappingResponse mapping = null; try { if (destination.DeleteExisting) { // Get previous mapping mapping = _client.GetMapping <object>(m => { m.Index(destination.Index); m.Type(destination.Type); return(m); }); _client.DeleteMapping(new DeleteMappingRequest(destination.Index, destination.Type)); } } catch (Exception ex) { log.Error(ex); } try { var index = _client.CreateIndex(c => c .Index(destination.Index) .InitializeUsing(new Nest.IndexSettings()) ); _indexCreated = true; if (mapping != null) { // Use previous mapping to create mapping for new index log.Info("Adding previously pulled mapping"); _client.Map <object>(m => { m.InitializeUsing(mapping.Mapping); m.Index(destination.Index); m.Type(destination.Type); return(m); }); } else { // Process parent mapping as normal for type creation if (destination.Mapping != null) { _client.Map <object>(m => { m.Index(destination.Index); m.Type(destination.Type); if (destination.Mapping.Parent != null) { m.SetParent(destination.Mapping.Parent.Type); } return(m); }); } } } catch (Exception ex) { log.Error(ex); throw; } }