예제 #1
0
  @Test
  public void singleValuedField_OrderedByNonMetricsOrMultiBucketSubAggregation() throws Exception {

    MockBigArrays.discardNextCheck();
    try {

      client()
          .prepareSearch("idx")
          .setTypes("type")
          .addAggregation(
              terms("terms")
                  .executionHint(randomExecutionHint())
                  .field(SINGLE_VALUED_FIELD_NAME)
                  .order(Terms.Order.aggregation("values", true))
                  .subAggregation(terms("values").field("i")))
          .execute()
          .actionGet();

      fail(
          "Expected search to fail when trying to sort terms aggregation by sug-aggregation which is not of a metrics or single-bucket type");

    } catch (ElasticsearchException e) {
      // expected
    }
  }
예제 #2
0
  @Test
  public void singleValuedField_OrderedByMultiValuedSubAggregation_WithoutMetric()
      throws Exception {

    MockBigArrays.discardNextCheck();
    try {

      client()
          .prepareSearch("idx")
          .setTypes("type")
          .addAggregation(
              terms("terms")
                  .executionHint(randomExecutionHint())
                  .field(SINGLE_VALUED_FIELD_NAME)
                  .order(Terms.Order.aggregation("stats", true))
                  .subAggregation(stats("stats").field("i")))
          .execute()
          .actionGet();

      fail(
          "Expected search to fail when trying to sort terms aggregation by multi-valued sug-aggregation "
              + "where the metric name is not specified");

    } catch (ElasticsearchException e) {
      // expected
    }
  }
예제 #3
0
  @Test
  public void singleValuedField_OrderedByMissingSubAggregation() throws Exception {

    MockBigArrays.discardNextCheck();
    try {

      client()
          .prepareSearch("idx")
          .setTypes("type")
          .addAggregation(
              terms("terms")
                  .executionHint(randomExecutionHint())
                  .field(SINGLE_VALUED_FIELD_NAME)
                  .order(Terms.Order.aggregation("avg_i", true)))
          .execute()
          .actionGet();

      fail(
          "Expected search to fail when trying to sort terms aggregation by sug-aggregation that doesn't exist");

    } catch (ElasticsearchException e) {
      // expected
    }
  }