Skip to content

Commit fa8fe22

Browse files
committed
Fix #428 remove scope from filters and facets, add join property to nested filter.
1 parent 66850b8 commit fa8fe22

24 files changed

+12
-125
lines changed

Diff for: src/Elasticsearch.Net/ElasticsearchClient.cs

-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public partial class ElasticsearchClient : IElasticsearchClient
2929
/// <param name="connection">Provide an alternative connection handler</param>
3030
/// <param name="transport">Provide a custom transport implementation that coordinates between IConnectionPool, IConnection and ISerializer</param>
3131
/// <param name="serializer">Provide a custom serializer</param>
32-
/// <param name="stringifier">This interface is responsible for translating non string objects in the querystring to strings</param>
3332
public ElasticsearchClient(
3433
IConnectionConfigurationValues settings = null,
3534
IConnection connection = null,

Diff for: src/Nest/DSL/Facets/BaseFacetDescriptor.cs

-7
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,6 @@ public TFacetDescriptor FacetFilter(Func<FilterDescriptor<T>, FilterContainer> f
3131
return (TFacetDescriptor) this;
3232
}
3333

34-
string IFacetRequest.Scope { get; set;}
35-
public TFacetDescriptor Scope(string scope)
36-
{
37-
((IFacetRequest)this).Scope = scope;
38-
return (TFacetDescriptor) this;
39-
}
40-
4134
PropertyPathMarker IFacetRequest.Nested { get; set; }
4235

4336
public TFacetDescriptor Nested(string nested)

Diff for: src/Nest/DSL/Facets/FacetContainer.cs

-6
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public interface IFacetContainer
1717
[JsonProperty(PropertyName = "global")]
1818
bool? Global { get; set; }
1919

20-
[JsonProperty(PropertyName = "_scope")]
21-
string Scope { get; set; }
22-
2320
[JsonProperty(PropertyName = "nested")]
2421
PropertyPathMarker Nested { get; set; }
2522

@@ -59,9 +56,6 @@ public class FacetContainer : IFacetContainer
5956
[JsonProperty(PropertyName = "global")]
6057
public bool? Global { get; set; }
6158

62-
[JsonProperty(PropertyName = "_scope")]
63-
public string Scope { get; set; }
64-
6559
[JsonProperty(PropertyName = "nested")]
6660
public PropertyPathMarker Nested { get; set; }
6761

Diff for: src/Nest/DSL/Facets/FacetRequest.cs

-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@ public interface IFacetRequest
66
{
77
bool? Global { get; set; }
88
IFilterContainer FacetFilter { get; set; }
9-
string Scope { get; set; }
109
PropertyPathMarker Nested { get; set; }
1110
}
1211
public abstract class FacetRequest : IFacetRequest
1312
{
1413
public bool? Global { get; set; }
1514
public IFilterContainer FacetFilter { get; set; }
16-
public string Scope { get; set; }
1715
public PropertyPathMarker Nested { get; set; }
1816
}
1917
}

Diff for: src/Nest/DSL/Filter/HasChildFilterDescriptor.cs

-11
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ public interface IHasChildFilter : IFilter
1616
[JsonProperty("type")]
1717
TypeNameMarker Type { get; set; }
1818

19-
[JsonProperty("_scope")]
20-
string Scope { get; set; }
21-
2219
[JsonProperty("query")]
2320
IQueryContainer Query { get; set; }
2421
}
@@ -31,7 +28,6 @@ protected internal override void WrapInContainer(IFilterContainer container)
3128
}
3229

3330
public TypeNameMarker Type { get; set; }
34-
public string Scope { get; set; }
3531
public IQueryContainer Query { get; set; }
3632
}
3733

@@ -48,7 +44,6 @@ bool IFilter.IsConditionless
4844

4945
TypeNameMarker IHasChildFilter.Type { get; set; }
5046

51-
string IHasChildFilter.Scope { get; set;}
5247

5348
IQueryContainer IHasChildFilter.Query { get; set; }
5449

@@ -64,12 +59,6 @@ public HasChildFilterDescriptor<T> Query(Func<QueryDescriptor<T>, QueryContainer
6459
return this;
6560
}
6661

