---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
- do:
    indices.create:
      index: "index_1"
      body:
        settings:
          number_of_shards: 1
        mappings:
          properties:
            created_at:
              type: "date"
              format: "yyyy-MM-dd"
            created_at_not_indexed:
              type: "date"
              index: false
              format: "yyyy-MM-dd"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.create:
      index: "index_2"
      body:
        settings:
          number_of_shards: 1
        mappings:
          properties:
            created_at:
              type: "date_nanos"
              format: "yyyy-MM-dd"
            created_at_not_indexed:
              type: "date"
              index: false
              format: "yyyy-MM-dd"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.create:
      index: "index_3"
      body:
        settings:
          number_of_shards: 1
        mappings:
          properties:
            created_at:
              type: "date"
              format: "yyyy-MM-dd"
            created_at_not_indexed:
              type: "date"
              index: false
              format: "yyyy-MM-dd"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
pre_filter_shard_size with invalid parameter:
- do:
    catch: "/preFilterShardSize must be >= 1/"
    search:
      rest_total_hits_as_int: true
      index: "test_1"
      pre_filter_shard_size: 0
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
---
pre_filter_shard_size with shards that have no hit:
- skip:
    awaits_fix: "https://github.com/elastic/elasticsearch/issues/92058"
- do:
    index:
      index: "index_1"
      id: "1"
      body:
        created_at: "2016-01-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    index:
      index: "index_2"
      id: "2"
      body:
        created_at: "2017-01-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    index:
      index: "index_3"
      id: "3"
      body:
        created_at: "2018-01-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.refresh: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    search:
      rest_total_hits_as_int: true
      body:
        size: 0
        query:
          range:
            created_at:
              gte: "2016-02-01"
              lt: "2018-02-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total: 2
- do:
    search:
      rest_total_hits_as_int: true
      pre_filter_shard_size: 1
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total: 3
- do:
    search:
      rest_total_hits_as_int: true
      pre_filter_shard_size: 1
      body:
        size: 0
        query:
          range:
            created_at:
              gte: "2016-02-01"
              lt: "2018-02-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 1
- match:
    _shards.failed: 0
- match:
    hits.total: 2
- do:
    search:
      rest_total_hits_as_int: true
      pre_filter_shard_size: 1
      body:
        size: 0
        query:
          range:
            created_at:
              gte: "2019-02-01"
              lt: "2020-02-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 2
- match:
    _shards.failed: 0
- match:
    hits.total: 0
- do:
    search:
      rest_total_hits_as_int: true
      pre_filter_shard_size: 1
      body:
        size: 0
        query:
          range:
            created_at:
              gte: "2016-02-01"
              lt: "2018-02-01"
        aggs:
          some_agg:
            global: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total: 2
- match:
    aggregations.some_agg.doc_count: 3
- do:
    search:
      rest_total_hits_as_int: true
      pre_filter_shard_size: 1
      body:
        size: 0
        query:
          range:
            created_at:
              gte: "2016-02-01"
              lt: "2018-02-01"
        aggs:
          idx_terms:
            terms:
              field: "_index"
              min_doc_count: 0
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total: 2
- length:
    aggregations.idx_terms.buckets: 3
- do:
    search:
      rest_total_hits_as_int: true
      pre_filter_shard_size: 1
      body:
        size: 0
        query:
          range:
            created_at:
              gte: "2016-02-01"
              lt: "2018-02-01"
        aggs:
          idx_terms:
            terms:
              field: "_index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 1
- match:
    _shards.failed: 0
- match:
    hits.total: 2
- length:
    aggregations.idx_terms.buckets: 2
- do:
    search:
      max_concurrent_shard_requests: 1
      body:
        size: 0
        query:
          range:
            created_at:
              gte: "2016-02-01"
              lt: "2018-02-01"
        aggs:
          idx_terms:
            terms:
              field: "_index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total.value: 2
- length:
    aggregations.idx_terms.buckets: 2
- do:
    search:
      max_concurrent_shard_requests: 2
      body:
        size: 0
        query:
          range:
            created_at:
              gte: "2019-02-01"
        aggs:
          idx_terms:
            terms:
              field: "_index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total.value: 0
- length:
    aggregations.idx_terms.buckets: 0
- do:
    search:
      max_concurrent_shard_requests: 1
      pre_filter_shard_size: 1
      body:
        size: 1
        track_total_hits: 1
        sort:
        - created_at:
            order: "desc"
            numeric_type: "date"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total.value: 1
- match:
    hits.total.relation: "gte"
- length:
    hits.hits: 1
- match:
    hits.hits.0._id: "3"
- do:
    search:
      max_concurrent_shard_requests: 1
      pre_filter_shard_size: 1
      body:
        size: 1
        track_total_hits: 1
        sort:
        - created_at:
            order: "desc"
            numeric_type: "date"
        aggs:
          idx_terms:
            terms:
              field: "_index"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total.value: 1
- match:
    hits.total.relation: "gte"
- length:
    hits.hits: 1
- match:
    hits.hits.0._id: "3"
- length:
    aggregations.idx_terms.buckets: 3
---
prefilter on non-indexed date fields:
- skip:
    awaits_fix: "prefiltering can now use skippers on dv-only fields"
- requires:
    cluster_features: "gte_v8.1.0"
    reason: "doc values search was added in 8.1.0"
- do:
    index:
      index: "index_1"
      id: "1"
      body:
        created_at_not_indexed: "2016-01-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    index:
      index: "index_2"
      id: "2"
      body:
        created_at_not_indexed: "2017-01-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    index:
      index: "index_3"
      id: "3"
      body:
        created_at_not_indexed: "2018-01-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    indices.refresh: {}
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- do:
    search:
      rest_total_hits_as_int: true
      body:
        size: 0
        query:
          range:
            created_at_not_indexed:
              gte: "2016-02-01"
              lt: "2018-02-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total: 2
- do:
    search:
      rest_total_hits_as_int: true
      pre_filter_shard_size: 1
      body:
        size: 0
        query:
          range:
            created_at_not_indexed:
              gte: "2016-02-01"
              lt: "2018-02-01"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - "Use of the \\[max_size\\] rollover condition has been deprecated in favour\
      \ of the \\[max_primary_shard_size\\] condition and will be removed in a later\
      \ version"
    - "Parameter \\[confidence_interval\\] in \\[index_options\\] for dense_vector\
      \ field \\[[^\\]]+\\] is deprecated and will be removed in a future version"
- match:
    _shards.total: 3
- match:
    _shards.successful: 3
- match:
    _shards.skipped: 0
- match:
    _shards.failed: 0
- match:
    hits.total: 2
