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.

4.2 KB
Raw Blame
setup:
  - do:
        indices.create:
            index: test
            body:
              mappings:
                properties:
                  int_field:
                    type: integer
                  double_field:
                    type: double
                  incomplete_field:
                    type: integer
  - do:
        bulk:
          refresh: true
          body:
            - index:
                _index: test
            - int_field: 100
              double_field: 100.0
              incomplete_field: 1000
            - index:
                _index: test
            - int_field: 200
              double_field: 200.0
              incomplete_field: 2000
            - index:
                _index: test
            - int_field: 300
              double_field: 300.0

---
"basic test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            mad_int:
              median_absolute_deviation:
                field: int_field
            mad_double:
              median_absolute_deviation:
                field: double_field

  - match: { hits.total: 3 }
  - length: { hits.hits: 3 }

  - match: { aggregations.mad_int.value: 100 }
  - match: { aggregations.mad_double.value: 100 }

---
"with setting compression":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            mad_int:
              median_absolute_deviation:
                field: int_field
                compression: 500
            mad_double:
              median_absolute_deviation:
                field: double_field
                compression: 500

  - match: { hits.total: 3 }
  - length: { hits.hits: 3 }

  - match: { aggregations.mad_int.value: 100 }
  - match: { aggregations.mad_double.value: 100 }

---
"with execution hint":

  - requires:
      cluster_features: ["gte_v8.9.0"]
      reason: t-digest forked in 8.9.0

  - do:
      search:
        body:
          aggs:
            mad_int:
              median_absolute_deviation:
                field: int_field
                execution_hint: high_accuracy

  - match: { hits.total.value: 3 }
  - length: { hits.hits: 3 }
  - match: { aggregations.mad_int.value: 100 }

  - do:
      search:
        body:
          aggs:
            mad_int:
              median_absolute_deviation:
                field: int_field
                execution_hint: default

  - match: { hits.total.value: 3 }
  - length: { hits.hits: 3 }
  - match: { aggregations.mad_int.value: 100 }

  - do:
      catch: /Invalid execution_hint \[no_such_hint\], valid values are \[default, high_accuracy\]/
      search:
        body:
          aggs:
            mad:
              median_absolute_deviation:
                field: int_field
                execution_hint: no_such_hint

---
"no documents":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          query:
            bool:
              filter:
                term:
                  non_existent_field: non_existent_value
          aggs:
            mad_no_docs:
              median_absolute_deviation:
                field: non_existent_field

  - match: { hits.total: 0 }
  - length: { hits.hits: 0 }

  - match: { aggregations.mad_no_docs.value: null }

---
"missing value":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            mad_missing:
              median_absolute_deviation:
                field: incomplete_field
                missing: 3000

  - match: { hits.total: 3 }
  - length: { hits.hits: 3 }

  - match: { aggregations.mad_missing.value: 1000 }

---
"bad arguments":

  - do:
      catch: /\[compression\] must be greater than 0. Found \[0.0\] in \[mad\]/
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            mad:
              median_absolute_deviation:
                field: int_field
                compression: 0

  - do:
      catch: /\[compression\] must be greater than 0. Found \[-1.0\] in \[mad\]/
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            mad:
              median_absolute_deviation:
                field: int_field
                compression: -1