Skip to content

Commit

Permalink
feat: ES 7.x client support (#43)
Browse files Browse the repository at this point in the history
* copy code verbatim from old module to the new module

* make changes in build.gradle

* make changes to the new module

* add new module in settings.gradle
  • Loading branch information
jywadhwani authored Nov 11, 2020
1 parent 56fcb75 commit 39a5c92
Show file tree
Hide file tree
Showing 29 changed files with 2,303 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ project.ext.externalDependency = [
'ebeanAgent': 'io.ebean:ebean-agent:11.27.1',
'elasticSearchRest': 'org.elasticsearch.client:elasticsearch-rest-high-level-client:5.6.8',
'elasticSearchTransport': 'org.elasticsearch.client:transport:5.6.8',
'elasticSearchRest7': 'org.elasticsearch.client:elasticsearch-rest-high-level-client:7.9.3',
'elasticSearchTransport7': 'org.elasticsearch.client:transport:7.9.3',
'guava': 'com.google.guava:guava:27.0.1-jre',
'h2': 'com.h2database:h2:1.4.196',
'jacksonCore': 'com.fasterxml.jackson.core:jackson-core:2.9.7',
Expand All @@ -50,6 +52,7 @@ project.ext.externalDependency = [
'junitJupiterEngine': "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion",
'lombok': 'org.projectlombok:lombok:1.18.12',
'mockito': 'org.mockito:mockito-core:3.0.0',
'mockitoInline': 'org.mockito:mockito-inline:3.0.0',
'neo4jHarness': 'org.neo4j.test:neo4j-harness:3.4.11',
'neo4jJavaDriver': 'org.neo4j.driver:neo4j-java-driver:4.0.0',
'parseqTest': 'com.linkedin.parseq:parseq:3.0.7:test',
Expand Down
21 changes: 21 additions & 0 deletions dao-impl/elasticsearch-dao-7/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apply plugin: 'java'

apply from: "$rootDir/gradle/java-publishing.gradle"

dependencies {
compile project(':dao-api')

compile externalDependency.elasticSearchRest7
compile externalDependency.elasticSearchTransport7
compile externalDependency.guava
compile externalDependency.lombok
compile externalDependency.commonsIo
compile externalDependency.commonsLang
compile externalDependency.jacksonCore
compile externalDependency.jacksonDataBind

annotationProcessor externalDependency.lombok

testCompile project(':testing:test-models')
testCompile externalDependency.mockitoInline
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package com.linkedin.metadata.dao.browse;

import com.linkedin.data.schema.RecordDataSchema;
import com.linkedin.data.template.RecordTemplate;
import javax.annotation.Nonnull;


public abstract class BaseBrowseConfig<DOCUMENT extends RecordTemplate> {
private static RecordDataSchema searchDocumentSchema;

@Nonnull
public String getBrowseDepthFieldName() {
return "browsePaths.length";
}

@Nonnull
public String getBrowsePathFieldName() {
return "browsePaths";
}

@Nonnull
public String getUrnFieldName() {
return "urn";
}

@Nonnull
public String getSortingField() {
return "urn";
}

@Nonnull
public String getRemovedField() {
return "removed";
}

public boolean hasFieldInSchema(@Nonnull String fieldName) {
return getSearchDocumentSchema().contains(fieldName);
}

private RecordDataSchema getSearchDocumentSchema() {
if (searchDocumentSchema == null) {
try {
searchDocumentSchema = getSearchDocument().newInstance().schema();
} catch (InstantiationException | IllegalAccessException e) {
throw new RuntimeException("Couldn't create an instance of the search document");
}
}
return searchDocumentSchema;
}

@Nonnull
public String getIndexName() {
return getSearchDocument().getSimpleName().toLowerCase();
}

public abstract Class<DOCUMENT> getSearchDocument();
}
Loading

0 comments on commit 39a5c92

Please sign in to comment.