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.6 KB
Raw Blame
basic:
  - do:
      bulk:
        index: test
        refresh: true
        body:
          - { "index": { } }
          - { "@timestamp": "2022-01-01T00:00:00", "v": 1 }
          - { "index": { } }
          - { "@timestamp": "2022-01-01T01:00:00", "v": 2 }
          - { "index": { } }
          - { "@timestamp": "2022-01-01T02:00:00", "v": 1 }

  - do:
      search:
        body:
          size: 0
          aggs:
            "@timestamp":
              date_histogram:
                field: "@timestamp"
                fixed_interval: 1h
              aggs:
                v: {avg: {field: v}}
                d: {serial_diff: {buckets_path: v}}
  - match: { hits.total.value: 3 }
  - length: { [email protected]: 3 }
  - match: { [email protected]_as_string: "2022-01-01T00:00:00.000Z" }
  - match: { [email protected]_as_string: "2022-01-01T01:00:00.000Z" }
  - match: { [email protected]_as_string: "2022-01-01T02:00:00.000Z" }
  - match: { [email protected]: 1 }
  - match: { [email protected]: 2 }
  - match: { [email protected]: 1 }
  - is_false: [email protected]
  - match: { [email protected]: 1 }
  - match: { [email protected]: -1 }

---
lag:
      - do:
          bulk:
            index: test
            refresh: true
            body:
              - { "index": { } }
              - { "@timestamp": "2022-01-01T00:00:00", "v": 1 }
              - { "index": { } }
              - { "@timestamp": "2022-01-01T01:00:00", "v": 2 }
              - { "index": { } }
              - { "@timestamp": "2022-01-01T02:00:00", "v": 3 }
              - { "index": { } }
              - { "@timestamp": "2022-01-01T03:00:00", "v": 1 }

      - do:
          search:
            body:
              size: 0
              aggs:
                "@timestamp":
                  date_histogram:
                    field: "@timestamp"
                    fixed_interval: 1h
                  aggs:
                    v: { avg: { field: v } }
                    d: { serial_diff: { buckets_path: v, lag: 2 } }
      - match: { hits.total.value: 4 }
      - length: { [email protected]: 4 }
      - match: { [email protected]_as_string: "2022-01-01T00:00:00.000Z" }
      - match: { [email protected]_as_string: "2022-01-01T01:00:00.000Z" }
      - match: { [email protected]_as_string: "2022-01-01T02:00:00.000Z" }
      - match: { [email protected]_as_string: "2022-01-01T03:00:00.000Z" }
      - match: { [email protected]: 1 }
      - match: { [email protected]: 2 }
      - match: { [email protected]: 3 }
      - match: { [email protected]: 1 }
      - is_false: [email protected]
      - is_false: [email protected]
      - match: { [email protected]: 2 }
      - match: { [email protected]: -1 }

---
parent has gap:
  - do:
      bulk:
        index: test
        refresh: true
        body:
          - { "index": { } }
          - { "@timestamp": "2022-01-01T00:00:00", "v": 1 }
          - { "index": { } }
          - { "@timestamp": "2022-01-01T01:00:00", "v": 2 }
          - { "index": { } }
          - { "@timestamp": "2022-01-01T03:00:00", "v": 1 }

  - do:
      search:
        body:
          size: 0
          aggs:
            "@timestamp":
              date_histogram:
                field: "@timestamp"
                fixed_interval: 1h
              aggs:
                v: {avg: {field: v}}
                d: {serial_diff: {buckets_path: v}}
  - match: { hits.total.value: 3 }
  - length: { [email protected]: 4 }
  - match: { [email protected]_as_string: "2022-01-01T00:00:00.000Z" }
  - match: { [email protected]_as_string: "2022-01-01T01:00:00.000Z" }
  - match: { [email protected]_as_string: "2022-01-01T02:00:00.000Z" }
  - match: { [email protected]_as_string: "2022-01-01T03:00:00.000Z" }
  - match: { [email protected]: 1 }
  - match: { [email protected]: 2 }
  - is_false: [email protected]
  - match: { [email protected]: 1 }
  - is_false: [email protected]
  - match: { [email protected]: 1 }
  - is_false: [email protected]
  - is_false: [email protected]

---
parent has min_doc_count:
  - requires:
      cluster_features: ["gte_v8.3.0"]
      reason: allowed in 8.3.0

  - do:
      bulk:
        index: test
        refresh: true
        body:
          - { "index": { } }
          - { "@timestamp": "2022-01-01T00:00:00", "v": 1 }
          - { "index": { } }
          - { "@timestamp": "2022-01-01T01:00:00", "v": 2 }
          - { "index": { } }
          - { "@timestamp": "2022-01-01T03:00:00", "v": 1 }

  - do:
      search:
        body:
          size: 0
          aggs:
            "@timestamp":
              date_histogram:
                field: "@timestamp"
                fixed_interval: 1h
                min_doc_count: 1
              aggs:
                v: {avg: {field: v}}
                d: {serial_diff: {buckets_path: v}}
  - match: { hits.total.value: 3 }
  - length: { [email protected]: 3 }
  - match: { [email protected]_as_string: "2022-01-01T00:00:00.000Z" }
  - match: { [email protected]_as_string: "2022-01-01T01:00:00.000Z" }
  - match: { [email protected]_as_string: "2022-01-01T03:00:00.000Z" }
  - match: { [email protected]: 1 }
  - match: { [email protected]: 2 }
  - match: { [email protected]: 1 }
  - is_false: [email protected]
  - match: { [email protected]: 1 }
  - match: { [email protected]: -1 }

---
invalid parent aggregation:
  - do:
      catch: /serial_diff 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:
                  serial_diff:
                    buckets_path: "b"