Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

17.3 KB
Raw Blame
setup:
  - requires:
      cluster_features: ["gte_v7.2.0"]
      reason:  These new error messages were added in 7.2

  - do:
      indices.create:
          index: test_1
          body:
            mappings:
              properties:
                int_field:
                   type : integer

  - do:
       bulk:
         refresh: true
         body:
           - index:
               _index: test_1
               _id:    "1"
           - int_field: 1
           - index:
               _index: test_1
               _id:    "2"
           - int_field: 2
           - index:
               _index: test_1
               _id:    "3"
           - int_field: 3
           - index:
               _index: test_1
               _id:    "4"
           - int_field: 4

---
"Max pipeline through terms agg":

  - do:
      catch: /\[Object\[\]\] at aggregation \[the_terms_2\]/
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            the_terms:
              terms:
                field: "int_field"
              aggs:
                the_terms_2:
                  terms:
                    field: "int_field"
                  aggs:
                    the_max:
                      max:
                        field: "int_field"
            the_bad_max:
              max_bucket:
                buckets_path: "the_terms>the_terms_2>the_max"

---
"Max pipeline on terms agg":

  - do:
      catch: /\[LongTerms\] at aggregation \[the_terms_2\]/
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            the_terms:
              terms:
                field: "int_field"
              aggs:
                the_terms_2:
                  terms:
                    field: "int_field"
            the_bad_max:
              max_bucket:
                buckets_path: "the_terms>the_terms_2"

---
"Max pipeline on percentiles tdigest agg without specifying percent":

  - do:
      catch: /buckets_path must reference either a number value or a single value numeric metric aggregation, but \[the_percentiles\] contains multiple values. Please specify which to use\./
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            the_terms:
              terms:
                field: "int_field"
              aggs:
                the_percentiles:
                  percentiles:
                    percents: [10, 50, 90, 99]
                    field: "int_field"
            the_bad_max:
              max_bucket:
                buckets_path: "the_terms>the_percentiles"