67-
public HasChildFilterDescriptor<T> Scope(string scope)
68-
{
69-
((IHasChildFilter)this).Scope = scope;
70-
return this;
71-
}
72-
7362
public HasChildFilterDescriptor<T> Type(string type)
7463
{
7564
((IHasChildFilter)this).Type = type;

Diff for: src/Nest/DSL/Filter/HasParentFilterDescriptor.cs

-12
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ public interface IHasParentFilter : IFilter
1616
[JsonProperty("type")]
1717
TypeNameMarker Type { get; set; }
1818

19-
[JsonProperty("_scope")]
20-
string Scope { get; set; }
21-
2219
[JsonProperty("query")]
2320
[JsonConverter(typeof(CompositeJsonConverter<ReadAsTypeConverter<QueryDescriptor<object>>, CustomJsonConverter>))]
2421
IQueryContainer Query { get; set; }
@@ -32,16 +29,13 @@ protected internal override void WrapInContainer(IFilterContainer container)
3229
}
3330

3431
public TypeNameMarker Type { get; set; }
35-
public string Scope { get; set; }
3632
public IQueryContainer Query { get; set; }
3733
}
3834

3935
public class HasParentFilterDescriptor<T> : FilterBase, IHasParentFilter where T : class
4036
{
4137
TypeNameMarker IHasParentFilter.Type { get; set; }
4238

43-
string IHasParentFilter.Scope { get; set;}
44-
4539
IQueryContainer IHasParentFilter.Query { get; set; }
4640

4741
bool IFilter.IsConditionless
@@ -67,12 +61,6 @@ public HasParentFilterDescriptor<T> Query(Func<QueryDescriptor<T>, QueryContaine
6761
return this;
6862
}
6963

70-
public HasParentFilterDescriptor<T> Scope(string scope)
71-
{
72-
((IHasParentFilter)this).Scope = scope;
73-
return this;
74-
}
75-
7664
public HasParentFilterDescriptor<T> Type(string type)
7765
{
7866
((IHasParentFilter)this).Type = type;

Diff for: src/Nest/DSL/Filter/NestedFilterDescriptor.cs

+12-8
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ public interface INestedFilter : IFilter
2828
[JsonProperty("path")]
2929
PropertyPathMarker Path { get; set; }
3030

31-
[JsonProperty("_scope")]
32-
string Scope { get; set; }
31+
[JsonProperty("join")]
32+
bool? Join { get; set; }
3333
}
3434

3535
public class NestedFilter : PlainFilter, INestedFilter
@@ -43,7 +43,7 @@ protected internal override void WrapInContainer(IFilterContainer container)
4343
public IFilterContainer Filter { get; set; }
4444
public IQueryContainer Query { get; set; }
4545
public PropertyPathMarker Path { get; set; }
46-
public string Scope { get; set; }
46+
public bool? Join { get; set; }
4747
}
4848

4949
public class NestedFilterDescriptor<T> : FilterBase, INestedFilter where T : class
@@ -56,7 +56,7 @@ public class NestedFilterDescriptor<T> : FilterBase, INestedFilter where T : cla
5656

5757
PropertyPathMarker INestedFilter.Path { get; set; }
5858

59-
string INestedFilter.Scope { get; set; }
59+
bool? INestedFilter.Join { get; set; }
6060

6161
bool IFilter.IsConditionless
6262
{
@@ -73,6 +73,7 @@ public NestedFilterDescriptor<T> Filter(Func<FilterDescriptor<T>, FilterContaine
7373
((INestedFilter)this).Filter = filterSelector(q);
7474
return this;
7575
}
76+
7677
public NestedFilterDescriptor<T> Query(Func<QueryDescriptor<T>, QueryContainer> querySelector)
7778
{
7879
var q = new QueryDescriptor<T>();
@@ -85,19 +86,22 @@ public NestedFilterDescriptor<T> Score(NestedScore score)
8586
((INestedFilter)this).Score = score;
8687
return this;
8788
}
89+
8890
public NestedFilterDescriptor<T> Path(string path)
8991
{
9092
((INestedFilter)this).Path = path;
9193
return this;
9294
}
93-
public NestedFilterDescriptor<T> Path(Expression<Func<T, object>> objectPath)
95+
96+
public NestedFilterDescriptor<T> Join(bool join = true)
9497
{
95-
((INestedFilter)this).Path = objectPath;
98+
((INestedFilter)this).Join = join;
9699
return this;
97100
}
98-
public NestedFilterDescriptor<T> Scope(string scope)
101+
102+
public NestedFilterDescriptor<T> Path(Expression<Func<T, object>> objectPath)
99103
{
100-
((INestedFilter)this).Scope = scope;
104+
((INestedFilter)this).Path = objectPath;
101105
return this;
102106
}
103107
}

Diff for: src/Nest/DSL/Query/HasChildQueryDescriptor.cs

