code: public JSONObject searchRules(RuleQuery query, RequestOptions requestOptions) throws AlgoliaException, JSONException {
      JSONObject body = new JSONObject();
      if (query.getQuery() != null) {
        body = body.put("query", query.getQuery());
      }
      if (query.getAnchoring() != null) {
        body = body.put("anchoring", query.getAnchoring());
      }
      if (query.getContext() != null) {
        body = body.put("context", query.getContext());
      }
      if (query.getPage() != null) {
        body = body.put("page", query.getPage());
      }
      if (query.getHitsPerPage() != null) {
        body = body.put("hitsPerPage", query.getHitsPerPage());
      }
  
      return client.postRequest("/1/indexes/" + encodedIndexName + "/rules/search", body.toString(), false, true, requestOptions);
    }
docs: Search for query rules
  
  @param query          the query
  @param requestOptions Options to pass to this request