Skip to content

Commit 758c92f

Browse files
committed
fix #954 add support for _source on _mget operations itself as well
1 parent 3fb2423 commit 758c92f

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

src/Nest/DSL/MultiGet/IMultiGetOperation.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public interface IMultiGetOperation
2222
[JsonProperty(PropertyName = "_routing")]
2323
string Routing { get; set; }
2424

25+
[JsonProperty(PropertyName = "_source")]
26+
ISourceFilter Source { get; set; }
27+
2528
Type ClrType { get; }
2629
}
2730
}

src/Nest/DSL/MultiGet/MultiGetOperationDescriptor.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public MultiGetOperation(string id)
1616
this.Type = typeof(T);
1717
}
1818
public MultiGetOperation(long id) : this(id.ToString(CultureInfo.InvariantCulture)) {}
19-
19+
2020
Type IMultiGetOperation.ClrType { get { return typeof(T); } }
2121

2222
public IndexNameMarker Index { get; set; }
@@ -27,6 +27,8 @@ public MultiGetOperation(long id) : this(id.ToString(CultureInfo.InvariantCultur
2727

2828
public IList<PropertyPathMarker> Fields { get; set; }
2929

30+
public ISourceFilter Source { get; set; }
31+
3032
public string Routing { get; set; }
3133
}
3234

@@ -39,6 +41,7 @@ public class MultiGetOperationDescriptor<T> : IMultiGetOperation
3941
TypeNameMarker IMultiGetOperation.Type { get; set; }
4042
string IMultiGetOperation.Id { get; set; }
4143
string IMultiGetOperation.Routing { get; set; }
44+
ISourceFilter IMultiGetOperation.Source { get; set; }
4245
IList<PropertyPathMarker> IMultiGetOperation.Fields { get; set; }
4346
Type IMultiGetOperation.ClrType { get { return typeof(T); } }
4447

@@ -83,23 +86,20 @@ public MultiGetOperationDescriptor<T> Type(string type)
8386
}
8487

8588
/// <summary>
86-
/// Manually set the type of which a typename will be inferred
89+
/// Control how the document's source is loaded
8790
/// </summary>
88-
public MultiGetOperationDescriptor<T> Type(Type type)
91+
public MultiGetOperationDescriptor<T> Source(ISourceFilter source)
8992
{
90-
if (type == null) return this;
91-
Self.Type = type;
93+
Self.Source = source;
9294
return this;
9395
}
9496

95-
public MultiGetOperationDescriptor<T> Id(long id)
96-
{
97-
return this.Id(id.ToString(CultureInfo.InvariantCulture));
98-
}
99-
100-
public MultiGetOperationDescriptor<T> Id(string id)
97+
/// <summary>
98+
/// Control how the document's source is loaded
99+
/// </summary>
100+
public MultiGetOperationDescriptor<T> Source(Func<SearchSourceDescriptor<T>, SearchSourceDescriptor<T>> source)
101101
{
102-
Self.Id = id;
102+
Self.Source = source(new SearchSourceDescriptor<T>());
103103
return this;
104104
}
105105

0 commit comments

Comments
 (0)