Method: Elasticsearch::API::TextStructure::Actions#find_structure
- Defined in:
- lib/elasticsearch/api/actions/text_structure/find_structure.rb
#find_structure(arguments = {}) ⇒ Object
Find the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch. This API provides a starting point for ingesting data into Elasticsearch in a format that is suitable for subsequent use with other Elastic Stack functionality. Unlike other Elasticsearch endpoints, the data that is posted to this endpoint does not need to be UTF-8 encoded and in JSON format. It must, however, be text; binary text formats are not currently supported. The size is limited to the Elasticsearch HTTP receive buffer size, which defaults to 100 Mb. The response from the API contains:
-
A couple of messages from the beginning of the text.
-
Statistics that reveal the most common values for all fields detected within the text and basic numeric statistics for numeric fields.
-
Information about the structure of the text, which is useful when you write ingest configurations to index it or similarly formatted text.
-
Appropriate mappings for an Elasticsearch index, which you could use to ingest the text.
All this information can be calculated by the structure finder with no guidance. However, you can optionally override some of the decisions about the text structure by specifying one or more query parameters.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/elasticsearch/api/actions/text_structure/find_structure.rb', line 119 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 Utils.update_ndjson_headers!(headers, client.transport..dig(:transport_options, :headers)) Elasticsearch::API::Response.new( perform_request(method, path, params, payload, headers, request_opts) ) end |