Skip to content

Commit

Permalink
added from and size controls
Browse files Browse the repository at this point in the history
  • Loading branch information
hitk6 committed Jul 3, 2024
1 parent d2b7d1a commit c596b4c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit c596b4c

Please sign in to comment.