Skip to content

Commit

Permalink
Remove wrapping user query
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilbonte21 committed Mar 22, 2024
1 parent 1437c84 commit 762f147
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1181,21 +1181,24 @@ private void addPreFiltersToSearchQuery(SearchParams searchParams) {
Map<String, Object> allPreFiltersBoolClause = NewAuthorizerUtils.getPreFilterDsl(persona, purpose, actions);
mustClauseList.add(allPreFiltersBoolClause);

mustClauseList.add((Map<String, Object>) ((IndexSearchParams) searchParams).getDsl().get("query"));

String dslString = searchParams.getQuery();
JsonNode node = mapper.readTree(dslString);
JsonNode userQueryNode = node.get("query");
/*JsonNode userQueryNode = node.get("query");
if (userQueryNode != null) {
String userQueryString = userQueryNode.toString();
String userQueryBase64 = Base64.getEncoder().encodeToString(userQueryString.getBytes());
mustClauseList.add(getMap("wrapper", getMap("query", userQueryBase64)));
}
}*/

JsonNode updateQueryNode = mapper.valueToTree(getMap("bool", getMap("must", mustClauseList)));

((ObjectNode) node).set("query", updateQueryNode);
searchParams.setQuery(node.toString());

RequestContext.get().endMetricRecord(addPreFiltersToSearchQueryMetric);

} catch (Exception e) {
Expand Down

0 comments on commit 762f147

Please sign in to comment.