-10
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public interface IHasChildQuery : IQuery
1717
[JsonProperty("type")]
1818
TypeNameMarker Type { get; set; }
1919

20-
[JsonProperty("_scope")]
21-
string Scope { get; set; }
22-
2320
[JsonProperty("score_type")]
2421
[JsonConverter(typeof (StringEnumConverter))]
2522
ChildScoreType? ScoreType { get; set; }
@@ -38,7 +35,6 @@ protected override void WrapInContainer(IQueryContainer container)
3835

3936
bool IQuery.IsConditionless { get { return false; } }
4037
public TypeNameMarker Type { get; set; }
41-
public string Scope { get; set; }
4238
public ChildScoreType? ScoreType { get; set; }
4339
public IQueryContainer Query { get; set; }
4440
}
@@ -47,7 +43,6 @@ public class HasChildQueryDescriptor<T> : IHasChildQuery where T : class
4743
{
4844
TypeNameMarker IHasChildQuery.Type { get; set; }
4945

50-
string IHasChildQuery.Scope { get; set; }
5146

5247
ChildScoreType? IHasChildQuery.ScoreType { get; set; }
5348

@@ -73,11 +68,6 @@ public HasChildQueryDescriptor<T> Query(Func<QueryDescriptor<T>, QueryContainer>
7368
((IHasChildQuery)this).Query = querySelector(q);
7469
return this;
7570
}
76-
public HasChildQueryDescriptor<T> Scope(string scope)
77-
{
78-
((IHasChildQuery)this).Scope = scope;
79-
return this;
80-
}
8171
public HasChildQueryDescriptor<T> Type(string type)
8272
{
8373
((IHasChildQuery)this).Type = type;

Diff for: src/Nest/DSL/Query/HasParentQueryDescriptor.cs

-11
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public interface IHasParentQuery : IQuery
1717
[JsonProperty("type")]
1818
TypeNameMarker Type { get; set; }
1919

20-
[JsonProperty("_scope")]
21-
string Scope { get; set; }
22-
2320
[JsonProperty("score_type")]
2421
[JsonConverter(typeof (StringEnumConverter))]
2522
ParentScoreType? ScoreType { get; set; }
@@ -39,7 +36,6 @@ protected override void WrapInContainer(IQueryContainer container)
3936

4037
bool IQuery.IsConditionless { get { return false; } }
4138
public TypeNameMarker Type { get; set; }
42-
public string Scope { get; set; }
4339
public ParentScoreType? ScoreType { get; set; }
4440
public IQueryContainer Query { get; set; }
4541
}
@@ -48,8 +44,6 @@ public class HasParentQueryDescriptor<T> : IHasParentQuery where T : class
4844
{
4945
TypeNameMarker IHasParentQuery.Type { get; set; }
5046

51-
string IHasParentQuery.Scope { get; set; }
52-
5347
ParentScoreType? IHasParentQuery.ScoreType { get; set; }
5448

5549
IQueryContainer IHasParentQuery.Query { get; set; }
@@ -74,11 +68,6 @@ public HasParentQueryDescriptor<T> Query(Func<QueryDescriptor<T>, QueryContainer
7468
((IHasParentQuery)this).Query = querySelector(q);
7569
return this;
7670
}
77-
public HasParentQueryDescriptor<T> Scope(string scope)
78-
{
79-
((IHasParentQuery)this).Scope = scope;
80-
return this;
81-
}
8271
public HasParentQueryDescriptor<T> Type(string type)
8372
{
8473
((IHasParentQuery)this).Type = type;

Diff for: src/Nest/DSL/Query/NestedQueryDescriptor.cs

-11
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ public interface INestedQuery : IQuery
2828
[JsonProperty("path")]
2929
PropertyPathMarker Path { get; set; }
3030

31-
[JsonProperty("_scope")]
32-
string Scope { get; set; }
33-
3431
}
3532

3633
public class NestedQuery : PlainQuery, INestedQuery
@@ -45,7 +42,6 @@ protected override void WrapInContainer(IQueryContainer container)
4542
public IFilterContainer Filter { get; set; }
4643
public IQueryContainer Query { get; set; }
4744
public PropertyPathMarker Path { get; set; }
48-
public string Scope { get; set; }
4945
}
5046

5147
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
@@ -59,8 +55,6 @@ public class NestedQueryDescriptor<T> : INestedQuery where T : class
5955

6056
PropertyPathMarker INestedQuery.Path { get; set; }
6157

62-
string INestedQuery.Scope { get; set; }
63-
6458
bool IQuery.IsConditionless
6559
{
6660
get
@@ -98,10 +92,5 @@ public NestedQueryDescriptor<T> Path(Expression<Func<T, object>> objectPath)
9892
((INestedQuery)this).Path = objectPath;
9993
return this;
10094
}
101-
public NestedQueryDescriptor<T> Scope(string scope)
102-
{
103-
((INestedQuery)this).Scope = scope;
104-
return this;
105-
}
10695
}
10796
}

