Skip to content

Commit 7739083

Browse files
mashhursyaauie
andauthored
Apply suggestions from code review
Accept obvious or agreed code review suggestions. Co-authored-by: Rye Biesemeyer <yaauie@users.noreply.github.com>
1 parent bf341e2 commit 7739083

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

docs/index.asciidoc

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,10 @@ Authorization to a secure Elasticsearch cluster requires `read` permission at in
119119
The `monitoring` permission at cluster level is necessary to perform periodic connectivity checks.
120120

121121
[id="plugins-{type}s-{plugin}-esql"]
122-
==== ES|QL support
123-
{es} Query Language (ES|QL) provides a SQL-like interface for querying your {es} data.
122+
==== {esql} support
123+
{es} Query Language ({esql}) provides a SQL-like interface for querying your {es} data.
124124

125-
To utilize the ES|QL feature with this plugin, the following version requirements must be met:
126-
[cols="1,2",options="header"]
127-
|===
128-
|Component |Minimum version
129-
|{es} |8.11.0 or newer
130-
|{ls} |8.17.4 or newer
131-
|This plugin |3.19.0+ (3.x series) or 4.3.0+ (4.x series)
132-
|===
125+
To use {esql}, this plugin needs to be installed in {ls} 8.17.4 or newer, and must be connected to {es} 8.11 or newer.
133126

134127
To configure ES|QL query in the plugin, set your ES|QL query in the `query` parameter.
135128

lib/logstash/filters/elasticsearch.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,10 @@ def validate_esql_query_and_params!
462462
named_params = original_query_params["named_params"] ||= []
463463
named_params_keys = named_params.map(&:keys).flatten
464464

465-
placeholders = @query.scan(/\?(\w+)/).flatten
465+
placeholders = @query.scan(/(?<=[?])[a-z_][a-z0-9_]*/i)
466466
raise LogStash::ConfigurationError, "Number of placeholders in `query` and `named_params` do not match" unless placeholders.size == named_params_keys.size
467467

468468
placeholders.each do |placeholder|
469-
placeholder.delete_prefix!("?")
470469
raise LogStash::ConfigurationError, "Placeholder #{placeholder} not found in query" unless named_params_keys.include?(placeholder)
471470
end
472471
end

lib/logstash/filters/elasticsearch/esql_executor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def add_requested_fields(event, columns, values)
8888
column_index = columns.find_index { |col| col['name'] == old_key }
8989
next unless column_index
9090

91-
row_values = values.map { |entry| entry[column_index] }&.compact # remove non-exist field values with compact
91+
row_values = values[column_index]&.compact # remove non-exist field values with compact
9292
# TODO: set to the target field once target support is added
9393
event.set(new_key, row_values.one? ? row_values.first : row_values) if row_values&.size > 0
9494
end

0 commit comments

Comments
 (0)