-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f2c56b1
commit 6f95612
Showing
5 changed files
with
127 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...evaluation-plugin/src/main/java/org/opensearch/eval/runners/OpenSearchQuerySetRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package org.opensearch.eval.runners; | ||
|
||
import org.opensearch.action.search.SearchRequest; | ||
import org.opensearch.action.search.SearchResponse; | ||
import org.opensearch.client.Client; | ||
import org.opensearch.eval.SearchQualityEvaluationPlugin; | ||
import org.opensearch.index.query.QueryBuilders; | ||
import org.opensearch.search.builder.SearchSourceBuilder; | ||
|
||
import java.util.Collection; | ||
|
||
public class OpenSearchQuerySetRunner extends QuerySetRunner { | ||
|
||
final Client client; | ||
|
||
public OpenSearchQuerySetRunner(final Client client) { | ||
this.client = client; | ||
} | ||
|
||
@Override | ||
public QuerySetRunResult run(String querySetId) { | ||
|
||
// Get the query set. | ||
final SearchSourceBuilder getQuerySetSearchSourceBuilder = new SearchSourceBuilder(); | ||
getQuerySetSearchSourceBuilder.query(QueryBuilders.matchQuery("_id", querySetId)); | ||
|
||
final SearchRequest getQuerySetSearchRequest = new SearchRequest(SearchQualityEvaluationPlugin.QUERY_SETS_INDEX_NAME); | ||
getQuerySetSearchRequest.source(getQuerySetSearchSourceBuilder); | ||
|
||
try { | ||
|
||
final SearchResponse searchResponse = client.search(getQuerySetSearchRequest).get(); | ||
|
||
// The queries from the query set that will be run. | ||
final Collection<String> queries = (Collection<String>) searchResponse.getHits().getAt(0).getSourceAsMap().get("queries"); | ||
|
||
// TODO: Initiate the running of the query set. | ||
for(final String query : queries) { | ||
|
||
// TODO: What should this query be? | ||
final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder(); | ||
searchSourceBuilder.query(QueryBuilders.matchQuery("_id", querySetId)); | ||
|
||
} | ||
|
||
final SearchMetrics searchMetrics = new SearchMetrics(); | ||
final QuerySetRunResult querySetRunResult = new QuerySetRunResult(searchMetrics); | ||
return querySetRunResult; | ||
|
||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
} | ||
|
||
} |
27 changes: 27 additions & 0 deletions
27
...uality-evaluation-plugin/src/main/java/org/opensearch/eval/runners/QuerySetRunResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package org.opensearch.eval.runners; | ||
|
||
public class QuerySetRunResult { | ||
|
||
private SearchMetrics searchMetrics; | ||
|
||
public QuerySetRunResult(final SearchMetrics searchMetrics) { | ||
this.searchMetrics = searchMetrics; | ||
} | ||
|
||
public SearchMetrics getSearchMetrics() { | ||
return searchMetrics; | ||
} | ||
|
||
public void setSearchMetrics(SearchMetrics searchMetrics) { | ||
this.searchMetrics = searchMetrics; | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...h-quality-evaluation-plugin/src/main/java/org/opensearch/eval/runners/QuerySetRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package org.opensearch.eval.runners; | ||
|
||
public abstract class QuerySetRunner { | ||
|
||
abstract QuerySetRunResult run(String querySetId); | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...ch-quality-evaluation-plugin/src/main/java/org/opensearch/eval/runners/SearchMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
package org.opensearch.eval.runners; | ||
|
||
public class SearchMetrics { | ||
|
||
} |