Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .paket/Paket.Restore.targets
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
<PaketExePath Condition=" '$(PaketExePath)' == '' ">$(PaketToolsPath)paket.exe</PaketExePath>
<PaketCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketExePath)"</PaketCommand>
<PaketCommand Condition=" '$(OS)' != 'Windows_NT' ">$(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)"</PaketCommand>

<!-- .net core fdd -->
<_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)"))</_PaketExeExtension>
<PaketCommand Condition=" '$(_PaketExeExtension)' == '.dll' ">dotnet "$(PaketExePath)"</PaketCommand>

<!-- no extension is a shell script -->
<PaketCommand Condition=" '$(_PaketExeExtension)' == '' ">"$(PaketExePath)"</PaketCommand>

<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' AND Exists('$(PaketRootPath)paket.bootstrapper.exe')">$(PaketRootPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
<PaketBootStrapperExePath Condition=" '$(PaketBootStrapperExePath)' == '' ">$(PaketToolsPath)paket.bootstrapper.exe</PaketBootStrapperExePath>
<PaketBootStrapperCommand Condition=" '$(OS)' == 'Windows_NT'">"$(PaketBootStrapperExePath)"</PaketBootStrapperCommand>
Expand Down Expand Up @@ -140,9 +148,10 @@
</DotNetCliToolReference>
</ItemGroup>

<!-- Disabled for now until we know what to do with runtime deps - https://github.com/fsprojects/Paket/issues/2964
<PropertyGroup>
<RestoreConfigFile>$(MSBuildProjectDirectory)/obj/$(MSBuildProjectFile).NuGet.Config</RestoreConfigFile>
</PropertyGroup>
</PropertyGroup> -->

</Target>

Expand Down
73 changes: 73 additions & 0 deletions docs/aggregations/aggregation-meta-usage.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
:ref_current: https://www.elastic.co/guide/en/elasticsearch/reference/6.1

: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/master/src/Tests/Aggregations/AggregationMetaUsageTests.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!
////

[[aggregation-metadata]]
=== Aggregation Metadata

Metadata can be provided per aggregation, and will be returned in the aggregation response

[source,csharp]
----
a => a
.Min("min_last_activity", m => m
.Field(p => p.LastActivity)
.Meta(d => d
.Add("meta_1", "value_1")
.Add("meta_2", 2)
.Add("meta_3", new { meta_3 = "value_3" })
)
)
----

[source,csharp]
----
new MinAggregation("min_last_activity", Infer.Field<Project>(p => p.LastActivity))
{
Meta = new Dictionary<string,object>
{
{ "meta_1", "value_1" },
{ "meta_2", 2 },
{ "meta_3", new { meta_3 = "value_3" } }
}
}
----

[source,javascript]
.Example json output
----
{
"min_last_activity": {
"min": {
"field": "lastActivity"
},
"meta": {
"meta_1": "value_1",
"meta_2": 2,
"meta_3": {
"meta_3": "value_3"
}
}
}
}
----

==== Handling Responses

[source,csharp]
----
response.ShouldBeValid();
var min = response.Aggregations.Min("min_last_activity");
min.Meta.Should().NotBeNull().And.ContainKeys("meta_1", "meta_2", "meta_3");
----

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,65 @@ please modify the original csharp file found at the link and submit the PR with
[[adjacency-matrix-usage]]
=== Adjacency Matrix Usage

[source,csharp]
----
a => a
.AdjacencyMatrix("interactions", am => am
.Filters(fs => fs
.Filter("grpA", f => f.Term(p => p.State, StateOfBeing.BellyUp))
.Filter("grpB", f => f.Term(p => p.State, StateOfBeing.Stable))
.Filter("grpC", f => f.Term(p => p.State, StateOfBeing.VeryActive))
)
)
----

[source,csharp]
----
new AdjacencyMatrixAggregation("interactions")
{
Filters = new NamedFiltersContainer
{
{"grpA", new TermQuery {Field = "state", Value = StateOfBeing.BellyUp}},
{"grpB", new TermQuery {Field = "state", Value = StateOfBeing.Stable}},
{"grpC", new TermQuery {Field = "state", Value = StateOfBeing.VeryActive}},
}
}
----

[source,javascript]
.Example json output
----
{
"interactions": {
"adjacency_matrix": {
"filters": {
"grpA": {
"term": {
"state": {
"value": "BellyUp"
}
}
},
"grpB": {
"term": {
"state": {
"value": "Stable"
}
}
},
"grpC": {
"term": {
"state": {
"value": "VeryActive"
}
}
}
}
}
}
}
----

==== Handling Responses

[source,csharp]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,55 @@ buckets on child documents.

Be sure to read the Elasticsearch documentation on {ref_current}/search-aggregations-bucket-children-aggregation.html[Children Aggregation]

[source,csharp]
----
a => a
.Children<CommitActivity>("name_of_child_agg", child => child
.Aggregations(childAggs => childAggs
.Average("average_per_child", avg => avg.Field(p => p.ConfidenceFactor))
.Max("max_per_child", avg => avg.Field(p => p.ConfidenceFactor))
.Min("min_per_child", avg => avg.Field(p => p.ConfidenceFactor))
)
)
----

