Skip to content
Permalink
Browse files
ATLAS-4436: Basic Search : Search By Query '*' gets internal entities…
… also

Signed-off-by: Pinal Shah <pinal.shah@freestoneinfotech.com>
  • Loading branch information
27shraddha92 authored and pinal-shah committed Oct 8, 2021
1 parent 375a6e4 commit a8ecfdf8d735b56f35af9c0e6f47990b91910ba0
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
@@ -24,13 +24,17 @@
import org.apache.atlas.repository.graph.GraphHelper;
import org.apache.atlas.repository.graphdb.*;
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.utils.AtlasPerfTracer;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;


/**
@@ -137,7 +141,12 @@ public List<AtlasVertex> execute() {
if (LOG.isDebugEnabled()) {
LOG.debug("FreeTextSearchProcessor.execute(): ignoring non-entity vertex (id={})", vertex.getId());
}
continue;
}

//skip internalTypes
AtlasEntityType entityType = context.getTypeRegistry().getEntityTypeByName(entityTypeName);
if (entityType != null && entityType.isInternalType()) {
continue;
}

@@ -23,6 +23,7 @@
import org.apache.atlas.repository.graphdb.AtlasIndexQuery;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.utils.AtlasPerfTracer;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
@@ -139,6 +140,13 @@ public List<AtlasVertex> execute() {

continue;
}
//skip internalTypes
String entityTypeName = AtlasGraphUtilsV2.getTypeName(vertex);
AtlasEntityType entityType = context.getTypeRegistry().getEntityTypeByName(entityTypeName);
if (entityType != null && entityType.isInternalType()) {
continue;
}


if (activeOnly && AtlasGraphUtilsV2.getState(vertex) != AtlasEntity.Status.ACTIVE) {
continue;
@@ -26,7 +26,9 @@
import org.apache.atlas.repository.graph.AtlasGraphProvider;
import org.apache.atlas.repository.graphdb.AtlasGraph;
import org.apache.atlas.repository.graphdb.AtlasVertex;
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
import org.apache.atlas.repository.store.graph.v2.EntityGraphRetriever;
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -38,6 +40,9 @@
import java.util.List;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;

@Guice(modules = TestModules.TestOnlyModule.class)
public class FreeTextSearchProcessorTest extends BasicTestSetup {
@@ -132,11 +137,35 @@ public void searchByNonExistingClassification() throws AtlasBaseException {
new FreeTextSearchProcessor(context);
}

@Test(description = "filtering internal types")
public void searchByTextFilteringInternalTypes() throws AtlasBaseException {
SearchParameters params = new SearchParameters();
params.setQuery("*");
params.setExcludeDeletedEntities(true);
params.setLimit(500);
params.setOffset(0);

SearchContext context = new SearchContext(params, typeRegistry, graph, Collections.<String>emptySet());

FreeTextSearchProcessor processor = new FreeTextSearchProcessor(context);

List<AtlasVertex> vertices = processor.execute();

assertNotNull(vertices);

for (AtlasVertex vertex : vertices) {
String entityTypeName = AtlasGraphUtilsV2.getTypeName(vertex);
AtlasEntityType entityType = context.getTypeRegistry().getEntityTypeByName(entityTypeName);

assertFalse(entityType.isInternalType());
assertNotEquals("AtlasGlossaryTerm", entityTypeName);
}
}

@AfterClass
public void teardown() throws Exception {
AtlasGraphProvider.cleanup();

super.cleanup();
}

}

0 comments on commit a8ecfdf

Please sign in to comment.