forked from jaeksoft/opensearchserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Document put JSON
AlexandreToyer edited this page Sep 30, 2013
·
4 revisions
Use this API to create or update document in the index.
Requirement: OpenSearchServer v1.5
URL: /services/rest/index/{index_name}/document
Method: PUT
HTTP Header:
-
Content-Type (required):
application/json -
Accept (optional returned type):
application/jsonorapplication/xml
URL parameters:
- index_name (required): The name of the index.
Raw data (PUT): An array of documents.
[
{
"lang": "ENGLISH",
"fields": [
{ "name": "id", "value": 1 },
{ "name": "content", "value": "Hello world!", "boost": 1 }
]
},
{
"lang": "FRENCH",
"fields": [
{ "name": "id", "value": 2 },
{ "name": "content", "value": "Bonjour le monde!" }
]
},
{
"lang": "GERMAN",
"fields": [
{ "name": "id", "value": 3 },
{ "name": "content", "value": "Hallo Welt!", "boost": 1 }
]
}
]- lang (optional): The lang of the document.
-
fields (required): Array of fields.
- name (required): The name of the field.
- value (required): The content to index.
- boost (optional): A float value.
The document(s) has been created or updated.
HTTP code: 200
Content (application/json):
{
"successful": true,
"info": "3 document(s) updated"
}The creation/update failed. The reason is provided in the content.
HTTP code: 500
Using CURL:
curl -XPUT -H "Content-Type: application/json" \
-d '[{"lang": "ENGLISH","fields": [{ "name": "id", "value": 1 }]}]' \
http://localhost:8080/services/rest/index/my_index/document