Skip to content

Commit

Permalink
Adding back standalone app.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Nov 26, 2024
1 parent 32f5823 commit 240074d
Show file tree
Hide file tree
Showing 30 changed files with 1,638 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ curl -s http://localhost:9200/judgments/_search | jq

This is a standalone Java application to generate implicit judgments from indexed UBI data. It runs outside OpenSearch and queries the UBI indexes to get the data for calculating the implicit judgments.

To run it, run the `org.opensearch.qef.App` class. This will connect to OpenSearch running on `localhost:9200`. It expects the `ubi_events` and `ubi_queries` indexes to exist and be populated.
To run it, run the `org.opensearch.eval.App` class. This will connect to OpenSearch running on `localhost:9200`. It expects the `ubi_events` and `ubi_queries` indexes to exist and be populated.

## License

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/*
* 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.judgments.model;

public class QuerySetQuery {
Expand Down
20 changes: 20 additions & 0 deletions opensearch-search-quality-evaluation/aggs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash -e

curl -X GET http://localhost:9200/ubi_events/_search -H "Content-Type: application/json" -d'
{
"size": 0,
"aggs": {
"By_Action": {
"terms": {
"field": "action_name"
},
"aggs": {
"By_Position": {
"terms": {
"field": "event_attributes.position.index"
}
}
}
}
}
}' | jq
40 changes: 40 additions & 0 deletions opensearch-search-quality-evaluation/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

apply plugin: 'java'
apply plugin: 'java-library-distribution'
apply plugin: 'application'

description = "opensearch-search-quality-implicit-judgments"

repositories {
mavenLocal()
mavenCentral()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
}

test {
useJUnitPlatform()
}

dependencies {
implementation 'org.opensearch.client:opensearch-rest-high-level-client:2.18.0'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.4'
compileOnly "org.apache.logging.log4j:log4j-core:2.24.0"
implementation "org.apache.commons:commons-lang3:3.17.0"
implementation "com.google.code.gson:gson:2.11.0"

testImplementation "org.mockito:mockito-core:5.14.2"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
}

tasks.withType(Tar){
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

tasks.withType(Zip){
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
Binary file added opensearch-search-quality-evaluation/coec.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions opensearch-search-quality-evaluation/queries.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
GET ubi_queries/_search

GET ubi_events/_search

GET rank_aggregated_ctr/_search

GET click_through_rates/_search

GET judgments/_search

DELETE rank_aggregated_ctr,click_through_rates,judgments
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.opensearch.eval;

import org.apache.http.HttpHost;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.client.RestClient;
import org.opensearch.client.RestClientBuilder;
import org.opensearch.client.RestHighLevelClient;
import org.opensearch.eval.clickmodel.coec.CoecClickModel;
import org.opensearch.eval.clickmodel.coec.CoecClickModelParameters;
import org.opensearch.eval.model.Judgment;

import java.util.Collection;

/**
* Entry point for the OpenSearch Evaluation Framework standalone app.
*/
public class App {

private static final Logger LOGGER = LogManager.getLogger(App.class.getName());

public static void main(String[] args) throws Exception {

final RestClientBuilder builder = RestClient.builder(new HttpHost("localhost", 9200, "http"));
final RestHighLevelClient restHighLevelClient = new RestHighLevelClient(builder);

final CoecClickModelParameters coecClickModelParameters = new CoecClickModelParameters(false, 20);
final CoecClickModel coecClickModel = new CoecClickModel(coecClickModelParameters);

final Collection<Judgment> judgments = coecClickModel.calculateJudgments();
Judgment.showJudgments(judgments);

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package org.opensearch.eval.clickmodel;

import org.opensearch.eval.model.Judgment;

import java.io.IOException;
import java.util.Collection;

public abstract class ClickModel<T extends ClickModelParameters> {

public static final String INDEX_UBI_EVENTS = "ubi_events";
public static final String INDEX_UBI_QUERIES = "ubi_queries";

public abstract Collection<Judgment> calculateJudgments() throws IOException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.opensearch.eval.clickmodel;

public abstract class ClickModelParameters {

}
Loading

0 comments on commit 240074d

Please sign in to comment.