You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by pi...@apache.org on 2021/04/22 16:00:25 UTC

[atlas] branch master updated (2e0caef -> d7382ea)

This is an automated email from the ASF dual-hosted git repository.

pinal pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git.


    from 2e0caef  ATLAS-4250 : Support HA for admin/tasks API.
     new f6ec21d  ATLAS-4238 : Quick Search: handle special characters to get correct results
     new d7382ea  ATLAS-4238:UI:Quick Search: handle special characters to get correct results

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 dashboardv2/public/js/views/site/Header.js         |  4 +-
 .../js/views/search/GlobalSearchLayoutView.js      |  4 +-
 .../atlas/discovery/EntityDiscoveryService.java    |  7 +++
 .../atlas/discovery/AtlasDiscoveryServiceTest.java | 61 +++++++++++++++++++++-
 4 files changed, 70 insertions(+), 6 deletions(-)

[atlas] 01/02: ATLAS-4238 : Quick Search: handle special characters to get correct results

Posted by pi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pinal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit f6ec21dfb85401b775d82e2727b7d94ddb637f34
Author: Pinal <pinal-shah>
AuthorDate: Wed Apr 7 21:37:43 2021 +0530

    ATLAS-4238 : Quick Search: handle special characters to get correct results
    
    Signed-off-by: Pinal <pinal-shah>
---
 .../atlas/discovery/EntityDiscoveryService.java    |  7 +++
 .../atlas/discovery/AtlasDiscoveryServiceTest.java | 61 +++++++++++++++++++++-
 2 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
index 4ae2d12..a3ab6e3 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
@@ -62,6 +62,7 @@ import org.apache.atlas.type.AtlasEntityType;
 import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
 import org.apache.atlas.type.AtlasType;
 import org.apache.atlas.type.AtlasTypeRegistry;
+import org.apache.atlas.type.AtlasStructType;
 import org.apache.atlas.util.AtlasGremlinQueryProvider;
 import org.apache.atlas.util.AtlasGremlinQueryProvider.AtlasGremlinQuery;
 import org.apache.atlas.util.SearchPredicateUtil;
