Skip to content

Commit 3fd4dce

Browse files
mashhursyaauie
andauthored
Apply suggestions from code review
Separate DSL and ESQL interface in the client. Co-authored-by: Rye Biesemeyer <[email protected]>
1 parent 7739083 commit 3fd4dce

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/logstash/filters/elasticsearch/client.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,12 @@ def initialize(logger, hosts, options = {})
5555
@client = ::Elasticsearch::Client.new(client_options)
5656
end
5757

58-
def search(params={}, query_type = 'dsl')
59-
query_type == 'esql' ? @client.esql.query(params) : @client.search(params)
58+
def search(params={})
59+
@client.search(params)
60+
end
61+
62+
def esql_query(params={})
63+
@client.esql.query(params)
6064
end
6165

6266
def info

lib/logstash/filters/elasticsearch/esql_executor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def resolve_parameters(event)
5454
def execute_query(client, params)
5555
# debug logs may help to check what query shape the plugin is sending to ES
5656
@logger.debug("Executing ES|QL query", query: @query, params: params)
57-
client.search({ body: { query: @query, params: params }, format: 'json', drop_null_columns: true }, 'esql')
57+
client.esql_query({ body: { query: @query, params: params }, format: 'json', drop_null_columns: true }, 'esql')
5858
end
5959

6060
def process_response(event, response)

0 commit comments

Comments
 (0)