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.

3.2 KB
Raw Blame

Vector search — kNN, no Pinecone

Use case doc: vectors / playbooks/vector-search

dense_vector field + kNN retrieval are first-class in the same engine.

✅ create vector index

curl -s -XPUT "http://localhost:9200/vstore" \
  -H 'content-type: application/json' \
  -d '{"mappings":{"properties":{"text":{"type":"text"},"embedding":{"type":"dense_vector","dims":4}}}}'
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "vstore"
}

HTTP 200

✅ bulk index vectors

curl -s -XPOST "http://localhost:9200/vstore/_bulk" \
  -H 'content-type: application/x-ndjson' \
  --data-binary $'{"index":{}}\n{"text":"red apple","embedding":[0.9,0.1,0.0,0.1]}\n{"index":{}}\n{"text":"green pear","embedding":[0.1,0.9,0.1,0.0]}\n{"index":{}}\n{"text":"blue car","embedding":[0.0,0.1,0.9,0.1]}\n'
{
  "errors": false,
  "items": [
    {
      "index": {
        "_id": "7cecbafd-9619-4452-ae2a-7d750fe23c9a",
        "_index": "vstore",
        "_primary_term": 1,
        "_seq_no": 1782855459635957,
        "_shards": {
          "failed": 0,
          "successful": 1,
          "total": 1
        },
        "_version": 1,
        "result": "created",
        "status": 201
      }
    },
    {
      "index": {
        "_id": "977f6978-af18-4919-8271-181518685d57",
        "_index": "vstore",
        "_primary_term": 1,
        "_seq_no": 1782855459635958,
        "_shards": {
          "failed": 0,
          "successful": 1,
          "total": 1
        },
        "_version": 1,
        "result": "created",
        "status": 201
      }
    },
    {
      "index": {
        "_id": "0a20a023-22db-4fc1-ba93-eb880ed9771a",
        "_index": "vstore",
        "_primary_term": 1,
        "_seq_no": 1782855459635958,
        "_shards": {
          "failed": 0,
          "successful": 1,
          "total": 1
        },
        "_version": 1,
        "result": "created",
        "status": 201
      }
    }
  ],
  "took": 0
}

HTTP 200

✅ refresh

curl -s -XPOST "http://localhost:9200/vstore/_refresh"
{
  "_shards": {
    "failed": 0,
    "successful": 1,
    "total": 1
  }
}

HTTP 200

✅ kNN nearest to [0.9,0.1,0,0.1]

curl -s -XPOST "http://localhost:9200/vstore/_search" \
  -H 'content-type: application/json' \
  -d '{"knn":{"field":"embedding","query_vector":[0.9,0.1,0,0.1],"k":2,"num_candidates":10}}'
{
  "_shards": {
    "failed": 0,
    "skipped": 0,
    "successful": 1,
    "total": 1
  },
  "hits": {
    "hits": [
      {
        "_id": "7cecbafd-9619-4452-ae2a-7d750fe23c9a",
        "_index": "vstore",
        "_score": 1,
        "_source": {
          "embedding": [
            0.9,
            0.1,
            0,
            0.1
          ],
          "text": "red apple"
        }
      },
      {
        "_id": "977f6978-af18-4919-8271-181518685d57",
        "_index": "vstore",
        "_score": 0.608433723449707,
        "_source": {
          "embedding": [
            0.1,
            0.9,
            0.1,
            0
          ],
          "text": "green pear"
        }
      }
    ],
    "max_score": 1,
    "total": {
      "relation": "eq",
      "value": 2
    }
  },
  "timed_out": false,
  "took": 0
}

HTTP 200