atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject atlas git commit: ATLAS-2117: basic search updates to handle issue caused by tokenization in indexer
Date Thu, 14 Sep 2017 05:35:44 GMT
Repository: atlas
Updated Branches:
  refs/heads/branch-0.8 4c7430ddf -> 3dc90a221


ATLAS-2117: basic search updates to handle issue caused by tokenization in indexer

Signed-off-by: Madhan Neethiraj <madhan@apache.org>
(cherry picked from commit 13fed7a9d746a7f28d6ed6f930b4e6497f9317c1)


Project: http://git-wip-us.apache.org/repos/asf/atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/3dc90a22
Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/3dc90a22
Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/3dc90a22

Branch: refs/heads/branch-0.8
Commit: 3dc90a2213ef3a2eb708dc83d68df2c3e7887c70
Parents: 4c7430d
Author: apoorvnaik <apoorvnaik@apache.org>
Authored: Tue Sep 5 23:02:58 2017 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Wed Sep 13 22:35:17 2017 -0700

----------------------------------------------------------------------
 .../apache/atlas/discovery/SearchProcessor.java | 31 +++++++++++++++-----
 1 file changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/atlas/blob/3dc90a22/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
----------------------------------------------------------------------
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 ddf117f..1cb2249 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
@@ -163,14 +163,12 @@ public abstract class SearchProcessor {
             }
         } else if (StringUtils.isNotEmpty(filterCriteria.getAttributeName())) {
             try {
-                String      attributeName = filterCriteria.getAttributeName();
-                String      qualifiedName = structType.getQualifiedAttributeName(attributeName);
-                Set<String> indexedKeys   = context.getIndexedKeys();
+                String attributeName = filterCriteria.getAttributeName();
 
-                if (indexedKeys != null && indexedKeys.contains(qualifiedName)) {
+                if (isIndexSearchable(filterCriteria, structType)) {
                     indexFiltered.add(attributeName);
                 } else {
-                    LOG.warn("search includes non-indexed attribute '{}'; might cause poor
performance", qualifiedName);
+                    LOG.warn("not using index-search for attribute '{}' - its either non-indexed
or a string attribute used with NEQ operator; might cause poor performance", structType.getQualifiedAttributeName(attributeName));
 
                     graphFiltered.add(attributeName);
                 }
@@ -222,9 +220,7 @@ public abstract class SearchProcessor {
             }
         } else if (StringUtils.isNotEmpty(filterCriteria.getAttributeName())) {
             try {
-                String qualifiedName = structType.getQualifiedAttributeName(filterCriteria.getAttributeName());
-
-                if (insideOrCondition && (indexedKeys == null || !indexedKeys.contains(qualifiedName)))
{
+                if (insideOrCondition && !isIndexSearchable(filterCriteria, structType))
{
                     ret = false;
                 }
             } catch (AtlasBaseException e) {
@@ -326,6 +322,25 @@ public abstract class SearchProcessor {
         indexQuery.append("v.\"").append(Constants.STATE_PROPERTY_KEY).append("\":ACTIVE");
     }
 
+    private boolean isIndexSearchable(FilterCriteria filterCriteria, AtlasStructType structType)
throws AtlasBaseException {
+        String      qualifiedName = structType.getQualifiedAttributeName(filterCriteria.getAttributeName());
+        Set<String> indexedKeys   = context.getIndexedKeys();
+        boolean     ret           = indexedKeys != null && indexedKeys.contains(qualifiedName);
+
+        if (ret) { // index exists
+            // Don't use index query for NEQ on string type attributes - as it might return
fewer entries due to tokenization of vertex property value by indexer
+            if (filterCriteria.getOperator() == SearchParameters.Operator.NEQ) {
+                AtlasType attributeType = structType.getAttributeType(filterCriteria.getAttributeName());
+
+                if (AtlasBaseTypeDef.ATLAS_TYPE_STRING.equals(attributeType.getTypeName()))
{
+                    ret = false;
+                }
+            }
+        }
+
+        return ret;
+    }
+
     private String toIndexQuery(AtlasStructType type, FilterCriteria criteria, Set<String>
indexAttributes, int level) {
         return toIndexQuery(type, criteria, indexAttributes, new StringBuilder(), level);
     }


Mime
View raw message