code: private QueryBuilder nestedQueryBuilder(
        List<Attribute> attributePath, QueryBuilder queryBuilder) {
      if (attributePath.size() == 1) {
        return queryBuilder;
      } else if (attributePath.size() == 2) {
        return QueryBuilders.nestedQuery(
            getQueryFieldName(attributePath.get(0)), queryBuilder, ScoreMode.Avg);
      } else {
        throw new UnsupportedOperationException(CANNOT_FILTER_DEEP_REFERENCE_MSG);
      }
    }
docs: Wraps the query in a nested query when a query is done on a reference entity. Returns the
  original query when it is applied to the current entity.