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
---
"Put template":

  - do:
      indices.put_template:
        name: test
        body:
          index_patterns: test-*
          settings:
            number_of_shards:   1
            number_of_replicas: 0
          mappings:
            properties:
              field:
                type: keyword

  - do:
      indices.get_template:
        name: test
        flat_settings: true

  - match: {test.index_patterns: ["test-*"]}
  - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}}
  - match: {test.mappings: {properties: {field: {type: keyword}}}}

---
"Put multiple template":

  - do:
      indices.put_template:
        name: test
        body:
          index_patterns: [test-*, test2-*]
          settings:
            number_of_shards:   1
            number_of_replicas: 0
          mappings:
            properties:
              field:
                type: text

  - do:
      indices.get_template:
        name: test
        flat_settings: true

  - match: {test.index_patterns: ["test-*", "test2-*"]}
  - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}}
  - match: {test.mappings: {properties: {field: {type: text}}}}

---
"Put template with empty mappings":

  - do:
      indices.put_template:
        name: test
        body:
          index_patterns: test-*
          settings:
            number_of_shards:   1
            number_of_replicas: 0
          mappings: {}

  - do:
      indices.get_template:
        name: test
        flat_settings: true

  - match: {test.mappings: {}}

---
"Put template with aliases":

  - do:
      indices.put_template:
        name: test
        body:
          index_patterns: test-*
          aliases:
            test_alias: {}
            test_blias: { routing: b }
            test_clias: { filter: { term: { user: kimchy }}}

  - do:
      indices.get_template:
        name: test

  - match:  { test.index_patterns: ["test-*"] }
  - length: { test.aliases: 3 }
  - is_true: test.aliases.test_alias
  - match: { test.aliases.test_blias.index_routing: "b" }
  - match: { test.aliases.test_blias.search_routing: "b" }
  - match: { test.aliases.test_clias.filter.term.user: "kimchy" }

---
"Put template create":

  - do:
      indices.put_template:
        name: test
        create: true
        body:
          index_patterns: test-*
          settings:
            number_of_shards:   1
            number_of_replicas: 0

  - do:
      indices.get_template:
        name: test
        flat_settings: true

  - match: {test.index_patterns: ["test-*"]}
  - match: {test.settings: {index.number_of_shards: '1', index.number_of_replicas: '0'}}

  - do:
      catch: bad_request
      indices.put_template:
        name: test
        create: true
        body:
          index_patterns: test-*
          settings:
            number_of_shards:   1
            number_of_replicas: 0

---
"Test Put Versioned Template":

  - do:
      indices.put_template:
        name: "my_template"
        body: >
          {
            "version": 10,
            "index_patterns": "foo*",
            "settings": { "number_of_shards": 1 }
          }
  - match: { acknowledged: true }

  - do:
      indices.get_template:
        name: "my_template"
  - match: { my_template.version: 10 }

  # Lower version
  - do:
      indices.put_template:
        name: "my_template"
        body: >
          {
            "version": 9,
            "index_patterns": "foo*",
            "settings": { "number_of_shards": 1 }
          }
  - match: { acknowledged: true }

  - do:
      indices.get_template:
        name: "my_template"
  - match: { my_template.version: 9 }

  # Higher version
  - do:
      indices.put_template:
        name: "my_template"
        body: >
          {
            "version": 6789,
            "index_patterns": "foo*",
            "settings": { "number_of_shards": 1 }
          }
  - match: { acknowledged: true }

  - do:
      indices.get_template:
        name: "my_template"
  - match: { my_template.version: 6789 }

  # No version
  - do:
      indices.put_template:
        name: "my_template"
        body: >
          {
            "index_patterns": "foo*",
            "settings": { "number_of_shards": 1 }
          }
  - match: { acknowledged: true }

  - do:
      indices.get_template:
        name: "my_template"
  - is_false: my_template.version

  # Coming back with a version
  - do:
      indices.put_template:
        name: "my_template"
        body: >
          {
            "version": 5385,
            "index_patterns": "foo*",
            "settings": { "number_of_shards": 1 }
          }
  - match: { acknowledged: true }

  - do:
      indices.get_template:
        name: "my_template"
  - match: { my_template.version: 5385 }

  # Able to delete the versioned template
  - do:
      indices.delete_template:
        name: "my_template"
  - match: { acknowledged: true }

  - do:
      catch: missing
      indices.get_template:
        name: "my_template"

---
"Put index template without index_patterns":

  - do:
      catch: /index patterns are missing/
      indices.put_template:
        name: test
        body: {}