Commit d7ce0a53 by apoorvnaik Committed by Madhan Neethiraj

ATLAS-1956: AtlasSearchResult should include attributes present in filter criteria

parent abc4856e
...@@ -420,6 +420,10 @@ public class EntityDiscoveryService implements AtlasDiscoveryService { ...@@ -420,6 +420,10 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
resultAttributes.addAll(searchParameters.getAttributes()); resultAttributes.addAll(searchParameters.getAttributes());
} }
if (CollectionUtils.isNotEmpty(context.getEntityAttributes())) {
resultAttributes.addAll(context.getEntityAttributes());
}
for (String resultAttribute : resultAttributes) { for (String resultAttribute : resultAttributes) {
AtlasAttribute attribute = context.getEntityType().getAttribute(resultAttribute); AtlasAttribute attribute = context.getEntityType().getAttribute(resultAttribute);
......
...@@ -27,6 +27,7 @@ import org.apache.atlas.type.AtlasTypeRegistry; ...@@ -27,6 +27,7 @@ import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
...@@ -35,6 +36,7 @@ public class SearchContext { ...@@ -35,6 +36,7 @@ public class SearchContext {
private final AtlasTypeRegistry typeRegistry; private final AtlasTypeRegistry typeRegistry;
private final AtlasGraph graph; private final AtlasGraph graph;
private final Set<String> indexedKeys; private final Set<String> indexedKeys;
private final Set<String> entityAttributes;
private final AtlasEntityType entityType; private final AtlasEntityType entityType;
private final AtlasClassificationType classificationType; private final AtlasClassificationType classificationType;
private SearchProcessor searchProcessor; private SearchProcessor searchProcessor;
...@@ -45,6 +47,7 @@ public class SearchContext { ...@@ -45,6 +47,7 @@ public class SearchContext {
this.typeRegistry = typeRegistry; this.typeRegistry = typeRegistry;
this.graph = graph; this.graph = graph;
this.indexedKeys = indexedKeys; this.indexedKeys = indexedKeys;
this.entityAttributes = new HashSet<>();
this.entityType = typeRegistry.getEntityTypeByName(searchParameters.getTypeName()); this.entityType = typeRegistry.getEntityTypeByName(searchParameters.getTypeName());
this.classificationType = typeRegistry.getClassificationTypeByName(searchParameters.getClassification()); this.classificationType = typeRegistry.getClassificationTypeByName(searchParameters.getClassification());
...@@ -70,6 +73,8 @@ public class SearchContext { ...@@ -70,6 +73,8 @@ public class SearchContext {
public Set<String> getIndexedKeys() { return indexedKeys; } public Set<String> getIndexedKeys() { return indexedKeys; }
public Set<String> getEntityAttributes() { return entityAttributes; }
public AtlasEntityType getEntityType() { return entityType; } public AtlasEntityType getEntityType() { return entityType; }
public AtlasClassificationType getClassificationType() { return classificationType; } public AtlasClassificationType getClassificationType() { return classificationType; }
......
...@@ -118,6 +118,11 @@ public abstract class SearchProcessor { ...@@ -118,6 +118,11 @@ public abstract class SearchProcessor {
gremlinFiltered.add(attributeName); gremlinFiltered.add(attributeName);
} }
if (structType instanceof AtlasEntityType) {
// Capture the entity attributes
context.getEntityAttributes().add(attributeName);
}
allAttributes.add(attributeName); allAttributes.add(attributeName);
} catch (AtlasBaseException e) { } catch (AtlasBaseException e) {
LOG.warn(e.getMessage()); LOG.warn(e.getMessage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment