You can import data into OpenSearch from a data source or by uploading files using an API, an SDK, or the console. Importing data using an API or SDK provides full control and flexibility.
Field type mappings
|
OpenSearch field type |
API data type |
|
INT |
int, long |
|
INT_ARRAY |
int[], long[] |
|
FLOAT |
float |
|
FLOAT_ARRAY |
float[] |
|
DOUBLE |
double |
|
DOUBLE_ARRAY |
double[] |
|
LITERAL |
string |
|
LITERAL_ARRAY |
string[] |
|
SHORT_TEXT |
string |
|
TEXT |
string |
|
TIMESTAMP |
long |
|
GEO_POINT |
A string in the `lon lat` format, where `lon` is the longitude and `lat` is the latitude. Both are double values separated by a space. The valid range for `lon` is [-180, 180] and for `lat` is [-90, 90]. |
Push data using an API
1. The file upload feature in the console is intended for testing the search feature. It is not efficient for uploading large numbers of documents, and each file can be up to 2 MB. For more information about other API and SDK push limits, see System limits in Push data [Application level] (Standard Edition).
2. APIs and SDKs do not support data source plugins. You must concatenate and process data before passing it to an OpenSearch application. For example, when using an API to upload data of the array type, upload it as an array, not as a string.
// Define a Map object to store the document data to be uploaded. This is document 2.
Map<String,Object> doc2 =Maps.newLinkedHashMap();
doc2.put("id",1);
String[] literal_arr2 ={"element1","element2"};
doc2.put("literal_arr", literal_arr2);
3. For more information about the API and SDK, see: