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.1 KB
Raw Blame
setup:
  - do:
      indices.create:
          index: test
          body:
            settings:
              number_of_shards: 1
            mappings:
              properties:
                date:
                  type: date
  - do:
      bulk:
        refresh: true
        index: test
        body:
            - '{"index": {}}'
            - '{"date": "2020-03-01", "v": 1}'
            - '{"index": {}}'
            - '{"date": "2020-03-02", "v": 2}'
            - '{"index": {}}'
            - '{"date": "2020-03-08", "v": 3}'
            - '{"index": {}}'
            - '{"date": "2020-03-09", "v": 4}'

---
"basic":
  - requires:
      cluster_features: ["gte_v7.9.0"]
      reason:  interval had a in bug before 7.9.0
  - do:
      search:
        body:
          size: 0
          aggs:
            histo:
              auto_date_histogram:
                field: date
                buckets: 2
  - match: { hits.total.value: 4 }
  - length: { aggregations.histo.buckets: 2 }
  - match: { aggregations.histo.interval: "7d" }
  - match: { aggregations.histo.buckets.0.key_as_string: "2020-03-01T00:00:00.000Z" }
  - match: { aggregations.histo.buckets.0.doc_count: 2 }
  - match: { aggregations.histo.buckets.1.key_as_string: "2020-03-08T00:00:00.000Z" }
  - match: { aggregations.histo.buckets.1.doc_count: 2 }

---
"avg_bucket":
  - requires:
      cluster_features: ["gte_v7.8.0"]
      reason: Fixed in 7.8.0
  - do:
      search:
        body:
          size: 0
          aggs:
            histo:
              auto_date_histogram:
                field: date
                buckets: 2
              aggs:
                v:
                  sum:
                    field: v
            histo_avg_v:
              avg_bucket:
                buckets_path: histo.v
  - match: { hits.total.value: 4 }
  - length: { aggregations.histo.buckets: 2 }
  - match: { aggregations.histo.buckets.0.key_as_string: "2020-03-01T00:00:00.000Z" }
  - match: { aggregations.histo.buckets.0.doc_count: 2 }
  - match: { aggregations.histo.buckets.0.v.value: 3 }
  - match: { aggregations.histo.buckets.1.key_as_string: "2020-03-08T00:00:00.000Z" }
  - match: { aggregations.histo.buckets.1.doc_count: 2 }
  - match: { aggregations.histo.buckets.1.v.value: 7 }
  - match: { aggregations.histo_avg_v.value: 5 }

---
"profile at top level":
  - requires:
      cluster_features: ["gte_v7.10.0"]
      reason: introduced in 7.10.0

  - do:
      search:
        body:
          profile: true
          size: 0
          aggs:
            histo:
              auto_date_histogram:
                field: date
                buckets: 2

  - match: { hits.total.value: 4 }
  - length: { aggregations.histo.buckets: 2 }
  - match: { profile.shards.0.aggregations.0.type: AutoDateHistogramAggregator.FromSingle }
  - match: { profile.shards.0.aggregations.0.debug.surviving_buckets: 4 }

---
"Auto date histogram on two indices with same field but different date type":
  - do:
      indices.create:
        index: date_field_type_date
        body:
          mappings:
            properties:
              date_field:
                type: date

  - do:
      indices.create:
        index: date_field_type_date_nanos
        body:
          mappings:
            properties:
              date_field:
                type: date_nanos

  - do:
      index:
        index: date_field_type_date
        refresh: true
        id: "1"
        body:
          date_field: "2017-10-20T03:08:45"

  - do:
      index:
        index: date_field_type_date_nanos
        refresh: true
        id: "2"
        body:
          date_field: "2017-10-20T04:10:15"

  - do:
      search:
        index: date_field_type_date,date_field_type_date_nanos
        body:
          aggs:
            auto_date_histogram:
              auto_date_histogram:
                field: date_field
                buckets: 2

  - match: { hits.total.value: 2 }
  - match: { hits.total.relation: "eq" }
  - length: { hits.hits: 2 }
  - length: { aggregations.auto_date_histogram.buckets: 2 }
  - match: { aggregations.auto_date_histogram.buckets.0.key_as_string: "2017-10-20T03:00:00.000Z" }
  - match: { aggregations.auto_date_histogram.buckets.0.key: 1508468400000 }
  - match: { aggregations.auto_date_histogram.buckets.0.doc_count: 1 }
  - match: { aggregations.auto_date_histogram.buckets.1.key_as_string: "2017-10-20T04:00:00.000Z" }
  - match: { aggregations.auto_date_histogram.buckets.1.key: 1508472000000 }
  - match: { aggregations.auto_date_histogram.buckets.1.doc_count: 1 }

  - do:
      search:
        index: date_field_type_date,date_field_type_date_nanos
        body:
          aggs:
            date_histogram:
              auto_date_histogram:
                field: date_field
                buckets: 1

  - match: { hits.total.value: 2 }
  - match: { hits.total.relation: "eq" }
  - length: { hits.hits: 2 }
  - length: { aggregations.date_histogram.buckets: 1 }
  - match: { aggregations.date_histogram.buckets.0.key_as_string: "2017-10-20T03:00:00.000Z" }
  - match: { aggregations.date_histogram.buckets.0.key: 1508468400000 }
  - match: { aggregations.date_histogram.buckets.0.doc_count: 2 }