Skip to content

Commit 9999568

Browse files
authored
[Backport master] Add NEST support for EQL Search API (#5662)
* Add NEST support for EQL Search API (#5658) * Add request and response classes * Code gen for EQL search * Add initial request properties * Initial response for testing * Un-skip EQL APIs from high-level code gen * Generate EQL code * Work on request and response types * Add event type for EQL * Update NEST code gen with license headers * Update request/response * Adding initial test * Support generic searches * Fixing URLs and adding URL tests * Add descriptor methods * Add sequence tests * Remove interfaces and update comments. * Remove redundant code in TimeSeriesCluster * Cleanup namespaces * Update license headers * Update headers * Remove UTF-8 BOM (cherry picked from commit f96a6f9) * Update code-gen * Update namespaces * Update license header for descriptors * Update unrelated tests
1 parent 2eee46f commit 9999568

File tree

105 files changed

+1258
-167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1258
-167
lines changed

.github/check-license-headers.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ NLINES=$(wc -l .github/license-header.txt | awk '{print $1}')
1616
function check_license_header {
1717
local f
1818
f=$1
19-
if ! diff .github/license-header.txt <(head -$NLINES "$f") >/dev/null; then
19+
if ! diff -a --strip-trailing-cr .github/license-header.txt <(head -$NLINES "$f") >/dev/null; then
2020
echo "check-license-headers: error: '$f' does not have required license header, see 'diff -u .github/license-header.txt <(head -$NLINES $f)'"
2121
return 1
2222
else

docs/7.0-breaking-changes/elasticsearch-net-breaking-changes.asciidoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -5206,13 +5206,13 @@ type:: deleted
52065206
type:: deleted
52075207

52085208
[discrete]
5209-
==== `Elasticsearch.Net.Utf8Json.Formatters.EnumFormatterHelper`
5209+
==== `Nest.Utf8Json.Formatters.EnumFormatterHelper`
52105210

52115211
[horizontal]
52125212
type:: added
52135213

52145214
[discrete]
5215-
==== `Elasticsearch.Net.Utf8Json.JsonParsingException`
5215+
==== `Nest.Utf8Json.JsonParsingException`
52165216

52175217
[horizontal]
52185218
type:: added

docs/code-standards/naming-conventions.asciidoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ var typesNotIElasticsearchNetNamespace = types
193193
.Where(t => !exceptions.Contains(t))
194194
.Where(t => t.Namespace != null)
195195
.Where(t => t.Namespace != "Elasticsearch.Net" && !t.Namespace.StartsWith("Elasticsearch.Net.Specification"))
196-
.Where(t => !t.Namespace.StartsWith("Elasticsearch.Net.Utf8Json"))
196+
.Where(t => !t.Namespace.StartsWith("Nest.Utf8Json"))
197197
.Where(t => !t.Namespace.StartsWith("Elasticsearch.Net.Extensions"))
198198
.Where(t => !t.Namespace.StartsWith("Elasticsearch.Net.Diagnostics"))
199199
.Where(t => !t.Namespace.StartsWith("System.Runtime.CompilerServices"))

src/ApiGenerator/Configuration/CodeConfiguration.cs

-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ public static class CodeConfiguration
9898
"cluster.get_component_template.json", // 7.8 experimental
9999
"cluster.put_component_template.json", // 7.8 experimental
100100
"cluster.exists_component_template.json", // 7.8 experimental
101-
102-
"eql.search.json", // 7.9 beta
103-
"eql.get.json", // 7.9 beta
104-
"eql.delete.json", // 7.9 beta
105101
};
106102

107103
/// <summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"eql.search": {
3+
"url": {
4+
"parts": {
5+
"index": {
6+
"type" : "list",
7+
"description" : "A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices"
8+
}
9+
}
10+
}
11+
}
12+
}

src/ApiGenerator/Views/HighLevel/Descriptors/RequestDescriptorBase.cshtml

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@using ApiGenerator.Domain
22
@inherits ApiGenerator.CodeTemplatePage<RestApiSpec>
3+
@{ await IncludeAsync("GeneratorNotice.cshtml", Model); }
34
using System.Collections.Generic;
45

56
namespace Nest

src/Elasticsearch.Net/Api/RequestParameters/RequestParameters.Eql.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class GetStatusRequestParameters : RequestParameters<GetStatusRequestPara
7272
}
7373

