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:
      indices.create:
          index: test_1
          body:
            mappings:
              properties:
                int_field:
                   type : integer
                double_field:
                   type : double
                string_field:
                   type: keyword

  - do:
       bulk:
         refresh: true
         body:
           - index:
               _index: test_1
               _id:    "1"
           - int_field: 1
             double_field: 1.0
             string_field: foo
           - index:
               _index: test_1
               _id:    "2"
           - int_field: 51
             double_field: 51.0
             string_field: foo
           - index:
               _index: test_1
               _id:    "3"
           - int_field: 101
             double_field: 101.0
             string_field: foo
           - index:
               _index: test_1
               _id:    "4"
           - int_field: 151
             double_field: 151.0
             string_field: foo

  - do:
      indices.create:
        index: test_2
        body:
          mappings:
            properties:
              other_field:
                type: keyword

  - do:
      bulk:
        refresh: true
        body:
          - index:
              _index: test_2
              _id:    "1"
          - other_field: "other value"

---
"Basic test":

  - do:
      search:
        rest_total_hits_as_int: true
        index: test_1
        body:
          aggs:
            the_int_min:
              min:
                field: int_field
            the_double_min:
              min:
                field: double_field

  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }
  - match: { aggregations.the_int_min.value: 1.0 }
  - match: { aggregations.the_double_min.value: 1.0 }

---
"Only aggs test":

  - do:
      search:
        rest_total_hits_as_int: true
        index: test_1
        body:
          size: 0
          aggs:
            the_int_min:
              min:
                field: int_field
            the_double_min:
              min:
                field: double_field

  - match: { hits.total: 4 }
  - length: { hits.hits: 0 }
  - match: { aggregations.the_int_min.value: 1.0 }
  - match: { aggregations.the_double_min.value: 1.0 }

---
"Filtered test":

  - do:
      search:
        rest_total_hits_as_int: true
        index: test_1
        body:
          query:
            constant_score:
              filter:
                range:
                  int_field:
                    gte: 50
          aggs:
            the_int_min:
              min:
                field: int_field
            the_double_min:
              min:
                field: double_field

  - match: { hits.total: 3 }
  - length: { hits.hits: 3 }
  - match: { aggregations.the_int_min.value: 51.0 }
  - match: { aggregations.the_double_min.value: 51.0 }


---
"Missing field with missing param":

  - do:
      search:
        rest_total_hits_as_int: true
        index: test_1
        body:
          aggs:
            the_missing_min:
              min:
                field: foo
                missing: 1

  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }
  - match: { aggregations.the_missing_min.value: 1.0 }

---
"Missing field without missing param":

  - do:
      search:
        rest_total_hits_as_int: true
        index: test_1
        body:
          aggs:
            the_missing_min:
              min:
                field: foo

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

---
"Metadata test":

  - do:
      search:
        rest_total_hits_as_int: true
        index: test_1
        body:
          aggs:
            the_int_min:
              meta:
                foo: bar
              min:
                field: int_field

  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }
  - match: { aggregations.the_int_min.value: 1.0 }
  - match: { aggregations.the_int_min.meta.foo: "bar" }

---
"Aggregating wrong datatype test":

  - do:
      catch: bad_request
      search:
        rest_total_hits_as_int: true
        index: test_1
        body:
          aggs:
            the_string_min:
              min:
                field: string_field

---
"Counter field":
  - requires:
      cluster_features: ["gte_v8.7.0"]
      reason: "counter field support added in 8.7"

  - do:
      indices.create:
        index: myindex
        body:
          mappings:
            properties:
              counter_field:
                type : long
                time_series_metric: counter

  - do:
      bulk:
        refresh: true
        body:
          - index:
              _index: myindex
              _id:    "1"
          - counter_field: 2
          - index:
              _index: myindex
              _id:    "2"
          - counter_field: 4
  - do:
      search:
        rest_total_hits_as_int: true
        index: myindex
        body:
          aggs:
            the_counter_min:
              min:
                field: counter_field

  - match: { hits.total: 2 }
  - length: { hits.hits: 2 }
  - match: { aggregations.the_counter_min.value: 2 }

---
"Partially unmapped":

  - do:
      search:
        index: test_1,test_2
        rest_total_hits_as_int: true
        body:
          aggs:
            the_int_min:
              min:
                field: int_field

  - match: { hits.total: 5 }
  - length: { hits.hits: 5 }
  - match: { aggregations.the_int_min.value: 1.0 }

---
"Partially unmapped with missing":

  - do:
      search:
        index: test_1,test_2
        rest_total_hits_as_int: true
        body:
          aggs:
            the_int_min:
              min:
                field: int_field
                missing: -100000

  - match: { hits.total: 5 }
  - length: { hits.hits: 5 }
  - match: { aggregations.the_int_min.value: -100000 }