Skip to content

Commit

Permalink
Merge pull request #93 from o19s/89-query-set-mapping
Browse files Browse the repository at this point in the history
Add mapping for query sets
  • Loading branch information
jzonthemtn authored Feb 5, 2025
2 parents 9a6aa24 + e728a79 commit 9989d2f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/create-query-set.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"name": "",
"description": "",
"sampling": "",
"querySetSize": 500
"querySetSize": 250
}
2 changes: 2 additions & 0 deletions src/main/java/org/opensearch/eval/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public static void main(String[] args) throws Exception {

if(file.exists()) {

searchEngine.createQuerySetIndex();

final String jsonString = Files.readString(file.toPath(), StandardCharsets.UTF_8);
final JsonElement jsonElement = JsonParser.parseString(jsonString);
final JsonObject jsonObject = jsonElement.getAsJsonObject();
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/org/opensearch/eval/engine/OpenSearchEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
import java.util.Set;
import java.util.UUID;

import static org.opensearch.eval.Constants.QUERY_SETS_INDEX_NAME;
import static org.opensearch.eval.judgments.clickmodel.coec.CoecClickModel.EVENT_CLICK;
import static org.opensearch.eval.judgments.clickmodel.coec.CoecClickModel.EVENT_IMPRESSION;
import static org.opensearch.eval.judgments.clickmodel.coec.CoecClickModel.INDEX_QUERY_DOC_CTR;
Expand Down Expand Up @@ -901,4 +902,28 @@ public String indexJudgments(final Collection<Judgment> judgments) throws Except

}

@Override
public void createQuerySetIndex() throws Exception {

final boolean querySetsIndexExists = doesIndexExist(QUERY_SETS_INDEX_NAME);

if (!querySetsIndexExists) {

final String mapping = "{\n" +
" \"properties\": {\n" +
" \"timestamp\": { \"type\": \"date\", \"format\": \"strict_date_time\" },\n" +
" \"description\": { \"type\": \"text\" },\n" +
" \"id\": { \"type\": \"keyword\" },\n" +
" \"name\": { \"type\": \"keyword\" },\n" +
" \"query_set_queries\": { \"type\": \"object\" },\n" +
" \"sampling\": { \"type\": \"keyword\" }\n" +
" }\n" +
" }";

createIndex(QUERY_SETS_INDEX_NAME, mapping);

}

}

}
1 change: 1 addition & 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,7 @@ public abstract class SearchEngine {
public abstract boolean doesIndexExist(String index) throws IOException;
public abstract boolean createIndex(String index, String mapping) throws IOException;
public abstract boolean deleteIndex(String index) throws IOException;
public abstract void createQuerySetIndex() throws Exception;

public abstract String getUserQuery(final String queryId) throws Exception;
public abstract UbiQuery getQueryFromQueryId(final String queryId) throws Exception;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/opensearch/eval/model/data/QuerySet.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,27 @@
*/
package org.opensearch.eval.model.data;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Collection;
import java.util.Map;
import java.util.UUID;

public class QuerySet extends AbstractData {

@JsonProperty("name")
private String name;

@JsonProperty("description")
private String description;

@JsonProperty("sampling")
private String sampling;

@JsonProperty("query_set_queries")
private Collection<Map<String, Long>> querySetQueries;

@JsonProperty("timestamp")
private String timestamp;

public QuerySet() {
Expand Down

0 comments on commit 9989d2f

Please sign in to comment.