Commit b5fe0896 by Le Ma Committed by Madhan Neethiraj

ATLAS-3580: incorrect results for search on __customAttributes

parent 72389767
...@@ -404,7 +404,7 @@ public abstract class SearchProcessor { ...@@ -404,7 +404,7 @@ public abstract class SearchProcessor {
} }
ret = false; ret = false;
} else if (hasIndexQuerySpecialChar(filterCriteria.getAttributeValue())) { } else if (hasIndexQuerySpecialChar(filterCriteria.getAttributeValue()) && !isPipeSeparatedSystemAttribute(filterCriteria.getAttributeName())) {
if (LOG.isDebugEnabled()) { if (LOG.isDebugEnabled()) {
LOG.debug("special characters found in filter value {}, deferring to in-memory or graph query (might cause poor performance)", filterCriteria.getAttributeValue()); LOG.debug("special characters found in filter value {}, deferring to in-memory or graph query (might cause poor performance)", filterCriteria.getAttributeValue());
} }
......
...@@ -26,6 +26,7 @@ import static org.apache.atlas.TestUtilsV2.PII; ...@@ -26,6 +26,7 @@ import static org.apache.atlas.TestUtilsV2.PII;
import static org.apache.atlas.TestUtilsV2.TABLE_TYPE; import static org.apache.atlas.TestUtilsV2.TABLE_TYPE;
import static org.apache.atlas.model.discovery.SearchParameters.FilterCriteria.Condition.AND; import static org.apache.atlas.model.discovery.SearchParameters.FilterCriteria.Condition.AND;
import static org.apache.atlas.repository.Constants.CLASSIFICATION_NAMES_KEY; import static org.apache.atlas.repository.Constants.CLASSIFICATION_NAMES_KEY;
import static org.apache.atlas.repository.Constants.CUSTOM_ATTRIBUTES_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.MODIFICATION_TIMESTAMP_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.STATE_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.STATE_PROPERTY_KEY;
import static org.apache.atlas.repository.Constants.TIMESTAMP_PROPERTY_KEY; import static org.apache.atlas.repository.Constants.TIMESTAMP_PROPERTY_KEY;
...@@ -154,6 +155,35 @@ public class TestEntitiesREST { ...@@ -154,6 +155,35 @@ public class TestEntitiesREST {
} }
@Test @Test
public void testCustomAttributesSearch() throws Exception {
AtlasEntity dbWithCustomAttr = new AtlasEntity(dbEntity);
HashMap customAttr = new HashMap<String, String>() {{
put("key1", "value1");
}};
dbWithCustomAttr.setCustomAttributes(customAttr);
AtlasEntitiesWithExtInfo atlasEntitiesWithExtInfo = new AtlasEntitiesWithExtInfo(dbWithCustomAttr);
EntityMutationResponse response = entityREST.createOrUpdate(atlasEntitiesWithExtInfo);
Assert.assertNotNull(response.getUpdatedEntitiesByTypeName(DATABASE_TYPE));
searchParameters = new SearchParameters();
searchParameters.setTypeName("_ALL_ENTITY_TYPES");
SearchParameters.FilterCriteria fc = new SearchParameters.FilterCriteria();
fc.setAttributeName(CUSTOM_ATTRIBUTES_PROPERTY_KEY);
fc.setOperator(SearchParameters.Operator.EQ);
fc.setAttributeValue("\"key1:value1\"");
searchParameters.setEntityFilters(fc);
AtlasSearchResult res = discoveryREST.searchWithParameters(searchParameters);
Assert.assertNotNull(res.getEntities());
Assert.assertEquals(res.getEntities().size(), 1);
}
@Test
public void testBasicSearch() throws Exception { public void testBasicSearch() throws Exception {
// search entities with classification named classification // search entities with classification named classification
searchParameters = new SearchParameters(); searchParameters = new SearchParameters();
......
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