Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correction of naming methods related to Ranking Rules #539

Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 2 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ update_stop_words_1: |-
reset_stop_words_1: |-
client.index("movies").resetStopWordsSettings();
get_ranking_rules_1: |-
client.index("movies").getRankingRuleSettings();
client.index("movies").getRankingRulesSettings();
update_ranking_rules_1: |-
Settings settings = new Settings();
settings.setRankingRules(new String[]
Expand All @@ -191,7 +191,7 @@ update_ranking_rules_1: |-
});
client.index("movies").updateSettings(settings);
reset_ranking_rules_1: |-
client.index("movies").resetRankingRuleSettings();
client.index("movies").resetRankingRulesSettings();
get_distinct_attribute_1: |-
client.index("shoes").getDistinctAttributeSettings();
update_distinct_attribute_1: |-
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/meilisearch/sdk/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,36 +392,36 @@ public TaskInfo resetSettings() throws MeilisearchException {
}

/**
* Gets the ranking rule settings of the index Refer
* Gets the ranking rules settings of the index Refer
* https://docs.meilisearch.com/reference/api/settings.html#get-settings
*
* @return ranking rules of a given uid as String
* @throws MeilisearchException if an error occurs
*/
public String[] getRankingRuleSettings() throws MeilisearchException {
return this.settingsHandler.getRankingRuleSettings(this.uid);
public String[] getRankingRulesSettings() throws MeilisearchException {
return this.settingsHandler.getRankingRulesSettings(this.uid);
}

/**
* Updates the ranking rule settings of the index Refer
* Updates the ranking rules settings of the index Refer
* https://docs.meilisearch.com/reference/api/settings.html#update-settings
*
* @param rankingRules array that contain the data with the new ranking rules
* @return TaskInfo instance
* @throws MeilisearchException if an error occurs
*/
public TaskInfo updateRankingRuleSettings(String[] rankingRules) throws MeilisearchException {
return this.settingsHandler.updateRankingRuleSettings(this.uid, rankingRules);
public TaskInfo updateRankingRulesSettings(String[] rankingRules) throws MeilisearchException {
return this.settingsHandler.updateRankingRulesSettings(this.uid, rankingRules);
}

/**
* Resets the ranking rule settings of the index Refer
* Resets the ranking rules settings of the index Refer
* https://docs.meilisearch.com/reference/api/settings.html#reset-settings
*
* @return TaskInfo instance
* @throws MeilisearchException if an error occurs
*/
public TaskInfo resetRankingRuleSettings() throws MeilisearchException {
public TaskInfo resetRankingRulesSettings() throws MeilisearchException {
return this.settingsHandler.resetRankingRulesSettings(this.uid);
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/meilisearch/sdk/SettingsHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ TaskInfo resetSettings(String uid) throws MeilisearchException {
* @return an array of strings that contains the ranking rules settings
* @throws MeilisearchException if an error occurs
*/
String[] getRankingRuleSettings(String uid) throws MeilisearchException {
String[] getRankingRulesSettings(String uid) throws MeilisearchException {
return httpClient.get(
settingsPath(uid).addSubroute("ranking-rules").getURL(), String[].class);
}
Expand All @@ -78,7 +78,7 @@ String[] getRankingRuleSettings(String uid) throws MeilisearchException {
* @return TaskInfo instance
* @throws MeilisearchException if an error occurs
*/
TaskInfo updateRankingRuleSettings(String uid, String[] rankingRules)
TaskInfo updateRankingRulesSettings(String uid, String[] rankingRules)
throws MeilisearchException {
return httpClient.put(
settingsPath(uid).addSubroute("ranking-rules").getURL(),
Expand Down
62 changes: 31 additions & 31 deletions src/test/java/com/meilisearch/integration/SettingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,20 +191,20 @@ public void testResetSettings() throws Exception {
/** Tests of the ranking rules setting methods */
@Test
@DisplayName("Test get ranking rules settings by uid")
public void testGetRankingRuleSettings() throws Exception {
Index index = createIndex("testGetRankingRuleSettings");
public void testGetRankingRulesSettings() throws Exception {
Index index = createIndex("testGetRankingRulesSettings");
Settings initialSettings = index.getSettings();
String[] initialRankingRules = index.getRankingRuleSettings();
String[] initialRankingRules = index.getRankingRulesSettings();

assertEquals(initialSettings.getRankingRules().length, initialRankingRules.length);
assertArrayEquals(initialSettings.getRankingRules(), initialRankingRules);
}

@Test
@DisplayName("Test update ranking rules settings")
public void testUpdateRankingRuleSettings() throws Exception {
Index index = createIndex("testUpdateRankingRuleSettings");
String[] initialRuleSettings = index.getRankingRuleSettings();
public void testUpdateRankingRulesSettings() throws Exception {
Index index = createIndex("testUpdateRankingRulesSettings");
String[] initialRulesSettings = index.getRankingRulesSettings();
String[] newRankingRules = {
"typo",
"words",
Expand All @@ -216,19 +216,19 @@ public void testUpdateRankingRuleSettings() throws Exception {
"rank:desc"
};

index.waitForTask(index.updateRankingRuleSettings(newRankingRules).getTaskUid());
String[] updatedRankingRuleSettings = index.getRankingRuleSettings();
index.waitForTask(index.updateRankingRulesSettings(newRankingRules).getTaskUid());
String[] updatedRankingRulesSettings = index.getRankingRulesSettings();

assertEquals(newRankingRules.length, updatedRankingRuleSettings.length);
assertArrayEquals(newRankingRules, updatedRankingRuleSettings);
assertNotEquals(initialRuleSettings.length, updatedRankingRuleSettings.length);
assertEquals(newRankingRules.length, updatedRankingRulesSettings.length);
assertArrayEquals(newRankingRules, updatedRankingRulesSettings);
assertNotEquals(initialRulesSettings.length, updatedRankingRulesSettings.length);
}

@Test
@DisplayName("Test reset ranking rules settings")
public void testResetRankingRuleSettings() throws Exception {
Index index = createIndex("testResetRankingRuleSettings");
String[] initialRuleSettings = index.getRankingRuleSettings();
public void testResetRankingRulesSettings() throws Exception {
Index index = createIndex("testResetRankingRulesSettings");
String[] initialRulesSettings = index.getRankingRulesSettings();
String[] newRankingRules = {
"typo",
"words",
Expand All @@ -240,19 +240,19 @@ public void testResetRankingRuleSettings() throws Exception {
"rank:desc"
};

index.waitForTask(index.updateRankingRuleSettings(newRankingRules).getTaskUid());
String[] updatedRankingRuleSettings = index.getRankingRuleSettings();
index.waitForTask(index.updateRankingRulesSettings(newRankingRules).getTaskUid());
String[] updatedRankingRulesSettings = index.getRankingRulesSettings();

index.waitForTask(index.resetRankingRuleSettings().getTaskUid());
String[] rankingRulesAfterReset = index.getRankingRuleSettings();
index.waitForTask(index.resetRankingRulesSettings().getTaskUid());
String[] rankingRulesAfterReset = index.getRankingRulesSettings();

assertEquals(newRankingRules.length, updatedRankingRuleSettings.length);
assertArrayEquals(newRankingRules, updatedRankingRuleSettings);
assertNotEquals(initialRuleSettings.length, updatedRankingRuleSettings.length);
assertEquals(newRankingRules.length, updatedRankingRulesSettings.length);
assertArrayEquals(newRankingRules, updatedRankingRulesSettings);
assertNotEquals(initialRulesSettings.length, updatedRankingRulesSettings.length);

assertNotEquals(updatedRankingRuleSettings.length, rankingRulesAfterReset.length);
assertEquals(initialRuleSettings.length, rankingRulesAfterReset.length);
assertArrayEquals(initialRuleSettings, rankingRulesAfterReset);
assertNotEquals(updatedRankingRulesSettings.length, rankingRulesAfterReset.length);
assertEquals(initialRulesSettings.length, rankingRulesAfterReset.length);
assertArrayEquals(initialRulesSettings, rankingRulesAfterReset);
}

/** Tests of the synonyms setting methods */
Expand Down Expand Up @@ -741,9 +741,9 @@ public void testUpdateStopWordsSettingsUsingNull() throws Exception {

@Test
@DisplayName("Test reset ranking rules when null value is passed")
public void testUpdateRankingRuleSettingsUsingNull() throws Exception {
Index index = createIndex("testUpdateRankingRuleSettingsUsingNull");
String[] initialRankingRule = index.getRankingRuleSettings();
public void testUpdateRankingRulesSettingsUsingNull() throws Exception {
Index index = createIndex("testUpdateRankingRulesSettingsUsingNull");
String[] initialRankingRule = index.getRankingRulesSettings();
String[] newRankingRules = {
"typo",
"words",
Expand All @@ -755,11 +755,11 @@ public void testUpdateRankingRuleSettingsUsingNull() throws Exception {
"rank:desc"
};

index.waitForTask(index.updateRankingRuleSettings(newRankingRules).getTaskUid());
String[] newRankingRule = index.getRankingRuleSettings();
index.waitForTask(index.updateRankingRulesSettings(newRankingRules).getTaskUid());
String[] newRankingRule = index.getRankingRulesSettings();

index.waitForTask(index.updateRankingRuleSettings(null).getTaskUid());
String[] resetRankingRule = index.getRankingRuleSettings();
index.waitForTask(index.updateRankingRulesSettings(null).getTaskUid());
String[] resetRankingRule = index.getRankingRulesSettings();

assertNotEquals(newRankingRule.length, resetRankingRule.length);
assertEquals(initialRankingRule.length, resetRankingRule.length);
Expand Down