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.

2.1 KB
Raw Blame
setup:
  - do:
      indices.create:
        index:  test
        body:
          mappings:
            properties:
              title:
                type: text
              abstract:
                type: text
              body:
                type: text

  - do:
      index:
        index: test
        id: "1"
        body:
          title: "Time, Clocks and the Ordering of Events in a Distributed System"
          abstract: "The concept of one event happening before another..."
          body: "The concept of time is fundamental to our way of thinking..."
        refresh: true

---
"Test combined_fields query":
  - requires:
      cluster_features: ["gte_v7.13.0"]
      reason: "combined fields query was introduced in 7.13"
  - do:
      search:
        index: test
        body:
          query:
            combined_fields:
              query: "time event"
              fields: ["abstract", "body"]
              operator: "and"

  - match: { hits.total.value: 1 }
  - match: { hits.hits.0._id: "1" }

---
"Test combined_fields default-operator (OR) with tokens scattered across fields":
  - requires:
      cluster_features: ["gte_v7.13.0"]
      reason: "combined fields query was introduced in 7.13"
  # `clocks` occurs only in `title`; `happening` occurs only in `abstract`.
  # No single field contains the whole query, so the default-operator (OR)
  # case must POOL tokens across fields — otherwise the doc silently
  # returned 0 hits. The scored path must also give it a non-zero _score.
  - do:
      search:
        index: test
        body:
          query:
            combined_fields:
              query: "clocks happening"
              fields: ["title", "abstract"]

  - match: { hits.total.value: 1 }
  - match: { hits.hits.0._id: "1" }
  - gt: { hits.hits.0._score: 0.0 }

  # A single scattered token still matches under OR.
  - do:
      search:
        index: test
        body:
          query:
            combined_fields:
              query: "clocks nonexistentword"
              fields: ["title", "abstract"]

  - match: { hits.total.value: 1 }
  - match: { hits.hits.0._id: "1" }