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.

6.7 KB
Raw Blame
setup:
  - do:
      indices.create:
        index: test
        body:
          mappings:
            properties:
              int:
                type : integer
              double:
                type : double
              keyword:
                type: keyword

  - do:
      bulk:
        refresh: true
        index: test
        body:
          - '{"index": {}}'
          - '{"int":   1, "double":   1.0, "keyword": "foo"}'
          - '{"index": {}}'
          - '{"int":  51, "double":  51.0, "keyword": "foo"}'
          - '{"index": {}}'
          - '{"int": 101, "double": 101.0, "keyword": "foo"}'
          - '{"index": {}}'
          - '{"int": 151, "double": 151.0, "keyword": "foo"}'

---
basic:
  - skip:
      features: close_to

  - do:
      search:
        body:
          size: 0
          aggs:
            percentile_ranks_int:
              percentile_ranks:
                field: int
                values: [50, 99]
            percentile_ranks_double:
              percentile_ranks:
                field: double
                values: [50, 99]

  - match: { hits.total.value: 4 }
  - close_to: { aggregations.percentile_ranks_int.values.50\\.0: { value: 37.0, error: 1} }
  - close_to: { aggregations.percentile_ranks_int.values.99\\.0: { value: 61.5, error: 1} }
  - close_to: { aggregations.percentile_ranks_double.values.50\\.0: { value: 37.0, error: 1} }
  - close_to: { aggregations.percentile_ranks_double.values.99\\.0: { value: 61.5, error: 1} }

---
with compression:
  - requires:
      test_runner_features: close_to
      cluster_features: ["gte_v8.9.0"]
      reason: t-digest forked in 8.9.0
  - do:
      search:
        body:
          size: 0
          aggs:
            percentile_ranks_int:
              percentile_ranks:
                field: int
                values: [50, 99]
                tdigest:
                  compression: 200

  - match: { hits.total.value: 4 }
  - close_to: { aggregations.percentile_ranks_int.values.50\\.0: { value: 37.0, error: 1} }
  - close_to: { aggregations.percentile_ranks_int.values.99\\.0: { value: 61.5, error: 1} }

---
with execution hint:
  - requires:
      test_runner_features: close_to
      cluster_features: ["gte_v8.9.0"]
      reason: t-digest forked in 8.9.0

  - do:
      search:
        body:
          size: 0
          aggs:
            percentile_ranks_int:
              percentile_ranks:
                field: int
                values: [50, 99]
                tdigest:
                  execution_hint: high_accuracy

  - match: { hits.total.value: 4 }
  - close_to: { aggregations.percentile_ranks_int.values.50\\.0: { value: 37.0, error: 1} }
  - close_to: { aggregations.percentile_ranks_int.values.99\\.0: { value: 61.5, error: 1} }

  - do:
      search:
        body:
          size: 0
          aggs:
            percentile_ranks_int:
              percentile_ranks:
                field: int
                values: [ 50, 99 ]
                tdigest:
                  execution_hint: default

  - match: { hits.total.value: 4 }
  - close_to: { aggregations.percentile_ranks_int.values.50\\.0: { value: 37.0, error: 1 } }
  - close_to: { aggregations.percentile_ranks_int.values.99\\.0: { value: 61.5, error: 1 } }

  - do:
      catch: /Invalid execution_hint \[no_such_hint\], valid values are \[default, high_accuracy\]/
      search:
        body:
          aggs:
            percentile_ranks_string:
              percentile_ranks:
                field: string
                tdigest:
                  execution_hint: no_such_hint

---
filtered:
  - skip:
      features: close_to

  - do:
      search:
        body:
          size: 0
          query:
            range:
              int:
                gte: 50
          aggs:
            percentile_ranks_int:
              percentile_ranks:
                field: int
                values: [51]
            percentile_ranks_double:
              percentile_ranks:
                field: double
                values: [51]

  - match: { hits.total.value: 3 }
  - close_to: { aggregations.percentile_ranks_int.values.51\\.0: { value: 16.0, error: 1} }
  - close_to: { aggregations.percentile_ranks_double.values.51\\.0: { value: 16.0, error: 1} }

---
missing field with missing param:
  - skip:
      features: close_to

  - do:
      search:
        body:
          size: 0
          aggs:
            percentile_ranks_missing:
              percentile_ranks:
                field: missing
                missing: 1.0
                values: [50, 99]

  - match: { hits.total.value: 4 }
  - close_to: { aggregations.percentile_ranks_missing.values.50\\.0: { value: 100.0, error: 1} }
  - close_to: { aggregations.percentile_ranks_missing.values.99\\.0: { value: 100.0, error: 1} }

---
missing field without missing param:
  - do:
      search:
        body:
          size: 0
          aggs:
            percentile_ranks_missing:
              percentile_ranks:
                field: missing
                values: [50, 99]

  - match: { hits.total.value: 4 }
  - is_false: aggregations.percentile_ranks_missing.value

---
invalid params:
  - do:
      catch: bad_request
      search:
        body:
          aggs:
            percentile_ranks_int:
              percentile_ranks:
                field: int
                values: []

  - do:
      catch: bad_request
      search:
        body:
          aggs:
            percentile_ranks_int:
              percentile_ranks:
                field: int
                values: null

  - do:
      catch: bad_request
      search:
        body:
          aggs:
            percentile_ranks_int:
              percentile_ranks:
                field: int
                values: ["foo"]

  - do:
      catch: bad_request
      search:
        body:
          aggs:
            percentile_ranks_string:
              percentile_ranks:
                field: string

  - do:
      catch: /\[compression\] must be greater than or equal to 0. Found \[-1.0\]/
      search:
        body:
          aggs:
            percentile_ranks_string:
              percentile_ranks:
                field: string
                tdigest:
                  compression: -1

---
non-keyed test:
  - skip:
      features: close_to
  - do:
      search:
        body:
          size: 0
          aggs:
            percentile_ranks_int:
              percentile_ranks:
                field: int
                values: [50, 99]
                keyed: false

  - match: { hits.total.value: 4 }
  - match: { aggregations.percentile_ranks_int.values.0.key: 50}
  - close_to: { aggregations.percentile_ranks_int.values.0.value: { value: 30.0, error: 10.0 } }
  - match: { aggregations.percentile_ranks_int.values.1.key: 99}
  - close_to: { aggregations.percentile_ranks_int.values.1.value: { value: 55.0, error: 10.0 } }