# Synonyms

# List synonyms of one sequence

GET
/indexes/:uid/synonyms/:synonym

List one sequence and its synonyms in an index.

# Path Variables

Variable Description
uid The index UID
synonym Sequence of which the synonyms will be returned

# Example

$ curl \
  -X GET 'http://localhost:7700/indexes/12345678/synonyms/magician'

# Response: 200 OK

["harry","merlin"]

Array of synonyms of the given sequence in the path variable.

# List all sequences and synonyms

GET
/indexes/:uid/synonyms

List all sequences and their synonyms in an index.

# Path Variables

Variable Description
uid The index UID

# Example

$ curl \
  -X GET 'http://localhost:7700/indexes/12345678/synonyms'

# Response: 200 OK

{
  "potter": [
    "harry"
  ],
  "magician": [
    "harry",
    "merlin"
  ],
  "harry": [
    "potter"
  ]
}

# Create synonyms

POST
/indexes/:uid/synonyms

Create synonyms.

# Path Variables

Variable Description
uid The index UID

# Body

key Value description
input the one-way string that is gonna be associated with the synonyms array
synonyms array of words to associate together in a multi-way

An object with either multi-way string associations or one-way string association.

# One-way Example

$ curl \
  -X POST 'http://localhost:7700/indexes/12345678/synonyms' \
  --data '{ "input": "magician", "synonyms": ["harry potter", "merlin"]}'

# Multi-way Example

$ curl \
  -X POST 'http://localhost:7700/indexes/12345678/synonyms' \
  --data '{ "synonyms": ["harry potter", "hp"]}'

# Response: 202 Accepted

{
  "updateId": 1
}

This updateId allows you to track the current update.

# Update a synonym

PUT
/indexes/:uid/synonyms/:synonym

Update a synonym.

# Path Variables

Variable Description
uid The index UID
synonym Sequence of which the synonyms will be updated

# Body

An array of string containing all synonyms of the given sequence.

WARNING

This will override the previous synonyms of the given sequence. Don't forget to add them if you dont want to lose them.

# Example

$ curl \
  -X PUT 'http://localhost:7700/indexes/12345678/synonyms/magician' \
  --data '["harry potter", "merlin", "Illusionist"]'

# Response: 200 Ok

{
  "updateId": 1
}

This updateId allows you to track the current update.

# Delete a synonym

DELETE
/indexes/:uid/synonyms/:synonym

Delete a synonym.

# Path Variables

Variable Description
uid The index UID
synonym Sequence of which the synonyms will be deleted

# Example

$ curl \
  -X DELETE 'http://localhost:7700/indexes/12345678/synonyms/magician'

# Response: 200 Ok

{
  "updateId": 1
}

This updateId allows you to track the current update.

# Batch write synonyms

POST
/indexes/:uid/synonyms/batch

Batch write synonyms.

# Path Variables

Variable Description
uid The index UID

# Body

key Value description
input the one-way string that is gonna be associated with the synonyms array
synonyms array of words to associate together in a multi-way

An object with either multi-way string associations or one-way string association.

# Example

$ curl \
  -X POST 'http://localhost:7700/indexes/12345678/synonyms/batch' \
  --data '[
    {
      "input": "magician",
      "synonyms": ["harry potter", "merlin", "illusionist"]
    },
    {
      "synonyms": ["mickey", "mouse"]
    }
  ]'

# Response: 202 Accepted

{
  "updateId": 1
}

This updateId allows you to track the current update.

# Clear synonyms

DELETE
/indexes/:uid/synonyms

Delete all synonyms

# Path Variables

Variable Description
uid The index UID

# Example

$ curl \
  -X DELETE 'http://localhost:7700/indexes/12345678/synonyms'

# Response: 202 Accepted

{
  "updateId": 1
}

This updateId allows you to track the current update.