public List<String> searchTags(@Nullable String textQuery, int page, int size) {
    int maxPageSize = 100;
    int maxPage = 20;
    checkArgument(size <= maxPageSize, "Page size must be lower than or equals to " + maxPageSize);
    checkArgument(page > 0 && page <= maxPage, "Page must be between 0 and " + maxPage);

    if (size <= 0) {
      return emptyList();
    }

    TermsAggregationBuilder tagFacet = AggregationBuilders.terms(FIELD_TAGS)
      .field(FIELD_TAGS)
      .size(size * page)
      .minDocCount(1)
      .order(BucketOrder.key(true));
    if (textQuery != null) {
      tagFacet.includeExclude(new IncludeExclude(".*" + escapeSpecialRegexChars(textQuery) + ".*", null));
    }

    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder()
      .query(authorizationTypeSupport.createQueryFilter())
      .fetchSource(false)
      .aggregation(tagFacet);

    SearchResponse response = client.search(EsClient.prepareSearch(TYPE_PROJECT_MEASURES.getMainType())
      .source(searchSourceBuilder));

    Terms aggregation = response.getAggregations().get(FIELD_TAGS);

    return aggregation.getBuckets().stream()
      .skip((page - 1) * size)
      .map(Bucket::getKeyAsString)
      .toList();
  }
@Test
  public void search_tags_only_of_authorized_projects() {
    indexForUser(USER1,
      newDoc(PROJECT1).setTags(singletonList("finance")),
      newDoc(PROJECT2).setTags(singletonList("marketing")));
    indexForUser(USER2,
      newDoc(PROJECT3).setTags(singletonList("offshore")));

    userSession.logIn(USER1);

    List<String> result = underTest.searchTags(null, 1, 10);

    assertThat(result).containsOnly("finance", "marketing");
  }