Skip to content

Commit

Permalink
Spotless apply
Browse files Browse the repository at this point in the history
Signed-off-by: Siddhant Deshmukh <deshsid@amazon.com>
  • Loading branch information
deshsidd committed Sep 3, 2024
1 parent 876baea commit 6fb7300
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ protected String defaultTopQueriesSettings() {
+ "}";
}


protected String defaultTopQueryGroupingSettings() {
return "{\n"
+ " \"persistent\" : {\n"
Expand Down Expand Up @@ -248,38 +247,32 @@ private String searchBody(String queryType) {
switch (queryType) {
case "match":
// Query shape 1: Match query
return "{\n" +
" \"query\": {\n" +
" \"match\": {\n" +
" \"field1\": \"value1\"\n" +
" }\n" +
" }\n" +
"}";
return "{\n" + " \"query\": {\n" + " \"match\": {\n" + " \"field1\": \"value1\"\n" + " }\n" + " }\n" + "}";

case "range":
// Query shape 2: Range query
return "{\n" +
" \"query\": {\n" +
" \"range\": {\n" +
" \"field2\": {\n" +
" \"gte\": 10,\n" +
" \"lte\": 50\n" +
" }\n" +
" }\n" +
" }\n" +
"}";
return "{\n"
+ " \"query\": {\n"
+ " \"range\": {\n"
+ " \"field2\": {\n"
+ " \"gte\": 10,\n"
+ " \"lte\": 50\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";

case "term":
// Query shape 3: Term query
return "{\n" +
" \"query\": {\n" +
" \"term\": {\n" +
" \"field3\": {\n" +
" \"value\": \"exact-value\"\n" +
" }\n" +
" }\n" +
" }\n" +
"}";
return "{\n"
+ " \"query\": {\n"
+ " \"term\": {\n"
+ " \"field3\": {\n"
+ " \"value\": \"exact-value\"\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}";

default:
throw new IllegalArgumentException("Unknown query type: " + queryType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@
*/
package org.opensearch.plugin.insights.core.service.grouper;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.junit.Assert;
import org.opensearch.client.Request;
import org.opensearch.client.Response;
import org.opensearch.plugin.insights.QueryInsightsRestTestCase;
import org.opensearch.plugin.insights.settings.QueryInsightsSettings;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
* ITs for Grouping Top Queries by none
*/
Expand Down Expand Up @@ -60,16 +59,14 @@ public void testGroupingByNone() throws IOException, InterruptedException {
}

private String groupByNoneSettings() {
return "{\n" +
" \"persistent\" : {\n" +
" \"search.insights.top_queries.latency.enabled\" : \"true\",\n" +
" \"search.insights.top_queries.latency.window_size\" : \"1m\",\n" +
" \"search.insights.top_queries.latency.top_n_size\" : 100,\n" +
" \"search.insights.top_queries.group_by\" : \"none\",\n" +
" \"search.insights.top_queries.max_groups\" : 5\n" +
" }\n" +
"}";
return "{\n"
+ " \"persistent\" : {\n"
+ " \"search.insights.top_queries.latency.enabled\" : \"true\",\n"
+ " \"search.insights.top_queries.latency.window_size\" : \"1m\",\n"
+ " \"search.insights.top_queries.latency.top_n_size\" : 100,\n"
+ " \"search.insights.top_queries.group_by\" : \"none\",\n"
+ " \"search.insights.top_queries.max_groups\" : 5\n"
+ " }\n"
+ "}";
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
*/
package org.opensearch.plugin.insights.core.service.grouper;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import org.junit.Assert;
import org.opensearch.client.Request;
import org.opensearch.client.Response;
import org.opensearch.client.ResponseException;
import org.opensearch.plugin.insights.QueryInsightsRestTestCase;
import org.opensearch.plugin.insights.settings.QueryInsightsSettings;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
* ITs for Grouping Top Queries by similarity
*/
Expand Down Expand Up @@ -98,63 +97,40 @@ public void testValidQueryGroupingSettings() throws IOException {
private String[] invalidQueryGroupingSettings() {
return new String[] {
// Invalid max_groups: below minimum (0)
"{\n" +
" \"persistent\" : {\n" +
" \"search.insights.top_queries.max_groups\" : 0\n" +
" }\n" +
"}",
"{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.max_groups\" : 0\n" + " }\n" + "}",

// Invalid max_groups: above maximum (10001)
"{\n" +
" \"persistent\" : {\n" +
" \"search.insights.top_queries.max_groups\" : 10001\n" +
" }\n" +
"}",
"{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.max_groups\" : 10001\n" + " }\n" + "}",

// Invalid group_by: unsupported value
"{\n" +
" \"persistent\" : {\n" +
" \"search.insights.top_queries.group_by\" : \"unsupported_value\"\n" +
" }\n" +
"}"
};
"{\n"
+ " \"persistent\" : {\n"
+ " \"search.insights.top_queries.group_by\" : \"unsupported_value\"\n"
+ " }\n"
+ "}" };
}

private String[] validQueryGroupingSettings() {
return new String[]{
return new String[] {
// Valid max_groups: minimum value (1)
"{\n" +
" \"persistent\" : {\n" +
" \"search.insights.top_queries.max_groups\" : 1\n" +
" }\n" +
"}",
"{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.max_groups\" : 1\n" + " }\n" + "}",

// Valid max_groups: maximum value (10000)
"{\n" +
" \"persistent\" : {\n" +
" \"search.insights.top_queries.max_groups\" : 10000\n" +
" }\n" +
"}",
"{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.max_groups\" : 10000\n" + " }\n" + "}",

// Valid group_by: supported value (SIMILARITY)
"{\n" +
" \"persistent\" : {\n" +
" \"search.insights.top_queries.group_by\" : \"SIMILARITY\"\n" +
" }\n" +
"}"
};
"{\n" + " \"persistent\" : {\n" + " \"search.insights.top_queries.group_by\" : \"SIMILARITY\"\n" + " }\n" + "}" };
}

private String groupByNoneSettings() {
return "{\n" +
" \"persistent\" : {\n" +
" \"search.insights.top_queries.latency.enabled\" : \"true\",\n" +
" \"search.insights.top_queries.latency.window_size\" : \"1m\",\n" +
" \"search.insights.top_queries.latency.top_n_size\" : 100,\n" +
" \"search.insights.top_queries.group_by\" : \"none\",\n" +
" \"search.insights.top_queries.max_groups\" : 5\n" +
" }\n" +
"}";
return "{\n"
+ " \"persistent\" : {\n"
+ " \"search.insights.top_queries.latency.enabled\" : \"true\",\n"
+ " \"search.insights.top_queries.latency.window_size\" : \"1m\",\n"
+ " \"search.insights.top_queries.latency.top_n_size\" : 100,\n"
+ " \"search.insights.top_queries.group_by\" : \"none\",\n"
+ " \"search.insights.top_queries.max_groups\" : 5\n"
+ " }\n"
+ "}";
}
}

0 comments on commit 6fb7300

Please sign in to comment.