@@ -405,6 +406,12 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
     @Override
     @GraphTransaction
     public AtlasQuickSearchResult quickSearch(QuickSearchParameters quickSearchParameters) throws AtlasBaseException {
+        String query = quickSearchParameters.getQuery();
+        if (StringUtils.isNotEmpty(query) && !AtlasStructType.AtlasAttribute.hastokenizeChar(query)) {
+                query = query + "*";
+        }
+        quickSearchParameters.setQuery(query);
+        
         SearchContext searchContext = new SearchContext(createSearchParameters(quickSearchParameters),
                                                         typeRegistry,
                                                         graph,
diff --git a/repository/src/test/java/org/apache/atlas/discovery/AtlasDiscoveryServiceTest.java b/repository/src/test/java/org/apache/atlas/discovery/AtlasDiscoveryServiceTest.java
index c277806..f55577c 100644
--- a/repository/src/test/java/org/apache/atlas/discovery/AtlasDiscoveryServiceTest.java
+++ b/repository/src/test/java/org/apache/atlas/discovery/AtlasDiscoveryServiceTest.java
@@ -22,7 +22,9 @@ import org.apache.atlas.AtlasClient;
 import org.apache.atlas.BasicTestSetup;
 import org.apache.atlas.TestModules;
 import org.apache.atlas.exception.AtlasBaseException;
+import org.apache.atlas.model.discovery.AtlasQuickSearchResult;
 import org.apache.atlas.model.discovery.AtlasSearchResult;
+import org.apache.atlas.model.discovery.QuickSearchParameters;
 import org.apache.atlas.model.discovery.SearchParameters;
 import org.apache.atlas.model.instance.AtlasClassification;
 import org.apache.atlas.model.instance.AtlasEntity;
@@ -351,6 +353,7 @@ public class AtlasDiscoveryServiceTest extends BasicTestSetup {
     String spChar18  = "/warehouse/tablespace/external/hive/name/hortonia_bank";
     String spChar19  = "/warehouse/tablespace/external/hive/name/exis_bank";
 
+    String spChar20  = "search_name_with nameblank@namecluster";
 
     @DataProvider(name = "specialCharSearchContains")
     private Object[][] specialCharSearchContains() {
@@ -575,10 +578,53 @@ public class AtlasDiscoveryServiceTest extends BasicTestSetup {
         };
     }
 
+    @DataProvider(name = "specialCharQuickSearch")
+    private Object[][] specialCharQuickSearch() {
+        return new Object[][]{
+                {"default.test_dot_name", 3},
+                {"default.test_dot_name*", 3},
+                {"test_dot_name", 0},
+                {"*test_dot_name", 2},
+                {"*test_dot_name*", 4},
+                {"default.test_dot_name\\*", 0},
+
+                {"default.test_dot_qf", 3},
+                {"default.test_dot_qf*", 3},
+                {"test_dot_qf", 1},
+                {"*test_dot_qf", 3},
+                {"*test_dot_qf*", 4},
+                {"default.test_dot_qf\\*", 2},
+
+                {"default.test_dot_name_12.col1", 1},
+                {"default.test_dot_name_12.col1*", 1},
+                {"default.test_dot_name_12.col", 0},
+                {"default.test_dot_name_12.col*", 1},
+                {"default.test_dot_qf_12.col1", 1},
+                {"default.test_dot_qf_12.col1*", 0},
+
+                {"default.test_dot_name_12*", 1},
+                {"default.test_dot_qf_12*", 1},
+
+                //space gets tokenized, hence whenever user searches for 'STRING' type attribute, space needs to be escaped
+                {"search_name_with nameblank@namecluster", 0},
+                //{"search_name_with nameblank@name", 0}, commenting as there are some entities created from other class with same name
+                {"search_name_with nameblank*", 0},
+                {"search_name_with\\ nameblank@namecluster", 1},
+                {"search_name_with\\ nameblank*", 1},
+
+                //if we escape it will consider as single string, hence * will act as character not as wildcard
+                {"search_qf_with\\ qfblank*", 0},
+                {"search_qf_with\\ qfblank@qfcluster", 1},
+                {"search_qf_with qfblank@qfcluster", 1},
+                {"search_qf_with qfblank@q", 1},
+                {"search_qf_with qfblank*", 1},
+        };
+    }
+
 
     public void createSpecialCharTestEntities() throws AtlasBaseException {
 
-        List<String> nameList = Arrays.asList(spChar1,spChar2,spChar3,spChar4,spChar5,spChar6,spChar7,spChar8,spChar9,spChar10,spChar11,spChar12,spChar13,spChar14,spChar15,spChar16,spChar17,spChar18,spChar19);
+        List<String> nameList = Arrays.asList(spChar1,spChar2,spChar3,spChar4,spChar5,spChar6,spChar7,spChar8,spChar9,spChar10,spChar11,spChar12,spChar13,spChar14,spChar15,spChar16,spChar17,spChar18,spChar19,spChar20);
         for (String nameStr : nameList) {
             AtlasEntity entityToDelete = new AtlasEntity(HIVE_TABLE_TYPE);
             entityToDelete.setAttribute("name", nameStr);
@@ -647,7 +693,18 @@ public class AtlasDiscoveryServiceTest extends BasicTestSetup {
         params.setLimit(20);
 
         AtlasSearchResult searchResult = discoveryService.searchWithParameters(params);
-        assertSearchResult(searchResult,expected, attrValue);
+        assertSearchResult(searchResult, expected, attrValue);
+    }
+
+    @Test(dataProvider = "specialCharQuickSearch")
+    public void specialCharQuickSearch(String searchValue, int expected) throws AtlasBaseException {
+        QuickSearchParameters params = new QuickSearchParameters();
+        params.setQuery(searchValue);
+        params.setLimit(5);
+        params.setOffset(0);
+
+        AtlasQuickSearchResult searchResult = discoveryService.quickSearch(params);
+        assertSearchResult(searchResult.getSearchResults(), expected, searchValue);
     }
 
     private void assertSearchResult(AtlasSearchResult searchResult, int expected, String query) {

[atlas] 02/02: ATLAS-4238:UI:Quick Search: handle special characters to get correct results

Posted by pi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

pinal pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit d7382ea61569ed8d5492bea53f41b3c038b9b654
Author: prasad pawar <pr...@freestoneinfotech.com>
AuthorDate: Thu Apr 8 11:16:53 2021 +0530

    ATLAS-4238:UI:Quick Search: handle special characters to get correct results
    
    Signed-off-by: Pinal <pinal-shah>
---
 dashboardv2/public/js/views/site/Header.js                   | 4 ++--
 dashboardv3/public/js/views/search/GlobalSearchLayoutView.js | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/dashboardv2/public/js/views/site/Header.js b/dashboardv2/public/js/views/site/Header.js
index a40f547..bc2f07b 100644
--- a/dashboardv2/public/js/views/site/Header.js
+++ b/dashboardv2/public/js/views/site/Header.js
@@ -149,7 +149,7 @@ define(['require',
                 url: UrlLinks.searchApiUrl('quick'),
                 contentType: 'application/json',
                 data: {
-                    "query": this.getSearchString(term),
+                    "query": term,
                     "limit": 5,
                     "offset": 0
                 },
@@ -233,7 +233,7 @@ define(['require',
                     that.ui.clearGlobalSearch.addClass("in");
                     if (event.keyCode == 13) {
                         if ($(this).data("valSelected") !== true) {
-                            that.triggerBuasicSearch(that.getSearchString($(this).val()));
+                            that.triggerBuasicSearch($(this).val());
                         } else {
                             $(this).data("valSelected", false);
                         }
diff --git a/dashboardv3/public/js/views/search/GlobalSearchLayoutView.js b/dashboardv3/public/js/views/search/GlobalSearchLayoutView.js
index 88dd418..6922181 100644
--- a/dashboardv3/public/js/views/search/GlobalSearchLayoutView.js
+++ b/dashboardv3/public/js/views/search/GlobalSearchLayoutView.js
@@ -121,7 +121,7 @@ define(["require",
                     url: UrlLinks.searchApiUrl("quick"),
                     contentType: "application/json",
                     data: {
-                        query: this.getSearchString(term),
+                        query: term,
                         limit: 5,
                         offset: 0
                     },
@@ -260,7 +260,7 @@ define(["require",
                             if (event.keyCode == 13) {
                                 if ($(this).data("valSelected") !== true) {
                                     that.closeSearch();
-                                    that.triggerBasicSearch(that.getSearchString($(this).val()));
+                                    that.triggerBasicSearch($(this).val());
                                 } else {
                                     $(this).data("valSelected", false);
                                 }