Skip to content

Commit 54bfe83

Browse files
authored
Update documentation on 7.6 (#4399)
* add IntervalsFuzzy as known replace (cherry picked from commit 0a59eb9) * update docs on 7.6
1 parent 996d4b0 commit 54bfe83

File tree

7 files changed

+182
-2
lines changed

7 files changed

+182
-2
lines changed

docs/aggregations.asciidoc

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ The values are typically extracted from the fields of the document (using the fi
5858

5959
* <<stats-aggregation-usage,Stats Aggregation Usage>>
6060

61+
* <<string-stats-aggregation-usage,String Stats Aggregation Usage>>
62+
6163
* <<sum-aggregation-usage,Sum Aggregation Usage>>
6264

6365
* <<top-hits-aggregation-usage,Top Hits Aggregation Usage>>
@@ -94,6 +96,8 @@ include::aggregations/metric/scripted-metric/scripted-metric-aggregation-usage.a
9496

9597
include::aggregations/metric/stats/stats-aggregation-usage.asciidoc[]
9698

99+
include::aggregations/metric/string-stats/string-stats-aggregation-usage.asciidoc[]
100+
97101
include::aggregations/metric/sum/sum-aggregation-usage.asciidoc[]
98102

99103
include::aggregations/metric/top-hits/top-hits-aggregation-usage.asciidoc[]

docs/aggregations/metric/min/min-aggregation-usage.asciidoc

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ please modify the original csharp file found at the link and submit the PR with
2222
a => a
2323
.Min("min_last_activity", m => m
2424
.Field(p => p.LastActivity)
25+
.Format("yyyy")
2526
)
2627
----
2728

2829
==== Object Initializer syntax example
2930

3031
[source,csharp]
3132
----
32-
new MinAggregation("min_last_activity", Field<Project>(p => p.LastActivity))
33+
new MinAggregation("min_last_activity", Field<Project>(p => p.LastActivity)) { Format = "yyyy" }
3334
----
3435

3536
[source,javascript]
@@ -38,7 +39,8 @@ new MinAggregation("min_last_activity", Field<Project>(p => p.LastActivity))
3839
{
3940
"min_last_activity": {
4041
"min": {
41-
"field": "lastActivity"
42+
"field": "lastActivity",
43+
"format": "yyyy"
4244
}
4345
}
4446
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/7.5
2+
3+
:github: https://github.com/elastic/elasticsearch-net
4+
5+
:nuget: https://www.nuget.org/packages
6+
7+
////
8+
IMPORTANT NOTE
9+
==============
10+
This file has been generated from https://github.com/elastic/elasticsearch-net/tree/7.x/src/Tests/Tests/Aggregations/Metric/StringStats/StringStatsAggregationUsageTests.cs.
11+
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
12+
please modify the original csharp file found at the link and submit the PR with that change. Thanks!
13+
////
14+
15+
[[string-stats-aggregation-usage]]
16+
=== String Stats Aggregation Usage
17+
18+
==== Fluent DSL example
19+
20+
[source,csharp]
21+
----
22+
a => a
23+
.StringStats("name_stats", st => st
24+
.Field(p => p.Name)
25+
)
26+
----
27+
28+
==== Object Initializer syntax example
29+
30+
[source,csharp]
31+
----
32+
new StringStatsAggregation("name_stats", Field<Project>(p => p.Name))
33+
----
34+
35+
[source,javascript]
36+
.Example json output
37+
----
38+
{
39+
"name_stats": {
40+
"string_stats": {
41+
"field": "name"
42+
}
43+
}
44+
}
45+
----
46+
47+
==== Handling Responses
48+
49+
[source,csharp]
50+
----
51+
response.ShouldBeValid();
52+
var commitStats = response.Aggregations.StringStats("name_stats");
53+
commitStats.Should().NotBeNull();
54+
commitStats.AverageLength.Should().BeGreaterThan(0);
55+
commitStats.MaxLength.Should().BeGreaterThan(0);
56+
commitStats.MinLength.Should().BeGreaterThan(0);
57+
commitStats.Count.Should().BeGreaterThan(0);
58+
commitStats.Distribution.Should().NotBeNull().And.BeEmpty();
59+
----
60+

docs/client-concepts/high-level/serialization/extending-nest-types.asciidoc

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type with NEST.
3131
public class MyPluginProperty : IProperty
3232
{
3333
IDictionary<string, object> IProperty.LocalMetadata { get; set; }
34+
IDictionary<string, string> IProperty.Meta { get; set; }
3435
public string Type { get; set; } = "my_plugin_property";
3536
public PropertyName Name { get; set; }
3637

docs/code-standards/serialization/formatters.asciidoc

+54
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,59 @@ foreach (var formatter in formatters)
2828
visible.Add(formatter.Name);
2929
}
3030
visible.Should().BeEmpty();
31+
32+
Type GetFormatterTargetType(Type t)
33+
{
34+
var attribute = t.GetCustomAttribute<JsonFormatterAttribute>();
35+
36+
if (attribute == null)
37+
return null;
38+
39+
var formatterType = attribute.FormatterType;
40+
41+
if (formatterType.IsGenericType && !formatterType.IsConstructedGenericType)
42+
return null;
43+
44+
return formatterType.GetInterfaces()
45+
.Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IJsonFormatter<>))
46+
.Select(i => i.GetGenericArguments()[0])
47+
.Single();
48+
}
49+
50+
var typesAndProperties =
51+
from t in typeof(IElasticClient).Assembly.GetTypes().Concat(typeof(IElasticLowLevelClient).Assembly.GetTypes())
52+
let p = t.GetProperties()
53+
let typeHasFormatter = t.GetCustomAttribute<JsonFormatterAttribute>(false) != null
54+
let propertiesHaveFormatter = p.Any(pp => pp.GetCustomAttribute<JsonFormatterAttribute>(false) != null)
55+
where typeHasFormatter || propertiesHaveFormatter
56+
select new { Type = t, TypeHasFormatter = typeHasFormatter, Properties = p, PropertiesHaveFormatter = propertiesHaveFormatter };
57+
58+
var invalid = new List<string>();
59+
60+
foreach (var typeAndProperties in typesAndProperties)
61+
{
62+
if (typeAndProperties.TypeHasFormatter)
63+
{
64+
var t = typeAndProperties.Type;
65+
var f = GetFormatterTargetType(t);
66+
67+
if (f != null && t != f)
68+
invalid.Add($"{t.FullName} has IJsonFormatter<{f.FullName}>");
69+
}
70+
71+
if (typeAndProperties.PropertiesHaveFormatter)
72+
{
73+
foreach (var property in typeAndProperties.Properties)
74+
{
75+
var t = property.PropertyType;
76+
var f = GetFormatterTargetType(t);
77+
78+
if (f != null && t != f)
79+
invalid.Add($"property {property.Name} on {typeAndProperties.Type.FullName} has IJsonFormatter<{f.FullName}>");
80+
}
81+
}
82+
}
83+
84+
invalid.Should().BeEmpty();
3185
----
3286

docs/query-dsl/full-text/intervals/intervals-usage.asciidoc

+58
Original file line numberDiff line numberDiff line change
@@ -249,3 +249,61 @@ new IntervalsQuery
249249
}
250250
----
251251

