atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject incubator-atlas git commit: ATLAS-1961: Basic search improvement in use of Solr index for attribute filtering (# 5)
Date Fri, 21 Jul 2017 04:28:26 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master 13ba156f1 -> 62d85a4ca


ATLAS-1961: Basic search improvement in use of Solr index for attribute filtering (# 5)


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

Branch: refs/heads/master
Commit: 62d85a4caebeb8f459c0a1774fade83cd49b9c35
Parents: 13ba156
Author: Madhan Neethiraj <madhan@apache.org>
Authored: Thu Jul 20 15:42:46 2017 -0700
Committer: Madhan Neethiraj <madhan@apache.org>
Committed: Thu Jul 20 21:28:13 2017 -0700

----------------------------------------------------------------------
 .../atlas/discovery/EntitySearchProcessor.java  |  2 --
 .../discovery/FullTextSearchProcessor.java      | 12 ++++------
 .../apache/atlas/discovery/SearchProcessor.java | 23 +++++++++++++-------
 3 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/62d85a4c/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
b/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
index a3525c9..efcfb7f 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntitySearchProcessor.java
@@ -18,10 +18,8 @@
 package org.apache.atlas.discovery;
 
 import org.apache.atlas.model.discovery.SearchParameters.FilterCriteria;
-import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.repository.Constants;
 import org.apache.atlas.repository.graphdb.*;
-import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1;
 import org.apache.atlas.type.AtlasClassificationType;
 import org.apache.atlas.type.AtlasEntityType;
 import org.apache.atlas.utils.AtlasPerfTracer;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/62d85a4c/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java
----------------------------------------------------------------------
diff --git a/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java
b/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java
index 1b19a0e..0d1c39b 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/FullTextSearchProcessor.java
@@ -20,12 +20,10 @@ package org.apache.atlas.discovery;
 import org.apache.atlas.model.discovery.SearchParameters;
 import org.apache.atlas.model.instance.AtlasEntity;
 import org.apache.atlas.repository.Constants;
-import org.apache.atlas.repository.graph.GraphHelper;
 import org.apache.atlas.repository.graphdb.AtlasIndexQuery;
 import org.apache.atlas.repository.graphdb.AtlasVertex;
 import org.apache.atlas.repository.store.graph.v1.AtlasGraphUtilsV1;
 import org.apache.atlas.utils.AtlasPerfTracer;
-import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -55,7 +53,8 @@ public class FullTextSearchProcessor extends SearchProcessor {
             Set<String> typeAndSubTypeNames = context.getEntityType().getTypeAndAllSubTypes();
 
             if (typeAndSubTypeNames.size() <= MAX_ENTITY_TYPES_IN_INDEX_QUERY) {
-                queryString.append(AND_STR).append("(").append(StringUtils.join(typeAndSubTypeNames,
SPACE_STRING)).append(")");
+                queryString.append(AND_STR);
+                appendIndexQueryValue(typeAndSubTypeNames, queryString);
             } else {
                 LOG.warn("'{}' has too many subtypes ({}) to include in index-query; might
cause poor performance",
                          context.getEntityType().getTypeName(), typeAndSubTypeNames.size());
@@ -68,17 +67,14 @@ public class FullTextSearchProcessor extends SearchProcessor {
             Set<String> typeAndSubTypeNames = context.getClassificationType().getTypeAndAllSubTypes();
 
             if (typeAndSubTypeNames.size() <= MAX_CLASSIFICATION_TYPES_IN_INDEX_QUERY)
{
-                queryString.append(AND_STR).append("(").append(StringUtils.join(typeAndSubTypeNames,
SPACE_STRING)).append(")");
+                queryString.append(AND_STR);
+                appendIndexQueryValue(typeAndSubTypeNames, queryString);
             } else {
                 LOG.warn("'{}' has too many subtypes ({}) to include in index-query; might
cause poor performance",
                         context.getClassificationType().getTypeName(), typeAndSubTypeNames.size());
             }
         }
 
-        if (context.getSearchParameters().getExcludeDeletedEntities()) {
-            queryString.append(AND_STR).append("(ACTIVE)");
-        }
-
         queryString.append(")");
 
         indexQuery = context.getGraph().indexQuery(Constants.FULLTEXT_INDEX, queryString.toString());

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/62d85a4c/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 7950127..2862165 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/SearchProcessor.java
@@ -48,12 +48,12 @@ public abstract class SearchProcessor {
     public static final String  AND_STR         = " AND ";
     public static final String  EMPTY_STRING    = "";
     public static final String  SPACE_STRING    = " ";
-    public static final String  BRACE_OPEN_STR  = "( ";
-    public static final String  BRACE_CLOSE_STR = " )";
+    public static final String  BRACE_OPEN_STR  = "(";
+    public static final String  BRACE_CLOSE_STR = ")";
     public static final char    DOUBLE_QUOTE    = '"';
 
     private static final Map<SearchParameters.Operator, String> OPERATOR_MAP = new
HashMap<>();
-    private static final char[] OFFENDING_CHARS = {'@', '/', ' '}; // This can grow as we
discover corner cases
+    private static final char[] OFFENDING_CHARS = { '@', '/', ' ' }; // This can grow as
we discover corner cases
 
     static
     {
@@ -182,16 +182,13 @@ public abstract class SearchProcessor {
     }
 
     protected void constructTypeTestQuery(StringBuilder solrQuery, Set<String> typeAndAllSubTypes)
{
-        String typeAndSubtypesString = StringUtils.join(typeAndAllSubTypes, SPACE_STRING);
-
         if (CollectionUtils.isNotEmpty(typeAndAllSubTypes)) {
             if (solrQuery.length() > 0) {
                 solrQuery.append(AND_STR);
             }
 
-            solrQuery.append("v.\"").append(Constants.TYPE_NAME_PROPERTY_KEY).append("\":
(")
-                    .append(typeAndSubtypesString)
-                    .append(")");
+            solrQuery.append("v.\"").append(Constants.TYPE_NAME_PROPERTY_KEY).append("\":");
+            appendIndexQueryValue(typeAndAllSubTypes, solrQuery);
         }
     }
 
@@ -392,6 +389,16 @@ public abstract class SearchProcessor {
         return ret;
     }
 
+    protected String appendIndexQueryValue(Set<String> values, StringBuilder sb) {
+        sb.append(BRACE_OPEN_STR);
+        for (String value : values) {
+            sb.append(escapeIndexQueryValue(value)).append(SPACE_STRING);
+        }
+        sb.append(BRACE_CLOSE_STR);
+
+        return sb.toString();
+    }
+
     private static int getApplicationProperty(String propertyName, int defaultValue) {
         try {
             return ApplicationProperties.get().getInt(propertyName, defaultValue);


Mime
View raw message