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.0 KB
Raw Blame

Quickstart — index, document, get, search

Use case doc: quickstart

Create an index with a mapping, write a document, read it back, and search it.

✅ create index w/ mapping

curl -s -XPUT "http://localhost:9200/articles" \
  -H 'content-type: application/json' \
  -d '{"mappings":{"properties":{"title":{"type":"text"},"body":{"type":"text"},"views":{"type":"integer"},"tag":{"type":"keyword"}}}}'
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "articles"
}

HTTP 200

✅ index a document

curl -s -XPUT "http://localhost:9200/articles/_doc/1" \
  -H 'content-type: application/json' \
  -d '{"title":"Hello Xerj","body":"one binary for search","views":42,"tag":"intro"}'
{
  "_index": "articles",
  "_id": "1",
  "_version": 1,
  "result": "created",
  "_shards": {
    "total": 1,
    "successful": 1,
    "failed": 0
  },
  "_seq_no": 1,
  "_primary_term": 1
}

HTTP 201

✅ get the document

curl -s "http://localhost:9200/articles/_doc/1"
{
  "_index": "articles",
  "_id": "1",
  "_version": 1,
  "_seq_no": 1,
  "_primary_term": 1,
  "found": true,
  "_source": {
    "body": "one binary for search",
    "tag": "intro",
    "title": "Hello Xerj",
    "views": 42
  }
}

HTTP 200

✅ search it

curl -s -XPOST "http://localhost:9200/articles/_search" \
  -H 'content-type: application/json' \
  -d '{"query":{"match":{"body":"binary"}}}'
{
  "_shards": {
    "failed": 0,
    "skipped": 0,
    "successful": 1,
    "total": 1
  },
  "hits": {
    "hits": [
      {
        "_id": "1",
        "_index": "articles",
        "_score": 0.28768211603164673,
        "_source": {
          "body": "one binary for search",
          "tag": "intro",
          "title": "Hello Xerj",
          "views": 42
        }
      }
    ],
    "max_score": 0.28768211603164673,
    "total": {
      "relation": "eq",
      "value": 1
    }
  },
  "timed_out": false,
  "took": 0
}

HTTP 200