mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-30 18:17:53 +00:00
* Fix #8991: Index fully qualified table name for search * Fix #8991: Index fully qualified table name for search
This commit is contained in:
parent
125fefcf6d
commit
6393ed03dc
@ -5,6 +5,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import org.openmetadata.schema.entity.data.Table;
|
import org.openmetadata.schema.entity.data.Table;
|
||||||
import org.openmetadata.schema.type.Column;
|
import org.openmetadata.schema.type.Column;
|
||||||
import org.openmetadata.schema.type.TagLabel;
|
import org.openmetadata.schema.type.TagLabel;
|
||||||
@ -49,13 +50,12 @@ public class TableIndex implements ElasticSearchIndex {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tags.addAll(ElasticSearchIndexUtils.parseTags(table.getTags()));
|
tags.addAll(ElasticSearchIndexUtils.parseTags(table.getTags()));
|
||||||
suggest.add(ElasticSearchSuggest.builder().input(table.getFullyQualifiedName()).weight(5).build());
|
parseTableSuggest(suggest);
|
||||||
suggest.add(ElasticSearchSuggest.builder().input(table.getName()).weight(10).build());
|
|
||||||
serviceSuggest.add(ElasticSearchSuggest.builder().input(table.getService().getName()).weight(5).build());
|
serviceSuggest.add(ElasticSearchSuggest.builder().input(table.getService().getName()).weight(5).build());
|
||||||
databaseSuggest.add(ElasticSearchSuggest.builder().input(table.getDatabase().getName()).weight(5).build());
|
databaseSuggest.add(ElasticSearchSuggest.builder().input(table.getDatabase().getName()).weight(5).build());
|
||||||
schemaSuggest.add(ElasticSearchSuggest.builder().input(table.getDatabaseSchema().getName()).weight(5).build());
|
schemaSuggest.add(ElasticSearchSuggest.builder().input(table.getDatabaseSchema().getName()).weight(5).build());
|
||||||
|
|
||||||
ParseTags parseTags = new ParseTags(tags);
|
ParseTags parseTags = new ParseTags(tags);
|
||||||
|
|
||||||
doc.put("displayName", table.getDisplayName() != null ? table.getDisplayName() : table.getName());
|
doc.put("displayName", table.getDisplayName() != null ? table.getDisplayName() : table.getName());
|
||||||
doc.put("tags", parseTags.tags);
|
doc.put("tags", parseTags.tags);
|
||||||
doc.put("tier", parseTags.tierTag);
|
doc.put("tier", parseTags.tierTag);
|
||||||
@ -70,6 +70,20 @@ public class TableIndex implements ElasticSearchIndex {
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void parseTableSuggest(List<ElasticSearchSuggest> suggest) {
|
||||||
|
suggest.add(ElasticSearchSuggest.builder().input(table.getFullyQualifiedName()).weight(5).build());
|
||||||
|
suggest.add(ElasticSearchSuggest.builder().input(table.getName()).weight(10).build());
|
||||||
|
// Table FQN has 4 parts
|
||||||
|
String[] fqnPartsWithoutService = table.getFullyQualifiedName().split(Pattern.quote(Entity.SEPARATOR), 2);
|
||||||
|
if (fqnPartsWithoutService.length == 2) {
|
||||||
|
suggest.add(ElasticSearchSuggest.builder().input(fqnPartsWithoutService[1]).weight(5).build());
|
||||||
|
String[] fqnPartsWithoutDB = fqnPartsWithoutService[1].split(Pattern.quote(Entity.SEPARATOR), 2);
|
||||||
|
if (fqnPartsWithoutDB.length == 2) {
|
||||||
|
suggest.add(ElasticSearchSuggest.builder().input(fqnPartsWithoutDB[1]).weight(5).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void parseColumns(List<Column> columns, List<FlattenColumn> flattenColumns, String parentColumn) {
|
private void parseColumns(List<Column> columns, List<FlattenColumn> flattenColumns, String parentColumn) {
|
||||||
Optional<String> optParentColumn = Optional.ofNullable(parentColumn).filter(Predicate.not(String::isEmpty));
|
Optional<String> optParentColumn = Optional.ofNullable(parentColumn).filter(Predicate.not(String::isEmpty));
|
||||||
List<TagLabel> tags = new ArrayList<>();
|
List<TagLabel> tags = new ArrayList<>();
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import org.slf4j.MarkerFactory;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class AuditEventHandler implements EventHandler {
|
public class AuditEventHandler implements EventHandler {
|
||||||
private final Marker auditMarker = MarkerFactory.getMarker("AUDIT");
|
private final Marker auditMarker = MarkerFactory.getMarker("AUDIT");
|
||||||
|
private final String ANONYMOUS_USER = "anonymous";
|
||||||
|
|
||||||
public void init(OpenMetadataApplicationConfig config, Jdbi jdbi) {
|
public void init(OpenMetadataApplicationConfig config, Jdbi jdbi) {
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
@ -37,7 +38,10 @@ public class AuditEventHandler implements EventHandler {
|
|||||||
String method = requestContext.getMethod();
|
String method = requestContext.getMethod();
|
||||||
if (responseContext.getEntity() != null) {
|
if (responseContext.getEntity() != null) {
|
||||||
String path = requestContext.getUriInfo().getPath();
|
String path = requestContext.getUriInfo().getPath();
|
||||||
String username = requestContext.getSecurityContext().getUserPrincipal().getName();
|
String username = ANONYMOUS_USER;
|
||||||
|
if (requestContext.getSecurityContext().getUserPrincipal() != null) {
|
||||||
|
username = requestContext.getSecurityContext().getUserPrincipal().getName();
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
EntityReference entityReference = ((EntityInterface) responseContext.getEntity()).getEntityReference();
|
EntityReference entityReference = ((EntityInterface) responseContext.getEntity()).getEntityReference();
|
||||||
AuditLog auditLog =
|
AuditLog auditLog =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user