Get synonyms set

Get synonyms set

New API reference

For the most up-to-date API details, refer to Synonyms APIs.

Retrieves a synonyms set.

Request

GET _synonyms/<synonyms_set>

Prerequisites

Requires the manage_search_synonyms cluster privilege.

Path parameters

<synonyms_set>

(Required, string) Synonyms set identifier to retrieve.

Query parameters

from

(Optional, integer) Starting offset for synonyms rules to retrieve. Defaults to 0.

size

(Optional, integer) Specifies the maximum number of synonyms rules to retrieve. Defaults to 10.

Response codes

400

The synonyms_set identifier was not provided.

404 (Missing resources)

No synonyms set with the identifier synonyms_set was found.

Examples

The following example retrieves a synonyms set called my-synonyms-set:

  1. resp = client.synonyms.get_synonym(
  2. id="my-synonyms-set",
  3. )
  4. print(resp)
  1. response = client.synonyms.get_synonym(
  2. id: 'my-synonyms-set'
  3. )
  4. puts response
  1. const response = await client.synonyms.getSynonym({
  2. id: "my-synonyms-set",
  3. });
  4. console.log(response);
  1. GET _synonyms/my-synonyms-set

The synonyms set information returned will include the total number of synonyms rules that the synonyms set contains, and the synonyms rules according to the from and size parameters.

A sample response:

  1. {
  2. "count": 3,
  3. "synonyms_set": [
  4. {
  5. "id": "test-1",
  6. "synonyms": "hello, hi"
  7. },
  8. {
  9. "id": "test-2",
  10. "synonyms": "bye, goodbye"
  11. },
  12. {
  13. "id": "test-3",
  14. "synonyms": "test => check"
  15. }
  16. ]
  17. }