252+
[float]
253+
=== Fuzzy rules
254+
255+
Fuzzy rules can be used to match terms that are similar to the provided term, within an edit distance defined by Fuzziness.
256+
If the fuzzy expansion matches more than 128 terms, Elasticsearch returns an error.
257+
258+
NOTE: Only available in Elasticsearch 7.6.0+
259+
260+
==== Fluent DSL example
261+
262+
[source,csharp]
263+
----
264+
q
265+
.Intervals(c => c
266+
.Field(p => p.Description)
267+
.Name("named_query")
268+
.Boost(1.1)
269+
.Fuzzy(m => m
270+
.Term(IntervalsFuzzy)
271+
.Fuzziness(Fuzziness.Auto)
272+
)
273+
)
274+
----
275+
276+
==== Object Initializer syntax example
277+
278+
[source,csharp]
279+
----
280+
new IntervalsQuery
281+
{
282+
Field = Field<Project>(p => p.Description),
283+
Name = "named_query",
284+
Boost = 1.1,
285+
Fuzzy = new IntervalsFuzzy
286+
{
287+
Term = IntervalsFuzzy,
288+
Fuzziness = Fuzziness.Auto
289+
}
290+
}
291+
----
292+
293+
[source,javascript]
294+
.Example json output
295+
----
296+
{
297+
"intervals": {
298+
"description": {
299+
"_name": "named_query",
300+
"boost": 1.1,
301+
"fuzzy": {
302+
"term": "lorem",
303+
"fuzziness": "AUTO"
304+
}
305+
}
306+
}
307+
}
308+
----
309+

src/DocGenerator/StringExtensions.cs

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static class StringExtensions
3939
{ "Project.First.Name", "\"Lesch Group\"" },
4040
{ "Project.First.NumberOfCommits", "775" },
4141
{ "IntervalsPrefix", "\"lorem\"" },
42+
{ "IntervalsFuzzy", "\"lorem\"" },
4243
{ "LastNameSearch", "\"Stokes\"" },
4344
{ "_first.Language", "\"painless\"" },
4445
{ "_first.Init", "\"state.map = [:]\"" },

0 commit comments

Comments
 (0)