Creating or updating an auto-completion item

Use this API to update or create an auto-completion item.

Requirement: OpenSearchServer v1.5

Call parameters

URL: /services/rest/index/{index_name}/autocompletion/{autocompletion_name}?field={field_name}&rows={rows}

Method: PUT

Header:

  • Accept (optional returned type): application/json or application/xml

URL parameters:

  • index_name (required): The name of the index.
  • autocompletion_name (required): The name of the auto-completion item.

Query parameters:

  • field (required, one or more): The fields providing the terms to populate the auto-completion index.
  • rows (optional): The number of terms that an auto-completion query will return by default.

Success response

The auto-completion item has been created or updated.

HTTP code:
200

Content (application/json):

{
"successful": true,
"info": "Autocompletion item my_expressions updated."
}
{
"successful": true,
"info": "Autocompletion item my_expressions inserted"
}

Error response

The creation/update failed. The reason is provided in the content.

HTTP code:
500

Sample call

Using CURL:

curl -XPUT http://localhost:8080/services/rest/index/my_index/autocompletion/my_expressions?field=titleExact&field=contentExact&rows=8

Using jQuery:

$.ajax({
type: "PUT",
dataType: "json",
url: "http://localhost:8080/services/rest/index/my_index/autocompletion/my_expressions?field=titleExact&field=contentExact&rows=8"
}).done(function (data) {
console.log(data);
});

View/edit on GitHub