7474
///<summary>Request options for Search <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html</para></summary>
75-
public class SearchRequestParameters : RequestParameters<SearchRequestParameters>
75+
public class EqlSearchRequestParameters : RequestParameters<EqlSearchRequestParameters>
7676
{
7777
///<summary>Update the time interval in which the results (partial or final) for this search will be available</summary>
7878
public TimeSpan KeepAlive

src/Elasticsearch.Net/ElasticLowLevelClient.Eql.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ public TResponse GetStatus<TResponse>(string id, GetStatusRequestParameters requ
9696
public Task<TResponse> GetStatusAsync<TResponse>(string id, GetStatusRequestParameters requestParameters = null, CancellationToken ctx = default)
9797
where TResponse : class, ITransportResponse, new() => DoRequestAsync<TResponse>(GET, Url($"_eql/search/status/{id:id}"), ctx, null, RequestParams(requestParameters));
9898
///<summary>POST on /{index}/_eql/search <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html</para></summary>
99-
///<param name = "index">The name of the index to scope the operation</param>
99+
///<param name = "index">A comma-separated list of index names to search; use the special string `_all` or Indices.All to perform the operation on all indices</param>
100100
///<param name = "body">Eql request body. Use the `query` to limit the query scope.</param>
101101
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
102-
public TResponse Search<TResponse>(string index, PostData body, SearchRequestParameters requestParameters = null)
102+
public TResponse Search<TResponse>(string index, PostData body, EqlSearchRequestParameters requestParameters = null)
103103
where TResponse : class, ITransportResponse, new() => DoRequest<TResponse>(POST, Url($"{index:index}/_eql/search"), body, RequestParams(requestParameters));
104104
///<summary>POST on /{index}/_eql/search <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html</para></summary>
105-
///<param name = "index">The name of the index to scope the operation</param>
105+
///<param name = "index">A comma-separated list of index names to search; use the special string `_all` or Indices.All to perform the operation on all indices</param>
106106
///<param name = "body">Eql request body. Use the `query` to limit the query scope.</param>
107107
///<param name = "requestParameters">Request specific configuration such as querystring parameters &amp; request specific connection settings.</param>
108108
[MapsApi("eql.search", "index, body")]
109-
public Task<TResponse> SearchAsync<TResponse>(string index, PostData body, SearchRequestParameters requestParameters = null, CancellationToken ctx = default)
109+
public Task<TResponse> SearchAsync<TResponse>(string index, PostData body, EqlSearchRequestParameters requestParameters = null, CancellationToken ctx = default)
110110
where TResponse : class, ITransportResponse, new() => DoRequestAsync<TResponse>(POST, Url($"{index:index}/_eql/search"), ctx, body, RequestParams(requestParameters));
111111
}
112112
}

src/Nest/Descriptors.AsyncSearch.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
2120
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
2221
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
@@ -40,8 +39,8 @@
4039
using System.Text;
4140
using System.Linq.Expressions;
4241
using Elastic.Transport;
43-
using Nest.Utf8Json;
4442
using Elasticsearch.Net;
43+
using Nest.Utf8Json;
4544
using Elasticsearch.Net.Specification.AsyncSearchApi;
4645

4746
// ReSharper disable RedundantBaseConstructorCall
@@ -215,4 +214,4 @@ public AsyncSearchSubmitDescriptor<TInferDocument> Index<TOther>()
215214
///<summary>Specify the time that the request should block waiting for the final response</summary>
216215
public AsyncSearchSubmitDescriptor<TInferDocument> WaitForCompletionTimeout(Time waitforcompletiontimeout) => Qs("wait_for_completion_timeout", waitforcompletiontimeout);
217216
}
218-
}
217+
}

src/Nest/Descriptors.Cat.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
2120
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
2221
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
@@ -518,6 +517,8 @@ public partial class CatNodesDescriptor : RequestDescriptorBase<CatNodesDescript
518517
public CatNodesDescriptor Headers(params string[] headers) => Qs("h", headers);
519518
///<summary>Return help information</summary>
520519
public CatNodesDescriptor Help(bool? help = true) => Qs("help", help);
520+
///<summary>If set to true segment stats will include stats for segments that are not currently loaded into memory</summary>
521+
public CatNodesDescriptor IncludeUnloadedSegments(bool? includeunloadedsegments = true) => Qs("include_unloaded_segments", includeunloadedsegments);
521522
///<summary>Explicit operation timeout for connection to master node</summary>
522523
public CatNodesDescriptor MasterTimeout(Time mastertimeout) => Qs("master_timeout", mastertimeout);
523524
///<summary>Comma-separated list of column names or column aliases to sort by</summary>

src/Nest/Descriptors.Cluster.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
2120
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
2221
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
@@ -76,7 +75,7 @@ public partial class DeleteVotingConfigExclusionsDescriptor : RequestDescriptorB
7675
public DeleteVotingConfigExclusionsDescriptor WaitForRemoval(bool? waitforremoval = true) => Qs("wait_for_removal", waitforremoval);
7776
}
7877

