Skip to content

Commit

Permalink
Update documentation on 7.6 (#4399)
Browse files Browse the repository at this point in the history
* add IntervalsFuzzy as known replace

(cherry picked from commit 0a59eb9)

* update docs on 7.6
  • Loading branch information
Mpdreamz authored Feb 21, 2020
1 parent 996d4b0 commit 54bfe83
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/aggregations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ The values are typically extracted from the fields of the document (using the fi

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

* <<string-stats-aggregation-usage,String Stats Aggregation Usage>>

* <<sum-aggregation-usage,Sum Aggregation Usage>>

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

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

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

include::aggregations/metric/sum/sum-aggregation-usage.asciidoc[]

include::aggregations/metric/top-hits/top-hits-aggregation-usage.asciidoc[]
Expand Down
6 changes: 4 additions & 2 deletions docs/aggregations/metric/min/min-aggregation-usage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ please modify the original csharp file found at the link and submit the PR with
a => a
.Min("min_last_activity", m => m
.Field(p => p.LastActivity)
.Format("yyyy")
)
----

==== Object Initializer syntax example

[source,csharp]
----
new MinAggregation("min_last_activity", Field<Project>(p => p.LastActivity))
new MinAggregation("min_last_activity", Field<Project>(p => p.LastActivity)) { Format = "yyyy" }
----

[source,javascript]
Expand All @@ -38,7 +39,8 @@ new MinAggregation("min_last_activity", Field<Project>(p => p.LastActivity))
{
"min_last_activity": {
"min": {
"field": "lastActivity"
"field": "lastActivity",
"format": "yyyy"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/7.5

:github: https://github.com/elastic/elasticsearch-net

:nuget: https://www.nuget.org/packages

////
IMPORTANT NOTE
==============
This file has been generated from https://github.com/elastic/elasticsearch-net/tree/7.x/src/Tests/Tests/Aggregations/Metric/StringStats/StringStatsAggregationUsageTests.cs.
If you wish to submit a PR for any spelling mistakes, typos or grammatical errors for this file,
please modify the original csharp file found at the link and submit the PR with that change. Thanks!
////

[[string-stats-aggregation-usage]]
=== String Stats Aggregation Usage

==== Fluent DSL example

[source,csharp]
----
a => a
.StringStats("name_stats", st => st
.Field(p => p.Name)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new StringStatsAggregation("name_stats", Field<Project>(p => p.Name))
----

[source,javascript]
.Example json output
----
{
"name_stats": {
"string_stats": {
"field": "name"
}
}
}
----

==== Handling Responses

[source,csharp]
----
response.ShouldBeValid();
var commitStats = response.Aggregations.StringStats("name_stats");
commitStats.Should().NotBeNull();
commitStats.AverageLength.Should().BeGreaterThan(0);
commitStats.MaxLength.Should().BeGreaterThan(0);
commitStats.MinLength.Should().BeGreaterThan(0);
commitStats.Count.Should().BeGreaterThan(0);
commitStats.Distribution.Should().NotBeNull().And.BeEmpty();
----

Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type with NEST.
public class MyPluginProperty : IProperty
{
IDictionary<string, object> IProperty.LocalMetadata { get; set; }
IDictionary<string, string> IProperty.Meta { get; set; }
public string Type { get; set; } = "my_plugin_property";
public PropertyName Name { get; set; }
Expand Down
54 changes: 54 additions & 0 deletions docs/code-standards/serialization/formatters.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,59 @@ foreach (var formatter in formatters)
visible.Add(formatter.Name);
}
visible.Should().BeEmpty();
Type GetFormatterTargetType(Type t)
{
var attribute = t.GetCustomAttribute<JsonFormatterAttribute>();
if (attribute == null)
return null;
var formatterType = attribute.FormatterType;
if (formatterType.IsGenericType && !formatterType.IsConstructedGenericType)
return null;
return formatterType.GetInterfaces()
.Where(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IJsonFormatter<>))
.Select(i => i.GetGenericArguments()[0])
.Single();
}
var typesAndProperties =
from t in typeof(IElasticClient).Assembly.GetTypes().Concat(typeof(IElasticLowLevelClient).Assembly.GetTypes())
let p = t.GetProperties()
let typeHasFormatter = t.GetCustomAttribute<JsonFormatterAttribute>(false) != null
let propertiesHaveFormatter = p.Any(pp => pp.GetCustomAttribute<JsonFormatterAttribute>(false) != null)
where typeHasFormatter || propertiesHaveFormatter
select new { Type = t, TypeHasFormatter = typeHasFormatter, Properties = p, PropertiesHaveFormatter = propertiesHaveFormatter };
var invalid = new List<string>();
foreach (var typeAndProperties in typesAndProperties)
{
if (typeAndProperties.TypeHasFormatter)
{
var t = typeAndProperties.Type;
var f = GetFormatterTargetType(t);
if (f != null && t != f)
invalid.Add($"{t.FullName} has IJsonFormatter<{f.FullName}>");
}
if (typeAndProperties.PropertiesHaveFormatter)
{
foreach (var property in typeAndProperties.Properties)
{
var t = property.PropertyType;
var f = GetFormatterTargetType(t);
if (f != null && t != f)
invalid.Add($"property {property.Name} on {typeAndProperties.Type.FullName} has IJsonFormatter<{f.FullName}>");
}
}
}
invalid.Should().BeEmpty();
----

58 changes: 58 additions & 0 deletions docs/query-dsl/full-text/intervals/intervals-usage.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,61 @@ new IntervalsQuery
}
----

[float]
=== Fuzzy rules

Fuzzy rules can be used to match terms that are similar to the provided term, within an edit distance defined by Fuzziness.
If the fuzzy expansion matches more than 128 terms, Elasticsearch returns an error.

NOTE: Only available in Elasticsearch 7.6.0+

==== Fluent DSL example

[source,csharp]
----
q
.Intervals(c => c
.Field(p => p.Description)
.Name("named_query")
.Boost(1.1)
.Fuzzy(m => m
.Term(IntervalsFuzzy)
.Fuzziness(Fuzziness.Auto)
)
)
----

==== Object Initializer syntax example

[source,csharp]
----
new IntervalsQuery
{
Field = Field<Project>(p => p.Description),
Name = "named_query",
Boost = 1.1,
Fuzzy = new IntervalsFuzzy
{
Term = IntervalsFuzzy,
Fuzziness = Fuzziness.Auto
}
}
----

[source,javascript]
.Example json output
----
{
"intervals": {
"description": {
"_name": "named_query",
"boost": 1.1,
"fuzzy": {
"term": "lorem",
"fuzziness": "AUTO"
}
}
}
}
----

1 change: 1 addition & 0 deletions src/DocGenerator/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public static class StringExtensions
{ "Project.First.Name", "\"Lesch Group\"" },
{ "Project.First.NumberOfCommits", "775" },
{ "IntervalsPrefix", "\"lorem\"" },
{ "IntervalsFuzzy", "\"lorem\"" },
{ "LastNameSearch", "\"Stokes\"" },
{ "_first.Language", "\"painless\"" },
{ "_first.Init", "\"state.map = [:]\"" },
Expand Down

0 comments on commit 54bfe83

Please sign in to comment.