> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Replace dictionary entries

> Replace a batch of dictionary entries.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="Add or delete dictionary entries" href="/doc/libraries/sdk/methods/search/batch-dictionary-entries" />

**Required ACL:** `editSettings`

## Examples

### Replace stopword entries

<CodeGroup>
  ```cs C# theme={"system"}
  Stopword stopword = new Stopword()
  {
    ObjectID = objectId,
    Language = "en",
     Word = "upper",
  };

  // Synchronous
  var replaceDictionaryResponse = DictionaryClient.ReplaceDictionaryEntries(algoliaDictionary, new List<DictionaryEntry>() { stopword });

  // Asynchronous
  var replaceDictionaryResponse = DictionaryClient.ReplaceDictionaryEntriesAsync(algoliaDictionary, new List<DictionaryEntry>() { stopword });
  replaceDictionaryResponse.Wait();
  ```

  ```go Go theme={"system"}
  stopwordEntry := search.NewStopword(entryID, "en", "down", "enabled")

  res, err := client.ReplaceDictionaryEntries(search.Stopwords, []search.DictionaryEntry{stopwordEntry})
  ```

  ```java Java theme={"system"}
  Stopword stopword = DictionaryEntry.stopword("MyObjectID", "en", "down", "enabled");
  // Synchronous
  searchClient.replaceDictionaryEntries(Dictionary.STOPWORDS, Collections.singletonList(stopword));
  // Asynchronous
  searchClient.replaceDictionaryEntriesAsync(Dictionary.STOPWORDS, Collections.singletonList(stopword));
  ```

  ```js JavaScript theme={"system"}
  client.replaceDictionaryEntries("stopwords", [
    {
      objectID: "down",
      language: "de",
      word: "down",
    },
  ]);
  ```

  ```kotlin Kotlin theme={"system"}
  val entry = DictionaryEntry.Stopword(
      objectID = ObjectID("MyObjectID"),
      language = Language.English,
      word = "upper"
  )
  client.replaceDictionaryEntries(Dictionary.Stopwords, listOf(entry))
  // or using extension function:
  client.replaceStopwordEntries(listOf(entry))
  ```

  ```php PHP theme={"system"}
  $client->replaceDictionaryEntries(
    'stopwords',
    array(array(
      'objectID' => 'down',
      'language' => 'en',
      'word' => 'down'
    ))
  );
  ```

  ```python Python theme={"system"}
  client.replace_dictionary_entries(
      "stopwords", [{"objectID": "down", "language": "en", "word": "down"}]
  )
  ```

  ```ruby Ruby theme={"system"}
  client.replace_dictionary_entries(
    "stopwords",
    [
      {
        objectID: "down",
        language: "en",
        word: "down"
      }
    ]
  )
  ```

  ```scala Scala theme={"system"}
  val entry = StopwordEntry(
    objectID = "MyObjectID",
    language = "en",
    word = "down",
    state = "enabled"
  )
  client.execute {
    replace dictionary Stopwords entries Seq(entry)
  }
  ```

  ```swift Swift theme={"system"}
  let entry = StopwordsDictionary.Entry(objectID: "down",
                                        language: .english,
                                        word: "down",
                                        state: .enabled)

  client.replaceDictionaryEntries(in: StopwordsDictionary.self, with: [entry]) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Replace plural entries

<CodeGroup>
  ```cs C# theme={"system"}
  Plural plural = new Plural()
  {
    ObjectID = objectId,
    Language = "fr",
    Words = new List<String>() { "cheval", "chevaux" }
  };

  // Synchronous
  DictionaryClient.ReplaceDictionaryEntries(algoliaDictionary, new List<DictionaryEntry>() { plural });

  // Asynchronous
  var replaceDictionaryResponse = await DictionaryClient.ReplaceDictionaryEntries(algoliaDictionary, new List<DictionaryEntry>() { plural });
  replaceDictionaryResponse.Wait();
  ```

  ```go Go theme={"system"}
  pluralEntry := search.NewPlural(entryID, "fr", []string{"cheval", "chevaux"})

  res, err := client.ReplaceDictionaryEntries(search.Plurals, []search.DictionaryEntry{pluralEntry})
  ```

  ```java Java theme={"system"}
  Plural plural = DictionaryEntry.plural("MyObjectID", "fr", Arrays.asList("cheval", "chevaux"));
  // Synchronous
  client.replaceDictionaryEntries(Dictionary.PLURALS, Collections.singletonList(plural));
  // Asynchronous
  client.replaceDictionaryEntriesAsync(Dictionary.PLURALS, Collections.singletonList(plural));
  ```

  ```js JavaScript theme={"system"}
  client.replaceDictionaryEntries("plurals", [
    {
      objectID: "chevaux",
      language: "fr",
      words: ["cheval", "chevaux"],
    },
  ]);
  ```

  ```kotlin Kotlin theme={"system"}
  val entry = DictionaryEntry.Plural(
      objectID = ObjectID("MyObjectID"),
      language = Language.French,
      words = listOf("cheval", "chevaux")
  )
  client.replaceDictionaryEntries(Dictionary.Plurals, listOf(entry))
  // or using extension function:
  client.replacePluralEntries(listOf(entry))
  ```

  ```php PHP theme={"system"}
  $client->replaceDictionaryEntries(
    'plurals',
    array(array(
      'objectID' => 'chevaux',
      'language' => 'fr',
      'words' => array('cheval', 'chevaux')
    ))
  );
  ```

  ```python Python theme={"system"}
  client.replace_dictionary_entries(
      "plurals",
      [{"objectID": "chevaux", "language": "fr", "words": ["cheval", "chevaux"]}],
  )
  ```

  ```ruby Ruby theme={"system"}
  client.replace_dictionary_entries(
    "plurals",
    [
      {
        objectID: "chevaux",
        language: "fr",
        words: %w[cheval chevaux]
      }
    ]
  )
  ```

  ```scala Scala theme={"system"}
  val entry = PluralEntry(
    objectID = "MyObjectID",
    language = "fr",
    words = Seq("cheval", "chevaux")
  )
  client.execute {
    replace dictionary Plurals entries Seq(entry)
  }
  ```

  ```swift Swift theme={"system"}
  let entry = PluralsDictionary.Entry(objectID: "chevaux",
                                      language: .french,
                                      words: ["cheval", "chevaux"])

  client.replaceDictionaryEntries(in: PluralsDictionary.self, with: [entry]) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

