public static QueryBuilder createQuery(ComponentTextSearchQuery query, ComponentTextSearchFeature... features) {
    checkArgument(features.length > 0, "features cannot be empty");
    BoolQueryBuilder esQuery = boolQuery().must(
      createQuery(query, features, UseCase.GENERATE_RESULTS)
        .orElseThrow(() -> new IllegalStateException("No text search features found to generate search results. Features: " + Arrays.toString(features))));
    createQuery(query, features, UseCase.CHANGE_ORDER_OF_RESULTS)
      .ifPresent(esQuery::should);
    return esQuery;
  }
@Test
  public void create_query() {
    QueryBuilder result = createQuery(ComponentTextSearchQuery.builder()
      .setQueryText("SonarQube").setFieldKey("key").setFieldName("name").build(),
      ComponentTextSearchFeatureRepertoire.KEY);

    assertJson(result.toString()).isSimilarTo("{" +
      "  \"bool\" : {" +
      "    \"must\" : [{" +
      "      \"bool\" : {" +
      "        \"should\" : [{" +
      "          \"match\" : {" +
      "            \"key.sortable_analyzer\" : {" +
      "              \"query\" : \"SonarQube\"," +
      "              \"boost\" : 50.0\n" +
      "            }" +
      "          }" +
      "        }]" +
      "      }" +
      "    }]" +
      "  }" +
      "}");
  }