Diff for: src/Nest/DSL/Query/TopChildrenQueryDescriptor.cs

-17
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public interface ITopChildrenQuery : IQuery
1717
[JsonProperty("type")]
1818
TypeNameMarker Type { get; set; }
1919

20-
[JsonProperty("_scope")]
21-
string Scope { get; set; }
22-
2320
[JsonProperty("score"), JsonConverter(typeof (StringEnumConverter))]
2421
TopChildrenScore? Score { get; set; }
2522

@@ -49,7 +46,6 @@ protected override void WrapInContainer(IQueryContainer container)
4946

5047
bool IQuery.IsConditionless { get { return false; } }
5148
public TypeNameMarker Type { get; set; }
52-
public string Scope { get; set; }
5349
public TopChildrenScore? Score { get; set; }
5450
public int? Factor { get; set; }
5551
public int? IncrementalFactor { get; set; }
@@ -82,8 +78,6 @@ public TopChildrenQueryDescriptor()
8278

8379
TypeNameMarker ITopChildrenQuery.Type { get; set; }
8480

85-
string ITopChildrenQuery.Scope { get; set; }
86-
8781
TopChildrenScore? ITopChildrenQuery.Score { get; set; }
8882

8983
int? ITopChildrenQuery.Factor { get; set; }
@@ -107,17 +101,6 @@ public TopChildrenQueryDescriptor<T> Query(Func<QueryDescriptor<T>, QueryContain
107101
return this;
108102
}
109103

110-
/// <summary>
111-
/// A _scope can be defined on the query allowing to run facets on the same scope name that will work
112-
/// against the child documents.
113-
/// </summary>
114-
/// <param name="scope">The name of the scope</param>
115-
public TopChildrenQueryDescriptor<T> Scope(string scope)
116-
{
117-
((ITopChildrenQuery)this).Scope = scope;
118-
return this;
119-
}
120-
121104
/// <summary>
122105
/// How many hits are asked for in the first child query run is controlled using the factor parameter (defaults to 5).
123106
/// </summary>

Diff for: src/Nest/DSL/SearchDescriptor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,6 @@ Action<FacetContainer, F> fillBucket
851851
bucket.FacetFilter = f.FacetFilter;
852852
f.FacetFilter = null;
853853
bucket.Nested = f.Nested;
854-
bucket.Scope = f.Scope;
855854
fillBucket(bucket, descriptor);
856855
Self.Facets.Add(key, bucket);
857856

Diff for: src/Tests/Nest.Tests.Unit/QueryParsers/Filter/HasChildFilterTests.cs

-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ public void HasChild_Deserializes(string cacheName, string cacheKey, bool cache)
1414
var hasChildFilter = this.SerializeThenDeserialize(cacheName, cacheKey, cache,
1515
f=>f.HasChild,
1616
f=>f.HasChild<Person>(d=>d
17-
.Scope("my_scope")
1817
.Query(q=>q.Term(p=>p.FirstName, "value"))
1918
)
2019
);
2120

22-
hasChildFilter.Scope.Should().Be("my_scope");
2321
var query = hasChildFilter.Query;
2422
query.Should().NotBeNull();
2523
query.Term.Field.Should().Be("firstName");

Diff for: src/Tests/Nest.Tests.Unit/QueryParsers/Filter/HasParentFilterTests.cs

-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ public void HasParent_Deserializes(string cacheName, string cacheKey, bool cache
1414
var hasParentFilter = this.SerializeThenDeserialize(cacheName, cacheKey, cache,
1515
f=>f.HasParent,
1616
f=>f.HasParent<ElasticsearchProject>(d=>d
17-
.Scope("my_scope")
1817
.Query(q=>q.Term(p=>p.Country, "value"))
1918
)
2019
);
21-
hasParentFilter.Scope.Should().Be("my_scope");
2220
var query = hasParentFilter.Query;
2321
query.Should().NotBeNull();
2422
query.Term.Field.Should().Be("country");

0 commit comments

Comments
 (0)