Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ typo_tolerance_guide_4: |-
};
typoTolerance.setMinWordSizeForTypos(minWordSizeTypos);
client.index("movies").updateTypoToleranceSettings(typoTolerance);
typo_tolerance_guide_5: |-
TypoTolerance typoTolerance = new TypoTolerance();
typoTolerance.setDisableOnNumbers(true);
client.index("1917").updateTypoToleranceSettings(typoTolerance);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
client.index("1917").updateTypoToleranceSettings(typoTolerance);
client.index("movies").updateTypoToleranceSettings(typoTolerance);

getting_started_add_documents: |-
// For Maven:
// Add the following code to the `<dependencies>` section of your project:
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/meilisearch/sdk/model/TypoTolerance.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class TypoTolerance {
protected HashMap<String, Integer> minWordSizeForTypos;
protected String[] disableOnWords;
protected String[] disableOnAttributes;
protected boolean disableOnNumbers;
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated

public TypoTolerance() {}
}
18 changes: 18 additions & 0 deletions src/test/java/com/meilisearch/integration/SettingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,24 @@ public void testResetTypoTolerance() throws Exception {
is(notNullValue()));
}

@Test
@DisplayName("Test update disableOnNumbers tolerance settings")
public void testUpdateDisableOnNumbersTolerance() throws Exception {
Index index = createIndex("testUpdateDisableOnNumbers");

TypoTolerance newTypoTolerance = new TypoTolerance();
index.waitForTask(index.updateTypoToleranceSettings(newTypoTolerance).getTaskUid());
TypoTolerance updatedTypoToleranceDefault = index.getTypoToleranceSettings();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can simplify by simply fetching the initial typo tolerance settings, e.g. simply

Index index = createIndex("testUpdateDisableOnNumbers");
TypoTolerance defaultTypoTolerance = index.getTypoToleranceSettings();

Initializing an empty index with default settings can be confusing


TypoTolerance newTypoToleranceDisableOnNumbers = new TypoTolerance();
newTypoToleranceDisableOnNumbers.setDisableOnNumbers(true);
index.waitForTask(index.updateTypoToleranceSettings(newTypoToleranceDisableOnNumbers).getTaskUid());
TypoTolerance updatedTypoToleranceDisableOnNumbers = index.getTypoToleranceSettings();

assertThat(updatedTypoToleranceDefault.isDisableOnNumbers(), is(equalTo(false)));
assertThat(updatedTypoToleranceDisableOnNumbers.isDisableOnNumbers(), is(equalTo(true)));
}

/** Tests of all the specifics setting methods when null is passed */
@Test
@DisplayName("Test update synonyms settings when null is passed")
Expand Down