Skip to content

Commit bc6baf2

Browse files
committed
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)
1 parent 2eee46f commit bc6baf2

File tree

16 files changed

+783
-18
lines changed

16 files changed

+783
-18
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

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/Nest/Search/Search/Hits/HitsMetaData.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ public interface IHitsMetadata<out T> where T : class
3636
[DataMember(Name = "total")]
3737
TotalHits Total { get; }
3838
}
39-
40-
39+
4140
public class HitsMetadata<T> : IHitsMetadata<T>
4241
where T : class
4342
{

src/Nest/XPack/Eql/Events/Event.cs

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
using System.Runtime.Serialization;
21+
using Elasticsearch.Net.Utf8Json;
22+
23+
namespace Nest
24+
{
25+
public class Event<TEvent> where TEvent : class
26+
{
27+
/// <summary>
28+
/// The individual fields requested for a event.
29+
/// </summary>
30+
[DataMember(Name = "fields")]
31+
public FieldValues Fields { get; internal set; }
32+
33+
/// <summary>
34+
/// The id of the event.
35+
/// </summary>
36+
[DataMember(Name = "_id")]
37+
public string Id { get; internal set; }
38+
39+
/// <summary>
40+
/// The index in which the event resides.
41+
/// </summary>
42+
[DataMember(Name = "_index")]
43+
public string Index { get; internal set; }
44+
45+
/// <summary>
46+
/// The source document for the event.
47+
/// </summary>
48+
[DataMember(Name = "_source")]
49+
[JsonFormatter(typeof(SourceFormatter<>))]
50+
public TEvent Source { get; internal set; }
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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+
using System.Collections.Generic;
21+
using System.Runtime.Serialization;
22+
using Elasticsearch.Net;
23+
24+
namespace Nest
25+
{
26+
public class EqlHitsMetadata<TEvent>
27+
where TEvent : class
28+
{
29+
/// <summary>
30+
/// Contains events matching the query. Each object represents a matching event.
31+
/// </summary>
32+
[DataMember(Name = "events")]
33+
public IReadOnlyCollection<Event<TEvent>> Events { get; internal set; } = EmptyReadOnly<Event<TEvent>>.Collection;
34+
35+
/// <summary>
36+
/// Contains event sequences matching the query. Each object represents a matching sequence. This parameter is only returned for EQL queries containing a sequence.
37+
/// </summary>
38+
[DataMember(Name = "sequences")]
39+
public IReadOnlyCollection<Sequence<TEvent>> Sequences { get; internal set; } = EmptyReadOnly<Sequence<TEvent>>.Collection;
40+
41+
/// <summary>
42+
/// Metadata about the number of matching events or sequences.
43+
/// </summary>
44+
[DataMember(Name = "total")]
45+
public TotalHits Total { get; internal set; }
46+
}
47+
}

src/Nest/XPack/Eql/Events/Sequence.cs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
using System.Collections.Generic;
21+
using System.Runtime.Serialization;
22+
using Elasticsearch.Net;
23+
24+
namespace Nest
25+
{
26+
public class Sequence<TEvent> where TEvent : class
27+
{
28+
/// <summary>
29+
/// Contains events matching the query. Each object represents a matching event.
30+
/// </summary>
31+
[DataMember(Name = "events")]
32+
public IReadOnlyCollection<Event<TEvent>> Events { get; internal set; } = EmptyReadOnly<Event<TEvent>>.Collection;
33+
34+
/// <summary>
35+
/// Shared field values used to constrain matches in the sequence. These are defined using the by keyword in the EQL query syntax.
36+
/// </summary>
37+
[DataMember(Name = "join_keys")]
38+
public IReadOnlyCollection<object> JoinKeys { get; internal set; } = EmptyReadOnly<object>.Collection;
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
using System.Runtime.Serialization;
21+
using Elasticsearch.Net;
22+
23+
namespace Nest
24+
{
25+
[StringEnum]
26+
public enum EqlResultPosition
27+
{
28+
[EnumMember(Value = "head")]
29+
Head,
30+
31+
[EnumMember(Value = "tail")]
32+
Tail
33+
}
34+
}

0 commit comments

Comments
 (0)