protected override void ExpectResponse(PutMappingResponse response) { // Ensure metadata can be deserialised var metadata = Client.Cluster.State(CallIsolatedValue, r => r.Metric(ClusterStateMetric.Metadata)); metadata.IsValid.Should().BeTrue(); }
/// <summary> /// 优化索引文档写入性能 /// </summary> /// <param name="indexName">索引名称</param> /// <param name="refresh"></param> /// <returns></returns> public async Task <bool> SetIndexRar(string indexName, string refresh = "60s") { var flag = false; try { var response = new PutMappingResponse(); if (_IMemoryCache.TryGetValue("isRar", out bool isRefresh)) { if (!isRefresh) { response = await Client.Indices.PutMappingAsync <TEntity>(x => x.Index(indexName.ToLower()).Timeout(refresh)); if (response.Acknowledged) { flag = true; _IMemoryCache.Set("isRar", true); } } } else { response = await Client.Indices.PutMappingAsync <TEntity>(x => x.Index(indexName.ToLower()).Timeout(refresh)); if (response.Acknowledged) { flag = true; _IMemoryCache.Set("isRar", true); } } } catch (Exception) { } return(flag); }
protected override void ExpectResponse(PutMappingResponse response) { base.ExpectResponse(response); // check the meta shows up in get mapping API var getMappingResponse = Client.Indices.GetMapping <Project>(m => m.Index(CallIsolatedValue)); getMappingResponse.IsValid.Should().BeTrue(); var mappingMeta = getMappingResponse.Indices[CallIsolatedValue].Mappings.Properties["rank"].Meta; mappingMeta.Should().NotBeNull().And.ContainKey("unit"); mappingMeta["unit"].Should().Be("popularity"); // check the meta shows up in field capabilities API var fieldCapsResponse = Client.FieldCapabilities(CallIsolatedValue, f => f .Fields <Project>(ff => ff.Rank) ); fieldCapsResponse.IsValid.Should().BeTrue(); var meta = fieldCapsResponse.Fields["rank"].Integer.Meta; meta.Should().NotBeNull().And.ContainKey("unit"); meta["unit"].Should().BeEquivalentTo("popularity"); }