### Replace compound entries

<CodeGroup>
  ```cs C# theme={"system"}
  Compound compound = new Compound()
  {
    ObjectID = objectId,
    Language = "nl",
    Word = "kopfschmerztablette",
    Decomposition = new List<String>() { "kopf", "schmerz", "tablette" }
   };

   // Synchronous
   var replaceDictionaryResponse = DictionaryClient.ReplaceDictionaryEntries(algoliaDictionary, new List<DictionaryEntry>() { compound });

   // Asynchronous
   var replaceDictionaryResponse = await DictionaryClient.ReplaceDictionaryEntriesAsync(algoliaDictionary, new List<DictionaryEntry>() { compound });
   replaceDictionaryResponse.Wait();
  ```

  ```go Go theme={"system"}
  compoundEntry := search.NewCompound(entryID, "de", "kopfschmerztablette", []string{"kopf", "schmerz", "tablette"})

  res, err := client.ReplaceDictionaryEntries(search.Compounds, []search.DictionaryEntry{compoundEntry})
  ```

  ```java Java theme={"system"}
  Compound compound = DictionaryEntry.compound("MyObjectID", "de", "kopfschmerztablette",Arrays.asList("kopf", "schmerz", "tablette"));
  // Synchronous
  client.replaceDictionaryEntries(Dictionary.COMPOUNDS, Collections.singletonList(compound));
  // Asynchronous
  client.replaceDictionaryEntriesAsync(Dictionary.COMPOUNDS, Collections.singletonList(compound));
  ```

  ```js JavaScript theme={"system"}
  client.replaceDictionaryEntries("compounds", [
    {
      objectID: "kopfschmerztablette",
      language: "de",
      word: "kopfschmerztablette",
      decomposition: ["kopf", "schmerz", "tablette"],
    },
  ]);
  ```

  ```kotlin Kotlin theme={"system"}
  val entry = DictionaryEntry.Compound(
      objectID = ObjectID("MyObjectID"),
      language = Language.Dutch,
      word = "kopfschmerztablette",
      decomposition = listOf("kopf", "schmerz", "tablette")
  )
  client.replaceDictionaryEntries(Dictionary.Compounds, listOf(entry))
  // or using extension function:
  client.replaceCompoundEntries(listOf(entry))
  ```

  ```php PHP theme={"system"}
  $client->replaceDictionaryEntries(
    'compounds',
    array(array(
      'objectID' => 'kopfschmerztablette',
      'language' => 'de',
      'word' => 'kopfschmerztablette',
      'decomposition' => array('kopf', 'schmerz', 'tablette')
    ))
  );
  ```

  ```python Python theme={"system"}
  client.replace_dictionary_entries(
    'compounds',
    [{
      'objectID': 'kopfschmerztablette',
      'language': 'de',
      'word': 'kopfschmerztablette',
      'decomposition': ['kopf', 'schmerz', 'tablette]
    }]
  )
  ```

  ```ruby Ruby theme={"system"}
  client.replace_dictionary_entries(
    "compounds",
    [
      {
        objectID: "kopfschmerztablette",
        language: "de",
        word: "kopfschmerztablette",
        decomposition: %w[kopf schmerz tablette]
      }
    ]
  )
  ```

  ```scala Scala theme={"system"}
  val entry = CompoundEntry(
    objectID = "MyObjectID",
    language = "de",
    word = "kopfschmerztablette",
    decomposition = Seq("kopf", "schmerz", "tablette")
  )
  client.execute {
    replace dictionary Compounds entries Seq(entry)
  }
  ```

  ```swift Swift theme={"system"}
  let entry = CompoundsDictionary.Entry(objectID: "kopfschmerztablette",
                                        language: .german,
                                        word: "kopfschmerztablette",
                                        decomposition: ["kopf", "schmerz", "tablette"])

  client.replaceDictionaryEntries(in: CompoundsDictionary.self, with: [entry]) { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="dictionary" type="enum<string>" required>
  Dictionary type. One of: `stopword`, `plural`, `compound`.
</ParamField>

<ParamField body="dictionaryEntries" type="object[]" required>
  The dictionary entries to add.

  <Expandable>
    <ParamField body="objectID" type="string" required>
      Unique ID of the dictionary entry.
    </ParamField>

    <ParamField body="language" type="string" required>
      Language ISO code supported by this dictionary,
      for example `en` for English.
    </ParamField>

    <ParamField body="decomposition" type="string[]">
      List of decompositions of a word for the `compounds` dictionary.
      If empty, `word` is considered a compound atom.
      Otherwise, the compounds that `word` is decomposed into.
    </ParamField>

    <ParamField body="state" type="enum<string>" default="enabled">
      Whether this dictionary entry is active:

      * `enabled`: this dictionary entry is active
      * `disabled`: this dictionary entry is inactive
    </ParamField>

    <ParamField body="word" type="string">
      For the stop-word dictionary: the stop word you want to add.
      For the compounds dictionary:

      * Adds the word as compound atom (with empty `decomposition`)
      * Adds the word with a custom decomposition

      If the word is already included in Algolia's standard dictionary,
      you can override it by setting its state to `disabled`.
    </ParamField>

    <ParamField body="words" type="string[]">
      List of declensions for the `plurals` dictionary.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="requestOptions" type="object">
  Additional parameters to add to this request.
</ParamField>

## Response

<ResponseField name="taskID" type="integer">
  The task ID used with the [`waitTask`](/doc/libraries/sdk/v1/methods/wait-task) method.
</ResponseField>

<ResponseField name="updatedAt" type="string">
  Date at which the indexing job has been created.
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "updatedAt":"2013-01-18T15:33:13.556Z",
  "taskID": 678
}
```
