diff --git a/intg/src/main/java/org/apache/atlas/model/discovery/IndexSearchParams.java b/intg/src/main/java/org/apache/atlas/model/discovery/IndexSearchParams.java index 8d8cc08247..63a8693472 100644 --- a/intg/src/main/java/org/apache/atlas/model/discovery/IndexSearchParams.java +++ b/intg/src/main/java/org/apache/atlas/model/discovery/IndexSearchParams.java @@ -18,7 +18,6 @@ public class IndexSearchParams extends SearchParams { private String purpose; private String persona; private String queryString; - /* * Indexsearch includes all relations (if requested with param attributes) even if relationshipStatus is DELETED * Changing this behaviour to exclude related attributes which has relationshipStatus as DELETED @@ -43,6 +42,20 @@ public void setDsl(Map dsl) { queryString = AtlasType.toJson(dsl); } + public Integer getFrom() { + if (dsl != null && dsl.containsKey("from")) { + return (Integer) dsl.get("from"); + } + return null; + } + + public Integer getSize() { + if (dsl != null && dsl.containsKey("size")) { + return (Integer) dsl.get("size"); + } + return null; + } + public boolean isAllowDeletedRelations() { return allowDeletedRelations; } diff --git a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java index 590e3cb0bf..797213d6c4 100644 --- a/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java +++ b/webapp/src/main/java/org/apache/atlas/web/rest/DiscoveryREST.java @@ -408,6 +408,14 @@ public AtlasSearchResult indexSearch(@Context HttpServletRequest servletRequest, throw abe; } + if (parameters.getFrom() > 10000) { + throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Invalid search query: 'from' parameter is more than 10000, Use search_after parameter for pagination."); + } + + if (parameters.getSize() > 20) { + throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "Invalid search query: 'size' parameter is more than 20, 'size' parameter can only be less than equal to 20"); + } + if(LOG.isDebugEnabled()){ LOG.debug("Performing indexsearch for the params ({})", parameters); }