-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relates: #4341 This commit adds the ability to define per-field metadata in mappings, which will be returned via the Get Mapping API and Field Capabilities API. (cherry picked from commit 9bc7470)
- Loading branch information
Showing
9 changed files
with
96 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Elastic.Xunit.XunitPlumbing; | ||
using FluentAssertions; | ||
using Nest; | ||
using Tests.ClientConcepts.HighLevel.CovariantHits; | ||
using Tests.Core.Extensions; | ||
using Tests.Core.ManagedElasticsearch.Clusters; | ||
using Tests.Domain; | ||
using Tests.Framework.EndpointTests.TestState; | ||
using Tests.Mapping.Types; | ||
|
||
namespace Tests.Mapping.Meta | ||
{ | ||
[SkipVersion("<7.6.0", "Meta added in Elasticsearch 7.6.0")] | ||
public class MetaMappingApiTests | ||
: PropertyTestsBase | ||
{ | ||
public MetaMappingApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { } | ||
|
||
protected override Func<PropertiesDescriptor<Project>, IPromise<IProperties>> FluentProperties => p => p | ||
.Number(n => n | ||
.Name(nn => nn.Rank) | ||
.Type(NumberType.Integer) | ||
.Meta(m => m | ||
.Add("unit", "popularity") | ||
) | ||
); | ||
protected override IProperties InitializerProperties => new Properties<Project> | ||
{ | ||
{ n => n.Rank, new NumberProperty(NumberType.Integer) | ||
{ | ||
Meta = new Dictionary<string, string> | ||
{ | ||
{ "unit", "popularity" } | ||
} | ||
} | ||
} | ||
}; | ||
|
||
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"); | ||
} | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
tests/Tests/Mapping/Metafields/MetafieldsMappingApiTestsBase.cs
This file was deleted.
Oops, something went wrong.