79-
///<summary>Descriptor for GetSettings <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-update-settings.html</para></summary>
78+
///<summary>Descriptor for GetSettings <para>https://www.elastic.co/guide/en/elasticsearch/reference/master/cluster-get-settings.html</para></summary>
8079
public partial class ClusterGetSettingsDescriptor : RequestDescriptorBase<ClusterGetSettingsDescriptor, ClusterGetSettingsRequestParameters, IClusterGetSettingsRequest>, IClusterGetSettingsRequest
8180
{
8281
internal override ApiUrls ApiUrls => ApiUrlsLookups.ClusterGetSettings;

src/Nest/Descriptors.CrossClusterReplication.cs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
2120
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
2221
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗

src/Nest/Descriptors.DanglingIndices.cs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
2120
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
2221
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗

src/Nest/Descriptors.Enrich.cs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
2120
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
2221
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗

src/Nest/Descriptors.Eql.cs

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Licensed to Elasticsearch B.V. under one or more contributor
3+
* license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright
5+
* ownership. Elasticsearch B.V. licenses this file to you under
6+
* the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
20+
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
21+
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗
22+
// ██║╚██╗██║██║ ██║ ██║ ██║██║ ██╔══╝
23+
// ██║ ╚████║╚██████╔╝ ██║ ██║╚██████╗███████╗
24+
// ╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚══════╝
25+
// -----------------------------------------------
26+
//
27+
// This file is automatically generated
28+
// Please do not edit these files manually
29+
// Run the following in the root of the repos:
30+
//
31+
// *NIX : ./build.sh codegen
32+
// Windows : build.bat codegen
33+
//
34+
// -----------------------------------------------
35+
// ReSharper disable RedundantUsingDirective
36+
using System;
37+
using System.Collections.Generic;
38+
using System.Linq;
39+
using System.Text;
40+
using System.Linq.Expressions;
41+
using Elastic.Transport;
42+
using Elasticsearch.Net;
43+
using Nest.Utf8Json;
44+
using Elasticsearch.Net.Specification.EqlApi;
45+
46+
// ReSharper disable RedundantBaseConstructorCall
47+
// ReSharper disable UnusedTypeParameter
48+
// ReSharper disable PartialMethodWithSinglePart
49+
// ReSharper disable RedundantNameQualifier
50+
namespace Nest
51+
{
52+
///<summary>Descriptor for Search <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search-api.html</para></summary>
53+
public partial class EqlSearchDescriptor<TInferDocument> : RequestDescriptorBase<EqlSearchDescriptor<TInferDocument>, EqlSearchRequestParameters, IEqlSearchRequest<TInferDocument>>, IEqlSearchRequest<TInferDocument>
54+
{
55+
internal override ApiUrls ApiUrls => ApiUrlsLookups.EqlSearch;
56+
protected override HttpMethod HttpMethod => HttpMethod.POST;
57+
protected override bool SupportsBody => true;
58+
///<summary>/{index}/_eql/search</summary>
59+
///<param name = "index">this parameter is required</param>
60+
public EqlSearchDescriptor(Indices index): base(r => r.Required("index", index))
61+
{
62+
}
63+
64+
///<summary>/{index}/_eql/search</summary>
65+
public EqlSearchDescriptor(): this(typeof(TInferDocument))
66+
{
67+
}
68+
69+
// values part of the url path
70+
Indices IEqlSearchRequest.Index => Self.RouteValues.Get<Indices>("index");
71+
///<summary>A comma-separated list of index names to search; use the special string `_all` or Indices.All to perform the operation on all indices</summary>
72+
public EqlSearchDescriptor<TInferDocument> Index(Indices index) => Assign(index, (a, v) => a.RouteValues.Required("index", v));
73+
///<summary>a shortcut into calling Index(typeof(TOther))</summary>
74+
public EqlSearchDescriptor<TInferDocument> Index<TOther>()
75+
where TOther : class => Assign(typeof(TOther), (a, v) => a.RouteValues.Required("index", (Indices)v));
76+
///<summary>A shortcut into calling Index(Indices.All)</summary>
77+
public EqlSearchDescriptor<TInferDocument> AllIndices() => Index(Indices.All);
78+
// Request parameters
79+
///<summary>Update the time interval in which the results (partial or final) for this search will be available</summary>
80+
public EqlSearchDescriptor<TInferDocument> KeepAlive(Time keepalive) => Qs("keep_alive", keepalive);
81+
///<summary>Control whether the response should be stored in the cluster if it completed within the provided [wait_for_completion] time (default: false)</summary>
82+
public EqlSearchDescriptor<TInferDocument> KeepOnCompletion(bool? keeponcompletion = true) => Qs("keep_on_completion", keeponcompletion);
83+
///<summary>Specify the time that the request should block waiting for the final response</summary>
84+
public EqlSearchDescriptor<TInferDocument> WaitForCompletionTimeout(Time waitforcompletiontimeout) => Qs("wait_for_completion_timeout", waitforcompletiontimeout);
85+
}
86+
}

src/Nest/Descriptors.Graph.cs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
2120
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
2221
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗

src/Nest/Descriptors.IndexLifecycleManagement.cs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
2019
// ███╗ ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
2120
// ████╗ ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
2221
// ██╔██╗ ██║██║ ██║ ██║ ██║██║ █████╗

0 commit comments

Comments
 (0)