View Source ExAws.CloudSearch.Document (ex_aws_cloud_search v0.3.0)

Operations to add and remove documents from a CloudSearch domain index.

Link to this section Summary

Types

Field values may be strings (text, literal, latlon, date), lists of strings (text-array, literal-array, date-array), numbers (int, double), or lists of numbers (int-array, double-array). Empty or nil values are not permitted.

Fields are maps of field names (which must be strings matching the pattern [a-zA-Z0-9][a-zA-Z0-9_]{0,63}) with field values. At least one field/value pair must be provided.

Functions

Adds the provided document(s) to the index. Note that nothing in this function prevents a request from being too large to process in CloudSearch (batches may be at most 5Mb, with each document being at most 1Mb).

Removes the provided document(s) by ID from the index.

Link to this section Types

@type add() :: %{type: :add, id: String.t(), fields: fields()}
@type batch() :: [document()]
@type delete() :: %{type: :delete, id: String.t()}
@type document() :: add() | delete()
@type field_value() :: String.t() | [String.t()] | number() | [number()]

Field values may be strings (text, literal, latlon, date), lists of strings (text-array, literal-array, date-array), numbers (int, double), or lists of numbers (int-array, double-array). Empty or nil values are not permitted.

@type fields() :: %{required(String.t() | atom()) => field_value()}

Fields are maps of field names (which must be strings matching the pattern [a-zA-Z0-9][a-zA-Z0-9_]{0,63}) with field values. At least one field/value pair must be provided.

@type request() :: %ExAws.Operation.CloudSearch{
  api_version: term(),
  before_request: term(),
  data: term(),
  headers: term(),
  http_method: term(),
  params: batch(),
  parser: term(),
  path: term(),
  request_type: :doc,
  service: term(),
  stream_builder: term()
}

Link to this section Functions

Adds the provided document(s) to the index. Note that nothing in this function prevents a request from being too large to process in CloudSearch (batches may be at most 5Mb, with each document being at most 1Mb).

Documents may be added in several ways:

add(%Band{id: 3, name: "Grimes"})
add(%{id: 3, name: "Grimes"})
add(%{"id" => 3, "name" => "Grimes"})
add(%{3 => %{"name" => "Grimes"}})
add({3, %{"name" => "Grimes"}})
add([%Band{id: 3, name: "Grimes"}])
add([%{id: 3, name: "Grimes"}])
add([%{"id" => 3, "name" => "Grimes"}])
add([%{3 => %{"name" => "Grimes"}}])
add([{3, %{name: "Grimes"}}])

However the document is provided, it must have an ID and the list of fields. The list of fields must match the document as defined in the index field configuration in CloudSearch (or the document upload will fail at least for that document).

The ID will be converted to a string with to_string/1. Fields may not be nil or empty ("" or []), so those will be removed.

Removes the provided document(s) by ID from the index.

remove(%Band{id: 3})
remove(%{id: 3})
remove(%{"id" => 3})
remove(3)
remove([%Band{id: 3}])
remove([%{id: 3}])
remove([%{"id" => 3}])
remove([3])