atlas-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From suma...@apache.org
Subject incubator-atlas git commit: ATLAS-1088 Fix /search api to default to fulltext on dsl failure (sumasai)
Date Thu, 04 Aug 2016 01:00:51 GMT
Repository: incubator-atlas
Updated Branches:
  refs/heads/master a165234cd -> dd030ecaa


ATLAS-1088 Fix /search api to default to fulltext on dsl failure (sumasai)


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

Branch: refs/heads/master
Commit: dd030ecaa06e1514d5c80aa816cd206f0bf16d68
Parents: a165234
Author: Suma Shivaprasad <sumasai.shivaprasad@gmail.com>
Authored: Wed Aug 3 18:00:41 2016 -0700
Committer: Suma Shivaprasad <sumasai.shivaprasad@gmail.com>
Committed: Wed Aug 3 18:00:41 2016 -0700

----------------------------------------------------------------------
 release-log.txt                                  |  1 +
 .../web/resources/MetadataDiscoveryResource.java | 16 ++++++++++++++--
 .../MetadataDiscoveryJerseyResourceIT.java       | 19 +++++++++++++++++++
 3 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd030eca/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 6e73a7d..35c1ea8 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -6,6 +6,7 @@ INCOMPATIBLE CHANGES:
 
 
 ALL CHANGES:
+ATLAS-1088 Fix /search api to default to fulltext on dsl failure (sumasai)
 ATLAS-762 Assertion in NegativeSSLAndKerberosTest.testUnsecuredClient needs to be hardened
(nixonrodrigues via sumasai)
 ATLAS-1071 Regression - UI - Details Button under Audits Tab is not working.(kevalbhatt18
via sumasai)
 ATLAS-965 Old lineage still exists after dropping tables and re-creating tables with same
name. (shwethags via sumasai)

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd030eca/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
----------------------------------------------------------------------
diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
index ea87ee1..64344da 100755
--- a/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
+++ b/webapp/src/main/java/org/apache/atlas/web/resources/MetadataDiscoveryResource.java
@@ -93,8 +93,20 @@ public class MetadataDiscoveryResource {
         if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
             perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "MetadataDiscoveryResource.search("
+ query + ", " + limit + ", " + offset + ")");
         }
-        Response response = searchUsingQueryDSL(query, limit, offset);
-        if (response.getStatus() != Response.Status.OK.getStatusCode()) {
+
+        boolean dslQueryFailed = false;
+        Response response = null;
+        try {
+            response = searchUsingQueryDSL(query, limit, offset);
+            if (response.getStatus() != Response.Status.OK.getStatusCode()) {
+                dslQueryFailed = true;
+            }
+        } catch (Exception e) {
+            LOG.debug("Error while running DSL. Switching to fulltext for query {}", query,
e);
+            dslQueryFailed = true;
+        }
+
+        if ( dslQueryFailed ) {
             response = searchUsingFullText(query, limit, offset);
         }
         AtlasPerfTracer.log(perf);

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/dd030eca/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
----------------------------------------------------------------------
diff --git a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
index 067c161..9aff145 100755
--- a/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
+++ b/webapp/src/test/java/org/apache/atlas/web/resources/MetadataDiscoveryJerseyResourceIT.java
@@ -196,6 +196,25 @@ public class MetadataDiscoveryJerseyResourceIT extends BaseResourceIT
{
         assertEquals(response.getString("queryType"), "dsl");
     }
 
+    @Test
+    public void testSearchFullTextOnDSLFailure() throws Exception {
+        String query = "*";
+        WebResource resource = service.path("api/atlas/discovery/search").queryParam("query",
query);
+
+        ClientResponse clientResponse = resource.accept(Servlets.JSON_MEDIA_TYPE).type(Servlets.JSON_MEDIA_TYPE)
+            .method(HttpMethod.GET, ClientResponse.class);
+        assertEquals(clientResponse.getStatus(), Response.Status.OK.getStatusCode());
+
+        String responseAsString = clientResponse.getEntity(String.class);
+        Assert.assertNotNull(responseAsString);
+
+        JSONObject response = new JSONObject(responseAsString);
+        Assert.assertNotNull(response.get(AtlasClient.REQUEST_ID));
+
+        assertEquals(response.getString("query"), query);
+        assertEquals(response.getString("queryType"), "full-text");
+    }
+
     @Test(dependsOnMethods = "testSearchDSLLimits")
     public void testSearchUsingFullText() throws Exception {
         JSONObject response = serviceClient.searchByFullText(tagName, 10, 0);


Mime
View raw message