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_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

---
"Basic test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            the_int_value_count:
              value_count:
                field: int_field
            the_double_value_count:
              value_count:
                field: double_field
            the_string_value_count:
              value_count:
                field: string_field

  - match: { hits.total: 4 }
  - length: { hits.hits: 4 }
  - match: { aggregations.the_int_value_count.value: 4 }
  - match: { aggregations.the_double_value_count.value: 4 }
  - match: { aggregations.the_string_value_count.value: 4 }

---
"Only aggs test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          size: 0
          aggs:
            the_int_value_count:
              value_count:
                field: int_field
            the_double_value_count:
              value_count:
                field: double_field
            the_string_value_count:
              value_count:
                field: string_field

  - match: { hits.total: 4 }
  - length: { hits.hits: 0 }
  - match: { aggregations.the_int_value_count.value: 4 }
  - match: { aggregations.the_double_value_count.value: 4 }
  - match: { aggregations.the_string_value_count.value: 4 }

---
"Filtered test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          query:
            constant_score:
              filter:
                range:
                  int_field:
                    gte: 50
          aggs:
            the_int_value_count:
              value_count:
                field: int_field
            the_double_value_count:
              value_count:
                field: double_field
            the_string_value_count:
              value_count:
                field: string_field

  - match: { hits.total: 3 }
  - length: { hits.hits: 3 }
  - match: { aggregations.the_int_value_count.value: 3 }
  - match: { aggregations.the_double_value_count.value: 3 }
  - match: { aggregations.the_string_value_count.value: 3 }


---
"Missing field with missing param":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            the_missing_value_count:
              value_count:
                field: foo
                missing: 1

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

---
"Missing field without missing param":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            the_missing_value_count:
              value_count:
                field: foo

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

---
"Metadata test":

  - do:
      search:
        rest_total_hits_as_int: true
        body:
          aggs:
            the_int_value_count:
              meta:
                foo: bar
              value_count:
                field: int_field

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