module Elasticsearch::API::TextStructure::Actions

Public Instance Methods

find_field_structure(arguments = {}) click to toggle source

Finds the structure of a text field in an index.

@option arguments [String] :index The index containing the analyzed field (Required) @option arguments [String] :field The field that should be analyzed (Required) @option arguments [Integer] :documents_to_sample How many documents should be included in the analysis @option arguments [Time] :timeout Timeout after which the analysis will be aborted @option arguments [String] :format Optional parameter to specify the high level file format (options: ndjson, xml, delimited, semi_structured_text) @option arguments [List] :column_names Optional parameter containing a comma separated list of the column names for a delimited file @option arguments [String] :delimiter Optional parameter to specify the delimiter character for a delimited file - must be a single character @option arguments [String] :quote Optional parameter to specify the quote character for a delimited file - must be a single character @option arguments [Boolean] :should_trim_fields Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them @option arguments [String] :grok_pattern Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file @option arguments [String] :ecs_compatibility Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either ‘v1’ or ‘disabled’ @option arguments [String] :timestamp_field Optional parameter to specify the timestamp field in the file @option arguments [String] :timestamp_format Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format @option arguments [Boolean] :explain Whether to include a commentary on how the structure was derived @option arguments [Hash] :headers Custom HTTP headers

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/find-field-structure.html

# File lib/elasticsearch/api/actions/text_structure/find_field_structure.rb, line 45
def find_field_structure(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'text_structure.find_field_structure' }

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body   = nil

  method = Elasticsearch::API::HTTP_GET
  path   = '_text_structure/find_field_structure'
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
find_message_structure(arguments = {}) click to toggle source

Finds the structure of a list of messages. The messages must contain data that is suitable to be ingested into Elasticsearch.

@option arguments [Time] :timeout Timeout after which the analysis will be aborted @option arguments [String] :format Optional parameter to specify the high level file format (options: ndjson, xml, delimited, semi_structured_text) @option arguments [List] :column_names Optional parameter containing a comma separated list of the column names for a delimited file @option arguments [String] :delimiter Optional parameter to specify the delimiter character for a delimited file - must be a single character @option arguments [String] :quote Optional parameter to specify the quote character for a delimited file - must be a single character @option arguments [Boolean] :should_trim_fields Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them @option arguments [String] :grok_pattern Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file @option arguments [String] :ecs_compatibility Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either ‘v1’ or ‘disabled’ @option arguments [String] :timestamp_field Optional parameter to specify the timestamp field in the file @option arguments [String] :timestamp_format Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format @option arguments [Boolean] :explain Whether to include a commentary on how the structure was derived @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body JSON object with one field [messages], containing an array of messages to be analyzed (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/find-message-structure.html

# File lib/elasticsearch/api/actions/text_structure/find_message_structure.rb, line 43
def find_message_structure(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'text_structure.find_message_structure' }

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body   = arguments.delete(:body)

  method = Elasticsearch::API::HTTP_POST
  path   = '_text_structure/find_message_structure'
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end
find_structure(arguments = {}) click to toggle source

Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch.

@option arguments [Integer] :lines_to_sample How many lines of the file should be included in the analysis @option arguments [Integer] :line_merge_size_limit Maximum number of characters permitted in a single message when lines are merged to create messages. @option arguments [Time] :timeout Timeout after which the analysis will be aborted @option arguments [String] :charset Optional parameter to specify the character set of the file @option arguments [String] :format Optional parameter to specify the high level file format (options: ndjson, xml, delimited, semi_structured_text) @option arguments [Boolean] :has_header_row Optional parameter to specify whether a delimited file includes the column names in its first row @option arguments [List] :column_names Optional parameter containing a comma separated list of the column names for a delimited file @option arguments [String] :delimiter Optional parameter to specify the delimiter character for a delimited file - must be a single character @option arguments [String] :quote Optional parameter to specify the quote character for a delimited file - must be a single character @option arguments [Boolean] :should_trim_fields Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them @option arguments [String] :grok_pattern Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file @option arguments [String] :ecs_compatibility Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either ‘v1’ or ‘disabled’ @option arguments [String] :timestamp_field Optional parameter to specify the timestamp field in the file @option arguments [String] :timestamp_format Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format @option arguments [Boolean] :explain Whether to include a commentary on how the structure was derived @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The contents of the file to be analyzed (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/find-structure.html

# File lib/elasticsearch/api/actions/text_structure/find_structure.rb, line 47
def find_structure(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'text_structure.find_structure' }

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body   = arguments.delete(:body)

  method = Elasticsearch::API::HTTP_POST
  path   = '_text_structure/find_structure'
  params = Utils.process_params(arguments)

  payload = if body.is_a? Array
              Elasticsearch::API::Utils.__bulkify(body)
            else
              body
            end

  headers.merge!('Content-Type' => 'application/x-ndjson')
  Elasticsearch::API::Response.new(
    perform_request(method, path, params, payload, headers, request_opts)
  )
end
test_grok_pattern(arguments = {}) click to toggle source

Tests a Grok pattern on some text.

@option arguments [String] :ecs_compatibility Optional parameter to specify the compatibility mode with ECS Grok patterns - may be either ‘v1’ or ‘disabled’ @option arguments [Hash] :headers Custom HTTP headers @option arguments [Hash] :body The Grok pattern and text. (Required)

@see www.elastic.co/guide/en/elasticsearch/reference/8.16/test-grok-pattern.html

# File lib/elasticsearch/api/actions/text_structure/test_grok_pattern.rb, line 33
def test_grok_pattern(arguments = {})
  request_opts = { endpoint: arguments[:endpoint] || 'text_structure.test_grok_pattern' }

  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body   = arguments.delete(:body)

  method = Elasticsearch::API::HTTP_POST
  path   = '_text_structure/test_grok_pattern'
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers, request_opts)
  )
end