Skip to content

Commit b736d13

Browse files
authored
type on has_parent query should be parent_type' (#2999)
1 parent 3322c7c commit b736d13

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/Nest/QueryDsl/Joining/HasParent/HasParentQuery.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace Nest
77
[JsonConverter(typeof(ReadAsTypeJsonConverter<HasParentQueryDescriptor<object>>))]
88
public interface IHasParentQuery : IQuery
99
{
10-
[JsonProperty("type")]
11-
TypeName Type { get; set; }
10+
[JsonProperty("parent_type")]
11+
TypeName ParentType { get; set; }
1212

1313
/// <summary>
1414
/// Determines whether the score of the matching parent document is aggregated into the child documents belonging to the matching parent document.
@@ -30,7 +30,7 @@ public interface IHasParentQuery : IQuery
3030
public class HasParentQuery : QueryBase, IHasParentQuery
3131
{
3232
protected override bool Conditionless => IsConditionless(this);
33-
public TypeName Type { get; set; }
33+
public TypeName ParentType { get; set; }
3434

3535
/// <summary>
3636
/// Determines whether the score of the matching parent document is aggregated into the child documents belonging to the matching parent document.
@@ -42,15 +42,15 @@ public class HasParentQuery : QueryBase, IHasParentQuery
4242
public bool? IgnoreUnmapped { get; set; }
4343

4444
internal override void InternalWrapInContainer(IQueryContainer c) => c.HasParent = this;
45-
internal static bool IsConditionless(IHasParentQuery q) => q.Query == null || q.Query.IsConditionless || q.Type == null;
45+
internal static bool IsConditionless(IHasParentQuery q) => q.Query == null || q.Query.IsConditionless || q.ParentType == null;
4646
}
4747

4848
public class HasParentQueryDescriptor<T>
4949
: QueryDescriptorBase<HasParentQueryDescriptor<T>, IHasParentQuery>
5050
, IHasParentQuery where T : class
5151
{
5252
protected override bool Conditionless => HasParentQuery.IsConditionless(this);
53-
TypeName IHasParentQuery.Type { get; set; }
53+
TypeName IHasParentQuery.ParentType { get; set; }
5454

5555
/// <summary>
5656
/// Determines whether the score of the matching parent document is aggregated into the child documents belonging to the matching parent document.
@@ -61,12 +61,12 @@ public class HasParentQueryDescriptor<T>
6161
QueryContainer IHasParentQuery.Query { get; set; }
6262
bool? IHasParentQuery.IgnoreUnmapped { get; set; }
6363

64-
public HasParentQueryDescriptor() { Self.Type = TypeName.Create<T>(); }
64+
public HasParentQueryDescriptor() { Self.ParentType = TypeName.Create<T>(); }
6565

6666
public HasParentQueryDescriptor<T> Query(Func<QueryContainerDescriptor<T>, QueryContainer> selector) =>
6767
Assign(a => a.Query = selector?.Invoke(new QueryContainerDescriptor<T>()));
6868

69-
public HasParentQueryDescriptor<T> Type(string type) => Assign(a => a.Type = type);
69+
public HasParentQueryDescriptor<T> ParentType(string type) => Assign(a => a.ParentType = type);
7070

7171
/// <summary>
7272
/// Determines whether the score of the matching parent document is aggregated into the child documents belonging to the matching parent document.

src/Tests/QueryDsl/Joining/HasParent/HasParentQueryUsageTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public HasParentUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usa
1515
{
1616
_name = "named_query",
1717
boost = 1.1,
18-
type = "developer",
18+
parent_type = "developer",
1919
score = true,
2020
ignore_unmapped = true,
2121
query = new
@@ -33,7 +33,7 @@ public HasParentUsageTests(ReadOnlyCluster i, EndpointUsage usage) : base(i, usa
3333
{
3434
Name = "named_query",
3535
Boost = 1.1,
36-
Type = Infer.Type<Developer>(),
36+
ParentType = Infer.Type<Developer>(),
3737
InnerHits = new InnerHits { Explain = true },
3838
Query = new MatchAllQuery(),
3939
Score = true,
@@ -54,7 +54,7 @@ protected override QueryContainer QueryFluent(QueryContainerDescriptor<Project>
5454
{
5555
q => q.Query = null,
5656
q => q.Query = ConditionlessQuery,
57-
q => q.Type = null,
57+
q => q.ParentType = null,
5858
};
5959
}
6060
}

0 commit comments

Comments
 (0)