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.

5.8 KB
Raw Blame
setup:
  - do:
      bulk:
        index: test
        refresh: true
        body:
          - { "index": { } }
          - { "@timestamp": "2022-01-01T00:00:00", "user": 1 }
          - { "index": { } }
          - { "@timestamp": "2022-01-01T01:00:00", "user": 2 }
          - { "index": { } }
          - { "@timestamp": "2022-01-01T02:00:00", "user": 1 }
          - { "index": { } }
          - { "@timestamp": "2022-01-02T00:00:00", "user": 1 }
          - { "index": { } }
          - { "@timestamp": "2022-01-02T01:00:00", "user": 2 }
          - { "index": { } }
          - { "@timestamp": "2022-01-02T02:00:00", "user": 3 }
          - { "index": { } }
          - { "@timestamp": "2022-01-03T00:00:00", "user": 1 }
          - { "index": { } }
          - { "@timestamp": "2022-01-03T01:00:00", "user": 2 }
          - { "index": { } }
          - { "@timestamp": "2022-01-03T03:00:00", "user": 4 }
          - { "index": { } }
          - { "@timestamp": "2022-01-04T00:00:00", "user": 1 }
          - { "index": { } }
          - { "@timestamp": "2022-01-04T01:00:00", "user": 5 }

---
basic:
  - do:
      search:
        index: test
        body:
          size: 0
          aggs:
            "@timestamp":
              date_histogram:
                field: "@timestamp"
                calendar_interval: day
              aggs:
                distinct_users:
                  cardinality:
                    field: user
                users_sum:
                  cumulative_sum:
                    buckets_path: distinct_users
  - match: { hits.total.value: 11 }
  - length: { [email protected]: 4 }
  - match: { [email protected]_as_string:        "2022-01-01T00:00:00.000Z" }
  - match: { [email protected]_users.value: 2 }
  - match: { [email protected]_sum.value:      2 }
  - match: { [email protected]_as_string:        "2022-01-02T00:00:00.000Z" }
  - match: { [email protected]_users.value: 3 }
  - match: { [email protected]_sum.value:      5 }
  - match: { [email protected]_as_string:        "2022-01-03T00:00:00.000Z" }
  - match: { [email protected]_users.value: 3 }
  - match: { [email protected]_sum.value:      8 }
  - match: { [email protected]_as_string:        "2022-01-04T00:00:00.000Z" }
  - match: { [email protected]_users.value: 2 }
  - match: { [email protected]_sum.value:     10 }

---
format:
  - do:
      search:
        index: test
        body:
          size: 0
          aggs:
            "@timestamp":
              date_histogram:
                field: "@timestamp"
                calendar_interval: day
              aggs:
                distinct_users:
                  cardinality:
                    field: user
                users_sum:
                  cumulative_sum:
                    buckets_path: distinct_users
                    format: "00"
  - match: { hits.total.value: 11 }
  - length: { [email protected]: 4 }
  - match: { [email protected]_as_string:               "2022-01-01T00:00:00.000Z" }
  - match: { [email protected]_users.value:        2 }
  - match: { [email protected]_sum.value_as_string:   "02" }
  - match: { [email protected]_as_string:               "2022-01-02T00:00:00.000Z" }
  - match: { [email protected]_users.value:        3 }
  - match: { [email protected]_sum.value_as_string:   "05" }
  - match: { [email protected]_as_string:               "2022-01-03T00:00:00.000Z" }
  - match: { [email protected]_users.value:        3 }
  - match: { [email protected]_sum.value_as_string:   "08" }
  - match: { [email protected]_as_string:               "2022-01-04T00:00:00.000Z" }
  - match: { [email protected]_users.value:        2 }
  - match: { [email protected]_sum.value_as_string:   "10" }

---
no results:
  - do:
      search:
        index: test
        body:
          size: 0
          query:
            match:
              missing_field: not_found
          aggs:
            "@timestamp":
              date_histogram:
                field: "@timestamp"
                calendar_interval: day
              aggs:
                distinct_users:
                  cardinality:
                    field: user
                users_sum:
                  cumulative_sum:
                    buckets_path: distinct_users
  - match: { hits.total.value: 0 }
  - length: { [email protected]: 0 }

---
bad path:
  - do:
      catch: '/Validation Failed: 1: No aggregation found for path \[missing\];/'
      search:
        index: test
        body:
          size: 0
          aggs:
            "@timestamp":
              date_histogram:
                field: "@timestamp"
                calendar_interval: day
              aggs:
                distinct_users:
                  cardinality:
                    field: user
                users_sum:
                  cumulative_sum:
                    buckets_path: missing

---
invalid parent aggregation:
  - do:
      catch: /cumulative_sum aggregation \[d\] must have a histogram, date_histogram or auto_date_histogram as parent/
      search:
        body:
          aggs:
            a:
              filter:
                term:
                  a: 1
              aggs:
                b:
                  sum:
                    field: b
                d:
                  cumulative_sum:
                    buckets_path: b