[source,csharp]
----
new ChildrenAggregation("name_of_child_agg", typeof(CommitActivity))
{
Aggregations =
new AverageAggregation("average_per_child", "confidenceFactor")
&& new MaxAggregation("max_per_child", "confidenceFactor")
&& new MinAggregation("min_per_child", "confidenceFactor")
}
----

[source,javascript]
.Example json output
----
{
"name_of_child_agg": {
"children": {
"type": "commits"
},
"aggs": {
"average_per_child": {
"avg": {
"field": "confidenceFactor"
}
},
"max_per_child": {
"max": {
"field": "confidenceFactor"
}
},
"min_per_child": {
"min": {
"field": "confidenceFactor"
}
}
}
}
}
----

Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,91 @@ as part of the `format` value.

Be sure to read the Elasticsearch documentation on {ref_current}/search-aggregations-bucket-datehistogram-aggregation.html[Date Histogram Aggregation].

[source,csharp]
----
a => a
.DateHistogram("projects_started_per_month", date => date
.Field(p => p.StartedOn)
.Interval(DateInterval.Month)
.MinimumDocumentCount(2)
.Format("yyyy-MM-dd'T'HH:mm:ss")
.ExtendedBounds(FixedDate.AddYears(-1), FixedDate.AddYears(1))
.Order(HistogramOrder.CountAscending)
.Missing(FixedDate)
.Aggregations(childAggs => childAggs
.Nested("project_tags", n => n
.Path(p => p.Tags)
.Aggregations(nestedAggs => nestedAggs
.Terms("tags", avg => avg.Field(p => p.Tags.First().Name))
)
)
)
)
----

[source,csharp]
----
new DateHistogramAggregation("projects_started_per_month")
{
Field = Field<Project>(p => p.StartedOn),
Interval = DateInterval.Month,
MinimumDocumentCount = 2,
Format = "yyyy-MM-dd'T'HH:mm:ss",
ExtendedBounds = new ExtendedBounds<DateMath>
{
Minimum = FixedDate.AddYears(-1),
Maximum = FixedDate.AddYears(1),
},
Order = HistogramOrder.CountAscending,
Missing = FixedDate,
Aggregations = new NestedAggregation("project_tags")
{
Path = Field<Project>(p => p.Tags),
Aggregations = new TermsAggregation("tags")
{
Field = Field<Project>(p => p.Tags.First().Name)
}
}
}
----

[source,javascript]
.Example json output
----
{
"projects_started_per_month": {
"date_histogram": {
"field": "startedOn",
"interval": "month",
"min_doc_count": 2,
"format": "yyyy-MM-dd'T'HH:mm:ss||date_optional_time",
"order": {
"_count": "asc"
},
"extended_bounds": {
"min": "2014-06-06T12:01:02.123",
"max": "2016-06-06T12:01:02.123"
},
"missing": "2015-06-06T12:01:02.123"
},
"aggs": {
"project_tags": {
"nested": {
"path": "tags"
},
"aggs": {
"tags": {
"terms": {
"field": "tags.name"
}
}
}
}
}
}
}
----

=== Handling responses

The `AggregateDictionary found on `.Aggregations` on `ISearchResponse<T>` has several helper methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,72 @@ IMPORTANT: this aggregation includes the `from` value and excludes the `to` valu

Be sure to read the Elasticsearch documentation on {ref_current}/search-aggregations-bucket-daterange-aggregation.html[Date Range Aggregation]

[source,csharp]
----
a => a
.DateRange("projects_date_ranges", date => date
.Field(p => p.StartedOn)
.Ranges(
r => r.From(DateMath.Anchored(FixedDate).Add("2d")).To(DateMath.Now),
r => r.To(DateMath.Now.Add(TimeSpan.FromDays(1)).Subtract("30m").RoundTo(DateMathTimeUnit.Hour)),
r => r.From(DateMath.Anchored("2012-05-05").Add(TimeSpan.FromDays(1)).Subtract("1m"))
)
.TimeZone("CET")
.Aggregations(childAggs => childAggs
.Terms("project_tags", avg => avg.Field(p => p.Tags))
)
)
----

[source,csharp]
----
new DateRangeAggregation("projects_date_ranges")
{
Field = Field<Project>(p => p.StartedOn),
Ranges = new List<DateRangeExpression>
{
new DateRangeExpression {From = DateMath.Anchored(FixedDate).Add("2d"), To = DateMath.Now},
new DateRangeExpression {To = DateMath.Now.Add(TimeSpan.FromDays(1)).Subtract("30m").RoundTo(DateMathTimeUnit.Hour)},
new DateRangeExpression {From = DateMath.Anchored("2012-05-05").Add(TimeSpan.FromDays(1)).Subtract("1m")}
},
TimeZone = "CET",
Aggregations =
new TermsAggregation("project_tags") {Field = Field<Project>(p => p.Tags)}
}
----

[source,javascript]
.Example json output
----
{
"projects_date_ranges": {
"date_range": {
"field": "startedOn",
"ranges": [
{
"to": "now",
"from": "2015-06-06T12:01:02.123||+2d"
},
{
"to": "now+1d-30m/h"
},
{
"from": "2012-05-05||+1d-1m"
}
],
"time_zone": "CET"
},
"aggs": {
"project_tags": {
"terms": {
"field": "tags"
}
}
}
}
}
----

=== Handling Responses

The `AggregateDictionary found on `.Aggregations` on `ISearchResponse<T>` has several helper methods
Expand Down
Loading