Skip to content

Commit

Permalink
Working on judgments index.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Feb 4, 2025
1 parent 17f52b0 commit 1329012
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 30 deletions.
31 changes: 1 addition & 30 deletions src/main/java/org/opensearch/eval/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,35 +272,6 @@ public static void main(String[] args) throws Exception {
//
// }
//
// private void createJudgmentsIndex(final NodeClient client) throws Exception {
//
// // If the judgments index does not exist we need to create it.
// final IndicesExistsRequest indicesExistsRequest = new IndicesExistsRequest(Constants.JUDGMENTS_INDEX_NAME);
//
// final IndicesExistsResponse indicesExistsResponse = client.admin().indices().exists(indicesExistsRequest).get();
//
// if(!indicesExistsResponse.isExists()) {
//
// // TODO: Read this mapping from a resource file instead.
// final String mapping = "{\n" +
// " \"properties\": {\n" +
// " \"judgments_id\": { \"type\": \"keyword\" },\n" +
// " \"query_id\": { \"type\": \"keyword\" },\n" +
// " \"query\": { \"type\": \"keyword\" },\n" +
// " \"document_id\": { \"type\": \"keyword\" },\n" +
// " \"judgment\": { \"type\": \"double\" },\n" +
// " \"timestamp\": { \"type\": \"date\", \"format\": \"strict_date_time\" }\n" +
// " }\n" +
// " }";
//
// // Create the judgments index.
// final CreateIndexRequest createIndexRequest = new CreateIndexRequest(Constants.JUDGMENTS_INDEX_NAME).mapping(mapping);
//
// // TODO: Don't use .get()
// client.admin().indices().create(createIndexRequest).get();
//
// }
//
// }


}
30 changes: 30 additions & 0 deletions src/main/java/org/opensearch/eval/engine/OpenSearchEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -1016,4 +1016,34 @@ public void saveQueryRunResult(final QuerySetRunResult querySetRunResult) throws

}

@Override
public void createJudgmentsIndex() throws Exception {

final boolean dashboardMetricsIndexExists = doesIndexExist(JUDGMENTS_INDEX_NAME);

if (!dashboardMetricsIndexExists) {

// Create the index.
// TODO: Read this mapping from a resource file instead.
final String mapping = "{\n" +
" \"properties\": {\n" +
" \"datetime\": { \"type\": \"date\", \"format\": \"strict_date_time\" },\n" +
" \"search_config\": { \"type\": \"keyword\" },\n" +
" \"query_set_id\": { \"type\": \"keyword\" },\n" +
" \"query\": { \"type\": \"keyword\" },\n" +
" \"metric\": { \"type\": \"keyword\" },\n" +
" \"value\": { \"type\": \"double\" },\n" +
" \"application\": { \"type\": \"keyword\" },\n" +
" \"evaluation_id\": { \"type\": \"keyword\" },\n" +
" \"frogs_percent\": { \"type\": \"double\" }\n" +
" }\n" +
" }";

// TODO: Make sure the index gets created successfully.
createIndex(DASHBOARD_METRICS_INDEX_NAME, mapping);

}

}

}
2 changes: 2 additions & 0 deletions src/main/java/org/opensearch/eval/engine/SearchEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public abstract class SearchEngine {

public abstract boolean doesIndexExist(String index) throws IOException;
public abstract boolean createIndex(String index, String mapping) throws IOException;
public abstract void createJudgmentsIndex() throws Exception;

public abstract boolean deleteIndex(String index) throws IOException;

public abstract String getUserQuery(final String queryId) throws Exception;
Expand Down

0 comments on commit 1329012

Please sign in to comment.