-
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.
- Loading branch information
1 parent
a9d6835
commit 146ce08
Showing
15 changed files
with
142 additions
and
5 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
12 changes: 12 additions & 0 deletions
12
src/Nest/Mapping/Types/Core/MatchOnlyText/MatchOnlyTextAttribute.cs
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,12 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
namespace Nest | ||
{ | ||
public class MatchOnlyTextAttribute : ElasticsearchCorePropertyAttributeBase, IMatchOnlyTextProperty { | ||
public MatchOnlyTextAttribute() : base(FieldType.MatchOnlyText) { } | ||
protected MatchOnlyTextAttribute(FieldType fieldType) : base(fieldType) { } | ||
private IMatchOnlyTextProperty Self => this; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Nest/Mapping/Types/Core/MatchOnlyText/MatchOnlyTextProperty.cs
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,36 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System.Diagnostics; | ||
using Elasticsearch.Net.Utf8Json; | ||
|
||
namespace Nest | ||
{ | ||
/// <summary> | ||
/// A variant of text that trades scoring and efficiency of positional queries for space efficiency. | ||
/// This field effectively stores data the same way as a text field that only indexes documents | ||
/// (index_options: docs) and disables norms (norms: false). | ||
/// <para /> | ||
/// MatchOnlyText fields are not used for sorting and seldom used for aggregations. | ||
/// </summary> | ||
[InterfaceDataContract] | ||
public interface IMatchOnlyTextProperty : ICoreProperty | ||
{ | ||
} | ||
|
||
/// <inheritdoc cref="IMatchOnlyTextProperty"/> | ||
[DebuggerDisplay("{DebugDisplay}")] | ||
public class MatchOnlyTextProperty : CorePropertyBase, IMatchOnlyTextProperty | ||
{ | ||
public MatchOnlyTextProperty() : base(FieldType.MatchOnlyText) { } | ||
} | ||
|
||
/// <inheritdoc cref="IMatchOnlyTextProperty"/> | ||
public class MatchOnlyTextPropertyDescriptor<T> | ||
: CorePropertyDescriptorBase<MatchOnlyTextPropertyDescriptor<T>, IMatchOnlyTextProperty, T>, IMatchOnlyTextProperty | ||
where T : class | ||
{ | ||
public MatchOnlyTextPropertyDescriptor() : base(FieldType.MatchOnlyText) { } | ||
} | ||
} |
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
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
21 changes: 21 additions & 0 deletions
21
tests/Tests/Mapping/Types/Core/MatchOnlyText/MatchOnlyTextAttributeTests.cs
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,21 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using Elastic.Elasticsearch.Xunit.XunitPlumbing; | ||
using Nest; | ||
|
||
namespace Tests.Mapping.Types.Core.MatchOnlyText | ||
{ | ||
public class MatchOnlyTextTest | ||
{ | ||
[MatchOnlyText] | ||
public string MatchOnlyText { get; set; } | ||
} | ||
|
||
[SkipVersion("<7.14.0", "Match only text property added in 7.14.0")] | ||
public class MatchOnlyTextAttributeTests : AttributeTestsBase<MatchOnlyTextTest> | ||
{ | ||
protected override object ExpectJson => new { properties = new { matchOnlyText = new { type = "match_only_text" } } }; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tests/Tests/Mapping/Types/Core/MatchOnlyText/MatchOnlyTextPropertyTests.cs
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,28 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information | ||
|
||
using System; | ||
using Elastic.Elasticsearch.Xunit.XunitPlumbing; | ||
using Nest; | ||
using Tests.Core.ManagedElasticsearch.Clusters; | ||
using Tests.Domain; | ||
using Tests.Framework.EndpointTests.TestState; | ||
|
||
namespace Tests.Mapping.Types.Core.MatchOnlyText | ||
{ | ||
[SkipVersion("<7.14.0", "Match only text property added in 7.14.0")] | ||
public class MatchOnlyTextPropertyTests : PropertyTestsBase | ||
{ | ||
public MatchOnlyTextPropertyTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { } | ||
|
||
protected override object ExpectJson => new { properties = new { name = new { type = "match_only_text" } } }; | ||
|
||
protected override Func<PropertiesDescriptor<Project>, IPromise<IProperties>> FluentProperties => f => f | ||
.MatchOnlyText(s => s | ||
.Name(p => p.Name) | ||
); | ||
|
||
protected override IProperties InitializerProperties => new Properties { { "name", new MatchOnlyTextProperty() } }; | ||
} | ||
} |