Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Commit

Permalink
Making names consistent to ubl for now. Removing dynamic strict.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Feb 15, 2024
1 parent e278f8c commit 37207bf
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 63 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM opensearchproject/opensearch:2.11.1

COPY ./build/distributions/opensearch-search-relevance.zip /tmp/
COPY ./build/distributions/opensearch-ubl.zip /tmp/

RUN /usr/share/opensearch/bin/opensearch-plugin install file:/tmp/opensearch-search-relevance.zip
RUN /usr/share/opensearch/bin/opensearch-plugin install file:/tmp/opensearch-ubl.zip
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,23 @@ Start the containers:
Initialize the `awesome` search relevance index:

```
curl -X PUT http://localhost:9200/_plugins/search_relevance/awesome
curl -X PUT http://localhost:9200/_plugins/ubl/awesome
```

Send an event to the `awesome` store:

```
curl -X POST http://localhost:9200/_plugins/search_relevance/awesome -H "Content-Type: application/json" -d @instant-search.json
curl -X POST http://localhost:9200/_plugins/ubl/awesome -H "Content-Type: application/json" -d @instant-search.json
```

Get events:

```
curl http://localhost:9200/.awesome_events/_search
```

Delete the store:

```
curl -X DELETE http://localhost:9200/_plugins/ubl/awesome
```
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.yaml-rest-test'