---
"Max pipeline on percentiles tdigest agg with single percent metric value":
  - requires:
      cluster_features: ["gte_v8.4.0"]
      reason: behaviour changed in 8.4.0
      test_runner_features: close_to

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          size: 0
          aggs:
            the_terms:
              terms:
                field: "int_field"
              aggs:
                the_percentiles:
                  percentiles:
                    field: "int_field"
                    keyed: false
                    percents: [99]
            the_max:
              max_bucket:
                buckets_path: "the_terms>the_percentiles"

  - match: { hits.total: 4 }
  - length: { aggregations.the_terms.buckets: 4 }

  - match: { aggregations.the_terms.buckets.0.key: 1 }
  - match: { aggregations.the_terms.buckets.0.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.0.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.0.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.0.the_percentiles.values.0.value: { value: 1.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.1.key: 2 }
  - match: { aggregations.the_terms.buckets.1.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.1.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.1.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.1.the_percentiles.values.0.value: { value: 2.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.2.key: 3 }
  - match: { aggregations.the_terms.buckets.2.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.2.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.2.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.2.the_percentiles.values.0.value: { value: 3.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.3.key: 4 }
  - match: { aggregations.the_terms.buckets.3.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.3.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.3.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.3.the_percentiles.values.0.value: { value: 4.000000, error: 0.000001 } }

  - close_to: { aggregations.the_max.value: { value: 4.000000, error: 0.000001 } }
  - length: { aggregations.the_max.keys: 1 }
  - match: { aggregations.the_max.keys.0: "4" }


---
"Max pipeline on percentiles tdigest agg with single percent metric field":
  - skip:
      features: close_to

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          size: 0
          aggs:
            the_terms:
              terms:
                field: "int_field"
              aggs:
                the_percentiles:
                  percentiles:
                    field: "int_field"
                    keyed: false
                    percents: [99]
            the_max:
              max_bucket:
                buckets_path: "the_terms>the_percentiles.99"

  - match: { hits.total: 4 }
  - length: { aggregations.the_terms.buckets: 4 }

  - match: { aggregations.the_terms.buckets.0.key: 1 }
  - match: { aggregations.the_terms.buckets.0.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.0.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.0.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.0.the_percentiles.values.0.value: { value: 1.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.1.key: 2 }
  - match: { aggregations.the_terms.buckets.1.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.1.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.1.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.1.the_percentiles.values.0.value: { value: 2.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.2.key: 3 }
  - match: { aggregations.the_terms.buckets.2.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.2.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.2.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.2.the_percentiles.values.0.value: { value: 3.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.3.key: 4 }
  - match: { aggregations.the_terms.buckets.3.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.3.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.3.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.3.the_percentiles.values.0.value: { value: 4.000000, error: 0.000001 } }

  - close_to: { aggregations.the_max.value: { value: 4.000000, error: 0.000001 } }
  - length: { aggregations.the_max.keys: 1 }
  - match: { aggregations.the_max.keys.0: "4" }

---
"Max pipeline on percentiles hdr agg without specifying percent":

  - do:
      catch: /buckets_path must reference either a number value or a single value numeric metric aggregation, but \[the_percentiles\] contains multiple values. Please specify which to use\./
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            the_terms:
              terms:
                field: "int_field"
              aggs:
                the_percentiles:
                  percentiles:
                    percents: [10, 50, 90, 99]
                    field: "int_field"
                    hdr:
                      number_of_significant_value_digits: 3
            the_bad_max:
              max_bucket:
                buckets_path: "the_terms>the_percentiles"

---
"Max pipeline on percentiles hdr agg with single percent metric value":
  - requires:
      cluster_features: ["gte_v8.4.0"]
      reason: behaviour changed in 8.4.0
      test_runner_features: close_to

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          size: 0
          aggs:
            the_terms:
              terms:
                field: "int_field"
              aggs:
                the_percentiles:
                  percentiles:
                    field: "int_field"
                    keyed: false
                    percents: [99]
                    hdr:
                      number_of_significant_value_digits: 3
            the_max:
              max_bucket:
                buckets_path: "the_terms>the_percentiles"

  - match: { hits.total: 4 }
  - length: { aggregations.the_terms.buckets: 4 }

  - match: { aggregations.the_terms.buckets.0.key: 1 }
  - match: { aggregations.the_terms.buckets.0.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.0.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.0.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.0.the_percentiles.values.0.value: { value: 1.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.1.key: 2 }
  - match: { aggregations.the_terms.buckets.1.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.1.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.1.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.1.the_percentiles.values.0.value: { value: 2.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.2.key: 3 }
  - match: { aggregations.the_terms.buckets.2.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.2.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.2.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.2.the_percentiles.values.0.value: { value: 3.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.3.key: 4 }
  - match: { aggregations.the_terms.buckets.3.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.3.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.3.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.3.the_percentiles.values.0.value: { value: 4.000000, error: 0.000001 } }

  - close_to: { aggregations.the_max.value: { value: 4.000000, error: 0.000001 } }
  - length: { aggregations.the_max.keys: 1 }
  - match: { aggregations.the_max.keys.0: "4" }


---
"Max pipeline on percentiles hdr agg with single percent metric field":
  - skip:
      features: close_to

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          size: 0
          aggs:
            the_terms:
              terms:
                field: "int_field"
              aggs:
                the_percentiles:
                  percentiles:
                    field: "int_field"
                    keyed: false
                    percents: [99]
                    hdr:
                      number_of_significant_value_digits: 3
            the_max:
              max_bucket:
                buckets_path: "the_terms>the_percentiles.99"

  - match: { hits.total: 4 }
  - length: { aggregations.the_terms.buckets: 4 }

  - match: { aggregations.the_terms.buckets.0.key: 1 }
  - match: { aggregations.the_terms.buckets.0.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.0.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.0.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.0.the_percentiles.values.0.value: { value: 1.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.1.key: 2 }
  - match: { aggregations.the_terms.buckets.1.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.1.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.1.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.1.the_percentiles.values.0.value: { value: 2.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.2.key: 3 }
  - match: { aggregations.the_terms.buckets.2.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.2.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.2.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.2.the_percentiles.values.0.value: { value: 3.000000, error: 0.000001 } }

  - match: { aggregations.the_terms.buckets.3.key: 4 }
  - match: { aggregations.the_terms.buckets.3.doc_count: 1 }
  - length: { aggregations.the_terms.buckets.3.the_percentiles.values: 1 }
  - close_to: { aggregations.the_terms.buckets.3.the_percentiles.values.0.key: { value: 99.000000, error: 0.000001 } }
  - close_to: { aggregations.the_terms.buckets.3.the_percentiles.values.0.value: { value: 4.000000, error: 0.000001 } }

  - close_to: { aggregations.the_max.value: { value: 4.000000, error: 0.000001 } }
  - length: { aggregations.the_max.keys: 1 }
  - match: { aggregations.the_max.keys.0: "4" }

---
"Max pipeline on percentiles with incorrect name":
  - requires:
      cluster_features: ["gte_v8.4.0"]
      reason: behaviour changed in 8.4.0
      test_runner_features: close_to

  - do:
      catch: /No aggregation \[unknown_aggregation\] found for path \[the_terms\>unknown_aggregation\]\;/
      search:
        rest_total_hits_as_int: true
        body:
          size: 0
          aggs:
            the_terms:
              terms:
                field: "int_field"
              aggs:
                the_percentiles:
                  percentiles:
                    field: "int_field"
                    keyed: false
                    percents: [99]
                    hdr:
                      number_of_significant_value_digits: 3
            the_max:
              max_bucket:
                buckets_path: "the_terms>unknown_aggregation"

---
"deep cumulative sum":
  - do:
      indices.create:
        index: test
        body:
          settings:
            number_of_shards: 3
  - do:
      bulk:
        index: test
        refresh: true
        body:
          - '{"index": {}}'
          - '{"t": "a", "int" :  1, "@timestamp" : "2020-07-16T00:00:00.000Z"}'
          - '{"index": {}}'
          - '{"t": "a", "int" : 50, "@timestamp" : "2020-07-17T00:00:00.000Z"}'
          - '{"index": {}}'
          - '{"t": "a", "int" : 99, "@timestamp" : "2020-07-18T00:00:00.000Z"}'
          - '{"index": {}}'
          - '{"t": "b", "int" :  1, "@timestamp" : "2020-07-16T00:00:00.000Z"}'
          - '{"index": {}}'
          - '{"t": "b", "int" : 99, "@timestamp" : "2020-07-17T00:00:00.000Z"}'

  - do:
      search:
        rest_total_hits_as_int: true
        index: test
        body:
          size: 0
          aggs:
            t:
              terms:
                field: t.keyword
              aggs:
                by_date:
                  date_histogram:
                    field: "@timestamp"
                    fixed_interval: 1d
                  aggs:
                    avg:
                      avg:
                        field: int
                    sum:
                      cumulative_sum:
                        buckets_path: avg.value
  - match: { hits.total: 5 }
  - length: { aggregations.t.buckets: 2 }
  - match: { aggregations.t.buckets.0.key: a }
  - match: { aggregations.t.buckets.1.key: b }
  - length: { aggregations.t.buckets.0.by_date.buckets: 3 }
  - match: { aggregations.t.buckets.0.by_date.buckets.0.key_as_string: "2020-07-16T00:00:00.000Z" }
  - match: { aggregations.t.buckets.0.by_date.buckets.0.avg.value: 1 }
  - match: { aggregations.t.buckets.0.by_date.buckets.0.sum.value: 1 }
  - match: { aggregations.t.buckets.0.by_date.buckets.1.key_as_string: "2020-07-17T00:00:00.000Z" }
  - match: { aggregations.t.buckets.0.by_date.buckets.1.avg.value: 50 }
  - match: { aggregations.t.buckets.0.by_date.buckets.1.sum.value: 51 }
  - match: { aggregations.t.buckets.0.by_date.buckets.2.key_as_string: "2020-07-18T00:00:00.000Z" }
  - match: { aggregations.t.buckets.0.by_date.buckets.2.avg.value: 99 }
  - match: { aggregations.t.buckets.0.by_date.buckets.2.sum.value: 150 }
  - length: { aggregations.t.buckets.1.by_date.buckets: 2 }
  - match: { aggregations.t.buckets.1.by_date.buckets.0.key_as_string: "2020-07-16T00:00:00.000Z" }
  - match: { aggregations.t.buckets.1.by_date.buckets.0.avg.value: 1 }
  - match: { aggregations.t.buckets.1.by_date.buckets.0.sum.value: 1 }
  - match: { aggregations.t.buckets.1.by_date.buckets.1.key_as_string: "2020-07-17T00:00:00.000Z" }
  - match: { aggregations.t.buckets.1.by_date.buckets.1.avg.value: 99 }
  - match: { aggregations.t.buckets.1.by_date.buckets.1.sum.value: 100 }