/** @return a {@link HasChildQueryBuilder} with random values all over the place */ @Override protected HasChildQueryBuilder doCreateTestQueryBuilder() { int min = randomIntBetween(0, Integer.MAX_VALUE / 2); int max = randomIntBetween(min, Integer.MAX_VALUE); InnerHitsBuilder.InnerHit innerHit = new InnerHitsBuilder.InnerHit().setSize(100).addSort(STRING_FIELD_NAME, SortOrder.ASC); return new HasChildQueryBuilder( CHILD_TYPE, RandomQueryBuilder.createQuery(random()), max, min, RandomPicks.randomFrom(random(), ScoreMode.values()), randomBoolean() ? null : new QueryInnerHits("inner_hits_name", innerHit)); }
/** @return a {@link HasChildQueryBuilder} with random values all over the place */ @Override protected NestedQueryBuilder doCreateTestQueryBuilder() { QueryBuilder innerQueryBuilder = RandomQueryBuilder.createQuery(random()); if (randomBoolean()) { requiresRewrite = true; innerQueryBuilder = new WrapperQueryBuilder(innerQueryBuilder.toString()); } NestedQueryBuilder nqb = new NestedQueryBuilder( "nested1", innerQueryBuilder, RandomPicks.randomFrom(random(), ScoreMode.values())); nqb.ignoreUnmapped(randomBoolean()); if (randomBoolean()) { nqb.innerHit( new InnerHitBuilder() .setName(randomAsciiOfLengthBetween(1, 10)) .setSize(randomIntBetween(0, 100)) .addSort(new FieldSortBuilder(INT_FIELD_NAME).order(SortOrder.ASC)), nqb.ignoreUnmapped()); } return nqb; }