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.

6.4 KB
Raw Blame
setup:
  - do:
      indices.create:
          index:  test
  - do:
      index:
          index:  test
          id:     "1"
          body:   { id: 1, foo: bar, age: 18, birth: "2022-01-01" }

  - do:
      index:
          index:  test
          id:     "42"
          body:   { id: 42, foo: bar, age: 18, birth: "2022-02-01" }

  - do:
        index:
            index:  test
            id:     "172"
            body:   { id: 172, foo: bar, age: 24, birth: "2022-03-01" }

  - do:
      indices.create:
        index:  test2
        body:
          settings:
            index:
              number_of_shards: 2

  - do:
      index:
        index:  test2
        id:     "45"
        body:   { id: 45, foo: bar, age: 19, birth: "2023-01-01" }

  - do:
      indices.refresh:
        index: "test*"

---
"basic":
  - requires:
      cluster_features: ["gte_v7.13.0"]
      reason: "point in time is introduced in server in 7.13"
  - do:
      open_point_in_time:
        index: test
        keep_alive: 5m
  - set: {id: point_in_time_id}

  - do:
      search:
        body:
          size: 1
          query:
            match:
              foo: bar
          sort: [{ age: desc }, { id: desc }]
          pit:
            id: "$point_in_time_id"
            keep_alive: 1m

  - match: {hits.total.value: 3 }
  - length: {hits.hits: 1 }
  - match: {hits.hits.0._index: test }
  - match: {hits.hits.0._id: "172" }
  - match: {hits.hits.0.sort.0: 24}
  - match: {hits.hits.0.sort.1: 172}

  - do:
      index:
        index:  test
        id:     "100"
        body:   { id: 100, foo: bar, age: 23 }
  - do:
      indices.refresh:
        index: test

  # search with a point in time
  - do:
      search:
        body:
          size: 1
          query:
            match:
              foo: bar
          sort: [{ age: desc }, { id: desc }]
          search_after: [24, 172]
          pit:
            id: "$point_in_time_id"

  - match: {hits.total.value: 3 }
  - length: {hits.hits: 1 }
  - match: {hits.hits.0._index: test }
  - match: {hits.hits.0._id: "42" }
  - match: {hits.hits.0.sort.0: 18}
  - match: {hits.hits.0.sort.1: 42}

  - do:
      search:
        body:
          size: 1
          query:
            match:
              foo: bar
          sort: [ { age: desc }, { id: desc } ]
          search_after: [18, 42]
          pit:
            id: "$point_in_time_id"

  - match: {hits.total.value: 3}
  - length: {hits.hits: 1 }
  - match: {hits.hits.0._index: test }
  - match: {hits.hits.0._id: "1" }
  - match: {hits.hits.0.sort.0: 18}
  - match: {hits.hits.0.sort.1: 1}

  - do:
      search:
        body:
          size: 1
          query:
            match:
              foo: bar
          sort: [{ age: desc }, { id: desc } ]
          search_after: [18, 1]
          pit:
            id: "$point_in_time_id"
            keep_alive: 1m

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

  - do:
      close_point_in_time:
        body:
          id: "$point_in_time_id"

---
"point-in-time with slicing":
  - requires:
      cluster_features: ["gte_v7.15.0"]
      reason: "support for slicing was added in 7.15"
  - do:
      open_point_in_time:
        index: test
        keep_alive: 5m
  - set: {id: point_in_time_id}

  - do:
      search:
        body:
          slice:
            id: "0"
            max: 2
          size: 1
          query:
            match:
              foo: bar
          sort: [{ age: desc }, { id: desc }]
          pit:
            id: "$point_in_time_id"

  - do:
      close_point_in_time:
        body:
          id: "$point_in_time_id"

---
"wildcard":
  - requires:
      cluster_features: ["gte_v7.10.0"]
      reason: "point in time is introduced in 7.10"
  - do:
      open_point_in_time:
        index: "t*"
        keep_alive: 5m
  - set: {id: point_in_time_id}

  - do:
      search:
        body:
          size: 2
          query:
            match:
              foo: bar
          sort: [{ age: desc }, { id: desc }]
          pit:
            id: "$point_in_time_id"
            keep_alive: 1m

  - match: {hits.total.value: 4 }
  - length: {hits.hits: 2 }
  - match: {hits.hits.0._index: test }
  - match: {hits.hits.0._id: "172" }
  - match: {hits.hits.1._index: test2 }
  - match: {hits.hits.1._id: "45" }

  - do:
      close_point_in_time:
        body:
          id: "$point_in_time_id"

---
"msearch":
  - requires:
      cluster_features: ["gte_v7.10.0"]
      reason: "point in time is introduced in 7.10"
  - do:
      open_point_in_time:
        index: "t*"
        keep_alive: 5m
  - set: {id: point_in_time_id}

  - do:
      msearch:
        body:
          - {}
          - { query: { match: { _index: test }}, pit: { id: "$point_in_time_id" }}
          - {}
          - { query: { match_all: {}}, pit: { id: "$point_in_time_id" }}

  - match:  { responses.0.hits.total.value:     3   }
  - match:  { responses.0.hits.total.relation:  eq  }
  - match:  { responses.1.hits.total.value:     4   }
  - match:  { responses.1.hits.total.relation:  eq  }

  - do:
      catch: bad_request
      msearch:
        body:
          - index: index
          - { query: { match: { foo: bar }}, pit: { id: "$point_in_time_id" }}
          - index: index2
          - { query: { match_all: {}}, pit: { id: "$point_in_time_id" }}

  - do:
      close_point_in_time:
        body:
          id: "$point_in_time_id"

---
"point-in-time with index filter":
  - requires:
      cluster_features: ["gte_v8.12.0"]
      reason: "support for index filter was added in 8.12"
  - do:
      open_point_in_time:
        index: test*
        keep_alive: 5m
        body: { index_filter: { range: { birth: { gte: "2023-01-01" }}}}
  - set: {id: point_in_time_id}

  - do:
      search:
        body:
          size: 1
          pit:
            id: "$point_in_time_id"

  - match: {hits.total.value: 1 }
  - length: {hits.hits: 1 }
  - match: {hits.hits.0._index: test2 }
  - match: {hits.hits.0._id: "45" }

  - do:
      close_point_in_time:
        body:
          id: "$point_in_time_id"

---
"delete invalid PIT returns error":
  - requires:
      cluster_features: ["closing_invalid_pit_id"]
      reason: "support returning a useful error was added in 9.4.0"

  - do:
      catch: /illegal_argument_exception/
      close_point_in_time:
        body:
          # this is an PIT created with an older Elasticsearch version
          # that cannot exist on this version
          id: "46ToAwMDaWR5BXV1aWQyKwZub2RlXzMAAAAAAAAAACoBYwADaWR4BXV1aWQxAgZub2RlXzEAAAAAAAAAAAEBYQADa"