Skip to content

Commit d781af1

Browse files
committed
Update documentation
1 parent 3e5568a commit d781af1

File tree

2 files changed

+60
-7
lines changed

2 files changed

+60
-7
lines changed

docs/search/request/source-filtering-usage.asciidoc

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ See the Elasticsearch documentation on {ref_current}/search-request-source-filte
2626
[source,csharp]
2727
----
2828
s => s
29-
.Source(so => so
30-
.Include(f => f
29+
.Source(src => src
30+
.IncludeAll()
31+
.Exclude(e => e
3132
.Fields(
32-
p => p.Name,
33-
p => p.StartedOn
33+
p => p.Description
3434
)
3535
)
3636
)
@@ -44,7 +44,8 @@ new SearchRequest<Project>
4444
{
4545
Source = new SourceFilter
4646
{
47-
Include = Fields<Project>(p => p.Name, prop => prop.StartedOn)
47+
Include = "*",
48+
Exclude = Fields<Project>(p => p.Description)
4849
}
4950
}
5051
----
@@ -55,8 +56,10 @@ new SearchRequest<Project>
5556
{
5657
"_source": {
5758
"include": [
58-
"name",
59-
"startedOn"
59+
"*"
60+
],
61+
"exclude": [
62+
"description"
6063
]
6164
}
6265
}
@@ -76,3 +79,48 @@ foreach (var document in response.Documents)
7679
}
7780
----
7881

82+
[[disable-source-retrieval]]
83+
[float]
84+
== Disable Source Retrieval
85+
86+
Source filtering can be disabled by setting disable to `true`.
87+
88+
=== Fluent DSL Example
89+
90+
[source,csharp]
91+
----
92+
s => s
93+
.Source(src => src.Disable())
94+
----
95+
96+
=== Object Initializer Syntax Example
97+
98+
[source,csharp]
99+
----
100+
new SearchRequest<Project>
101+
{
102+
Source = new SourceFilter
103+
{
104+
Disable = true
105+
}
106+
}
107+
----
108+
109+
[source,javascript]
110+
.Example json output
111+
----
112+
{
113+
"_source": false
114+
}
115+
----
116+
117+
=== Handling Responses
118+
119+
[source,csharp]
120+
----
121+
response.ShouldBeValid();
122+
123+
foreach (var hit in response.Hits)
124+
hit.Source.Should().BeNull();
125+
----
126+

src/Tests/Search/Request/SourceFilteringUsageTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ protected override void ExpectResponse(ISearchResponse<Project> response)
6262
}
6363
}
6464

65+
/**[float]
66+
* == Disable Source Retrieval
67+
* Source filtering can be disabled by setting disable to `true`.
68+
*
69+
*/
6570
public class SourceFilteringDisabledUsageTests : SearchUsageTestBase
6671
{
6772
public SourceFilteringDisabledUsageTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { }

0 commit comments

Comments
 (0)