You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2020/01/09 21:20:58 UTC
[atlas] branch branch-2.0 updated: ATLAS-3580: incorrect results
for search on __customAttributes
This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 4cb29b8 ATLAS-3580: incorrect results for search on __customAttributes
4cb29b8 is described below
commit 4cb29b87653ab725ad0466cf37e8305f2d80330a
Author: Le Ma <lm...@cloudera.com>
AuthorDate: Thu Jan 9 12:55:48 2020 -0800
ATLAS-3580: incorrect results for search on __customAttributes
Signed-off-by: Madhan Neethiraj <ma...@apache.org>
(cherry picked from commit b5fe0896d630dbdf5a48452930ad1023f3a0d2cb)
---
.../apache/atlas/discovery/SearchProcessor.java | 2 +-
.../atlas/web/adapters/TestEntitiesREST.java | 30 ++++++++++++++++++++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
index 76d5a01..278b97f 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
@@ -404,7 +404,7 @@ public abstract class SearchProcessor {
}
ret = false;
- } else if (hasIndexQuerySpecialChar(filterCriteria.getAttributeValue())) {
+ } else if (hasIndexQuerySpecialChar(filterCriteria.getAttributeValue()) && !isPipeSeparatedSystemAttribute(filterCriteria.getAttributeName())) {
if (LOG.isDebugEnabled()) {
LOG.debug("special characters found in filter value {}, deferring to in-memory or graph query (might cause poor performance)", filterCriteria.getAttributeValue());
}
diff --git a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
index afc4c50..b2c1d4a 100644
--- a/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
+++ b/webapp/src/test/java/org/apache/atlas/web/adapters/TestEntitiesREST.java
@@ -26,6 +26,7 @@ import static org.apache.atlas.TestUtilsV2.PII;
import static org.apache.atlas.TestUtilsV2.TABLE_TYPE;
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.CUSTOM_ATTRIBUTES_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.TIMESTAMP_PROPERTY_KEY;
@@ -154,6 +155,35 @@ public class TestEntitiesREST {
}
@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 {
// search entities with classification named classification
searchParameters = new SearchParameters();