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.3 KB
Raw Blame
setup:
  - do:
      index:
        index: ip_locations
        id: 192.168.1.1
        body: { country: 'Canada', city: 'Montreal' }

  - do:
      index:
        index: ip_locations
        id: 192.168.1.3
        body: { country: 'Canada', city: 'Toronto' }

  - do:
      index:
        index: logs
        body: { ip: '192.168.1.1', msg: 'The first message', ord: 1 }
  - do:
      index:
        index: logs
        body: { ip: '192.168.1.2', msg: 'The second message', ord: 2 }

  - do:
      indices.refresh:
        index: "ip_locations,logs"

---
"Retrieve lookup fields":
  - requires:
      cluster_features: ["gte_v8.2.0"]
      reason: "Lookup fields are introduced in 8.2"
  - do:
      search:
        index: logs
        body:
          runtime_mappings:
            location:
              type: lookup
              target_index: ip_locations
              input_field: ip
              target_field: _id
              fetch_fields: [ "city", "country" ]
          sort: ord
          fields:
            - msg
            - location

  - match: { hits.hits.0.fields.msg: [ 'The first message' ] }
  - match: { hits.hits.0.fields.location: [ { country: [ 'Canada' ], city: [ 'Montreal' ] } ] }
  - match: { hits.hits.1.fields.msg: [ 'The second message' ] }
  - match: { hits.hits.1.fields.location: null }

---
"Fails to query or aggregate on lookup fields":
  - requires:
      cluster_features: ["gte_v8.2.0"]
      reason: "Lookup fields are introduced in 8.2"
  - do:
      catch: /Field \[location\] of type \[lookup\] does not support match queries/
      search:
        index: logs
        body:
          runtime_mappings:
            location:
              type: lookup
              target_index: ip_locations
              input_field: ip
              target_field: _id
              fetch_fields: [ "city"]
          query:
            match:
              location: montreal

  - do:
      catch: /Fielddata is not supported on field \[location\] of type \[lookup\]/
      search:
        index: logs
        body:
          runtime_mappings:
            location:
              type: lookup
              target_index: ip_locations
              input_field: ip
              target_field: _id
              fetch_fields: [ "city" ]
          aggs:
            locations:
              terms:
                field: location