Skip to content

Commit

Permalink
Merge branch 'dg-980-public-daap' of github.com:atlanhq/atlas-metasto…
Browse files Browse the repository at this point in the history
…re into dg-980-public-daap
  • Loading branch information
PRATHAM2002-DS committed Apr 1, 2024
2 parents 88361cf + 2799d22 commit ea0da83
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1150,37 +1150,39 @@ private String getIndexName(IndexSearchParams params) throws AtlasBaseException

if (StringUtils.isNotEmpty(aliasName)) {
if(params.isAccessControlExclusive()) {
accessControlExclusiveDsl(params, aliasName);
aliasName = aliasName+","+VERTEX_INDEX_NAME;
accessControlExclusiveDsl(params.getDsl(), aliasName);
}
return aliasName;
} else {
throw new AtlasBaseException("ES alias not found for purpose/persona " + params.getPurpose());
}
}

private void accessControlExclusiveDsl(Map dsl, String aliasName) {
private void accessControlExclusiveDsl(IndexSearchParams params, String aliasName) {

List<Map<String, Object>> mustClauses = new ArrayList<>();
Map<String, Object> clientQuery = (Map<String, Object>) dsl.get("query");
Map<String, Object> clientQuery = (Map<String, Object>) params.getDsl().get("query");

mustClauses.add(clientQuery);

List<Map<String, Object>>filterClauses = new ArrayList<>();
filterClauses.add(getMap("terms", getMap("_index", Collections.singletonList(aliasName))));
Map<String, Object> filterClause = getMap("filter", filterClauses);

Map<String, Object> boolQuery = new HashMap<>();
boolQuery.put("must", mustClauses);
boolQuery.put("filter",filterClause);
boolQuery.put("filter",filterClauses);

List<Map<String, Object>> shouldClauses = new ArrayList<>();
shouldClauses.add(getMap("bool", boolQuery));
shouldClauses.add(getStaticBoolQuery());

Map<String, Object> topBoolQuery = getMap("bool", getMap("should", shouldClauses));

dsl.put("query", topBoolQuery);
Map copyOfDsl = new HashMap(params.getDsl());
copyOfDsl.put("query", topBoolQuery);

params.setDsl(copyOfDsl);
}

private Map<String, Object> getStaticBoolQuery() {
Expand All @@ -1194,11 +1196,9 @@ private Map<String, Object> getStaticBoolQuery() {
List<Map<String, Object>>filterClauses = new ArrayList<>();
filterClauses.add(getMap("terms", getMap("_index", Collections.singletonList(VERTEX_INDEX_NAME))));

Map<String, Object> filterClause = getMap("filter", filterClauses);

Map<String, Object> boolQuery = new HashMap<>();
boolQuery.put("must", mustClauses);
boolQuery.put("filter",filterClause);
boolQuery.put("filter", filterClauses);

return getMap("bool", boolQuery);
}
Expand Down

0 comments on commit ea0da83

Please sign in to comment.