opensearchplugin {
name 'opensearch-search-relevance'
description 'OpenSearch Search Relevance Plugin'
classname 'org.opensearch.relevance.SearchRelevancePlugin'
name 'opensearch-ubl'
description 'OpenSearch User Behavior Logging Plugin'
classname 'org.opensearch.UserBehaviorLoggingPlugin'
licenseFile rootProject.file('LICENSE.txt')
noticeFile rootProject.file('NOTICE.txt')
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
* in the user manual at https://docs.gradle.org/6.5.1/userguide/multi_project_builds.html
*/

rootProject.name = 'search-relevance-plugin'
rootProject.name = 'user-behavior-logging-plugin'
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.relevance;
package org.opensearch;

public class SettingsConstants {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@
* compatible open source license.
*/

package org.opensearch.relevance;
package org.opensearch;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.UserBehaviorLoggingRestHandler;
import org.opensearch.action.UserBehaviorLoggingSearchFilter;
import org.opensearch.action.support.ActionFilter;
import org.opensearch.backends.Backend;
import org.opensearch.backends.OpenSearchBackend;
import org.opensearch.client.Client;
import org.opensearch.cluster.metadata.IndexNameExpressionResolver;
import org.opensearch.cluster.node.DiscoveryNodes;
Expand All @@ -20,13 +24,9 @@
import org.opensearch.core.xcontent.NamedXContentRegistry;
import org.opensearch.env.Environment;
import org.opensearch.env.NodeEnvironment;
import org.opensearch.events.EventManager;
import org.opensearch.plugins.ActionPlugin;
import org.opensearch.plugins.Plugin;
import org.opensearch.relevance.action.SearchRelevanceRestHandler;
import org.opensearch.relevance.action.SearchRelevanceSearchFilter;
import org.opensearch.relevance.backends.Backend;
import org.opensearch.relevance.backends.OpenSearchBackend;
import org.opensearch.relevance.events.EventManager;
import org.opensearch.repositories.RepositoriesService;
import org.opensearch.rest.RestController;
import org.opensearch.rest.RestHandler;
Expand All @@ -43,12 +43,12 @@

import static java.util.Collections.singletonList;

public class SearchRelevancePlugin extends Plugin implements ActionPlugin {
public class UserBehaviorLoggingPlugin extends Plugin implements ActionPlugin {

private static final Logger LOGGER = LogManager.getLogger(SearchRelevancePlugin.class);
private static final Logger LOGGER = LogManager.getLogger(UserBehaviorLoggingPlugin.class);

private Backend backend;
private ActionFilter searchRelevanceFilter;
private ActionFilter userBehaviorLoggingFilter;

@Override
public List<RestHandler> getRestHandlers(final Settings settings,
Expand All @@ -59,7 +59,7 @@ public List<RestHandler> getRestHandlers(final Settings settings,
final IndexNameExpressionResolver indexNameExpressionResolver,
final Supplier<DiscoveryNodes> nodesInCluster) {

return singletonList(new SearchRelevanceRestHandler(backend));
return singletonList(new UserBehaviorLoggingRestHandler(backend));

}

Expand All @@ -79,7 +79,7 @@ public List<Setting<?>> getSettings() {
@Override
public List<ActionFilter> getActionFilters() {
// LOGGER.info("Index name: {}", settings.get(ConfigConstants.INDEX_NAME));
return singletonList(searchRelevanceFilter);
return singletonList(userBehaviorLoggingFilter);
}

@Override
Expand All @@ -98,7 +98,7 @@ public Collection<Object> createComponents(
) {

this.backend = new OpenSearchBackend(client);
this.searchRelevanceFilter = new SearchRelevanceSearchFilter(backend, environment.settings());
this.userBehaviorLoggingFilter = new UserBehaviorLoggingSearchFilter(backend, environment.settings());

LOGGER.info("Creating scheduled task");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
* compatible open source license.
*/

package org.opensearch.relevance.action;
package org.opensearch.action;

import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.client.node.NodeClient;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.relevance.backends.Backend;
import org.opensearch.backends.Backend;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.BytesRestResponse;
import org.opensearch.rest.RestRequest;
Expand All @@ -22,13 +22,13 @@

import static org.opensearch.rest.RestRequest.Method.*;

public class SearchRelevanceRestHandler extends BaseRestHandler {
public class UserBehaviorLoggingRestHandler extends BaseRestHandler {

private static final Logger LOGGER = LogManager.getLogger(SearchRelevanceRestHandler.class);
private static final Logger LOGGER = LogManager.getLogger(UserBehaviorLoggingRestHandler.class);

private final Backend backend;

public SearchRelevanceRestHandler(final Backend backend) {
public UserBehaviorLoggingRestHandler(final Backend backend) {
this.backend = backend;
}

Expand All @@ -40,10 +40,10 @@ public String getName() {
@Override
public List<Route> routes() {
return List.of(
new Route(PUT, "/_plugins/search_relevance/{store}"), // Initializes the store.
new Route(DELETE, "/_plugins/search_relevance/{store}"), // Deletes a store.
new Route(GET, "/_plugins/search_relevance"), // Lists all stores
new Route(POST, "/_plugins/search_relevance/{store}")); // Indexes events into the store.
new Route(PUT, "/_plugins/ubl/{store}"), // Initializes the store.
new Route(DELETE, "/_plugins/ubl/{store}"), // Deletes a store.
new Route(GET, "/_plugins/ubl"), // Lists all stores
new Route(POST, "/_plugins/ubl/{store}")); // Indexes events into the store.
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,32 @@
* compatible open source license.
*/

package org.opensearch.relevance.action;
package org.opensearch.action;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.ActionRequest;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.action.support.ActionFilter;
import org.opensearch.action.support.ActionFilterChain;
import org.opensearch.common.settings.Settings;
import org.opensearch.core.action.ActionListener;
import org.opensearch.core.action.ActionResponse;
import org.opensearch.relevance.SettingsConstants;
import org.opensearch.relevance.backends.Backend;
import org.opensearch.relevance.model.QueryRequest;
import org.opensearch.relevance.model.QueryResponse;
import org.opensearch.model.QueryResponse;
import org.opensearch.backends.Backend;
import org.opensearch.model.QueryRequest;
import org.opensearch.tasks.Task;

import java.util.*;

public class SearchRelevanceSearchFilter implements ActionFilter {
public class UserBehaviorLoggingSearchFilter implements ActionFilter {

private static final Logger LOGGER = LogManager.getLogger(SearchRelevanceSearchFilter.class);
private static final Logger LOGGER = LogManager.getLogger(UserBehaviorLoggingSearchFilter.class);

private final Backend backend;
private final Settings settings;

public SearchRelevanceSearchFilter(final Backend backend, final Settings settings) {
public UserBehaviorLoggingSearchFilter(final Backend backend, final Settings settings) {
this.backend = backend;
this.settings = settings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
* compatible open source license.
*/

package org.opensearch.relevance.backends;
package org.opensearch.backends;

import org.opensearch.client.node.NodeClient;
import org.opensearch.relevance.model.QueryRequest;
import org.opensearch.relevance.model.QueryResponse;
import org.opensearch.model.QueryResponse;
import org.opensearch.model.QueryRequest;
import org.opensearch.rest.RestChannel;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.relevance.backends;
package org.opensearch.backends;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -18,10 +18,10 @@
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.io.Streams;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.relevance.SettingsConstants;
import org.opensearch.relevance.events.EventManager;
import org.opensearch.relevance.model.QueryRequest;
import org.opensearch.relevance.model.QueryResponse;
import org.opensearch.events.EventManager;
import org.opensearch.model.QueryResponse;
import org.opensearch.SettingsConstants;
import org.opensearch.model.QueryRequest;
import org.opensearch.rest.RestChannel;
import org.opensearch.rest.action.RestToXContentListener;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
* compatible open source license.
*/

package org.opensearch.relevance.events;
package org.opensearch.events;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.opensearch.action.bulk.BulkRequest;
import org.opensearch.action.index.IndexRequest;
import org.opensearch.client.Client;
import org.opensearch.relevance.events.queues.EventQueue;
import org.opensearch.relevance.events.queues.InternalQueue;

import java.util.TimerTask;
import org.opensearch.events.queues.EventQueue;
import org.opensearch.events.queues.InternalQueue;

public class EventManager {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.relevance.events.queues;
package org.opensearch.events.queues;

import org.opensearch.action.index.IndexRequest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.relevance.events.queues;
package org.opensearch.events.queues;

import org.opensearch.action.index.IndexRequest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.relevance.model;
package org.opensearch.model;

public class QueryRequest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* compatible open source license.
*/

package org.opensearch.relevance.model;
package org.opensearch.model;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dynamic": "strict",
"dynamic": false,
"properties": {
"action_name": { "type" : "keyword" },
"user_id": { "type" : "keyword" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dynamic": "strict",
"dynamic": false,
"properties": {
"query": {
"type": "keyword"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import org.opensearch.test.rest.yaml.ClientYamlTestCandidate;
import org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase;

public class SearchRelevanceClientYamlTestSuiteIT extends OpenSearchClientYamlSuiteTestCase {
public class UserBehaviorLoggingClientYamlTestSuiteIT extends OpenSearchClientYamlSuiteTestCase {

public SearchRelevanceClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
public UserBehaviorLoggingClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"url": {
"paths": [
{
"path": "/_plugins/search_relevance",
"path": "/_plugins/ubl",
"methods": [
"DELETE",
"GET",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
h: component

- match:
$body: /^opensearch-search-relevance\n$/
$body: /^opensearch-ubl\n$/

0 comments on commit 37207bf

Please sign in to comment.