-
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.
Merge pull request #46 from o19s/44-pptss
Adds PPTSS sampling
- Loading branch information
Showing
12 changed files
with
415 additions
and
72 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
opensearch-search-quality-evaluation-plugin/scripts/create-query-set-no-sampling.sh
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
4 changes: 2 additions & 2 deletions
4
opensearch-search-quality-evaluation-plugin/scripts/create-query-set-using-pptss-sampling.sh
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
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
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
...ty-evaluation-plugin/src/main/java/org/opensearch/eval/samplers/AbstractQuerySampler.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.samplers; | ||
|
||
import org.opensearch.action.index.IndexRequest; | ||
import org.opensearch.action.support.WriteRequest; | ||
import org.opensearch.client.node.NodeClient; | ||
import org.opensearch.eval.SearchQualityEvaluationPlugin; | ||
|
||
import java.time.Instant; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
/** | ||
* An interface for sampling UBI queries. | ||
*/ | ||
public abstract class AbstractQuerySampler { | ||
|
||
/** | ||
* Gets the name of the sampler. | ||
* @return The name of the sampler. | ||
*/ | ||
abstract String getName(); | ||
|
||
/** | ||
* Samples the queries and inserts the query set into an index. | ||
* @return A query set ID. | ||
*/ | ||
abstract String sample() throws Exception; | ||
|
||
/** | ||
* Index the query set. | ||
*/ | ||
protected String indexQuerySet(final NodeClient client, final String name, final String description, final String sampling, Collection<String> queries) throws Exception { | ||
|
||
final Map<String, Object> querySet = new HashMap<>(); | ||
querySet.put("name", name); | ||
querySet.put("description", description); | ||
querySet.put("sampling", sampling); | ||
querySet.put("queries", queries); | ||
querySet.put("created_at", Instant.now().toEpochMilli()); | ||
|
||
final String querySetId = UUID.randomUUID().toString(); | ||
|
||
final IndexRequest indexRequest = new IndexRequest().index(SearchQualityEvaluationPlugin.QUERY_SETS_INDEX_NAME) | ||
.id(querySetId) | ||
.source(querySet) | ||
.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); | ||
|
||
client.index(indexRequest).get(); | ||
|
||
return querySetId; | ||
|
||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
...aluation-plugin/src/main/java/org/opensearch/eval/samplers/AbstractSamplerParameters.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,41 @@ | ||
/* | ||
* 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.samplers; | ||
|
||
public class AbstractSamplerParameters { | ||
|
||
private final String name; | ||
private final String description; | ||
private final String sampling; | ||
private final int querySetSize; | ||
|
||
public AbstractSamplerParameters(final String name, final String description, final String sampling, final int querySetSize) { | ||
this.name = name; | ||
this.description = description; | ||
this.sampling = sampling; | ||
this.querySetSize = querySetSize; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public String getSampling() { | ||
return sampling; | ||
} | ||
|
||
public int getQuerySetSize() { | ||
return querySetSize; | ||
} | ||
|
||
} |
Oops, something went wrong.