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.
Rust agent-memoryai-agentsbm25claude-codeclicode-searchcursordatabaseelasticsearchfull-text-searchhybrid-searchjsonllocal-firstmcpmcp-servermodel-context-protocolragrustsearch-enginevector-search
setup:
- do:
indices.create:
index: test
body:
mappings:
properties:
ip:
type: ip
- do:
indices.refresh:
index: test
---
"IP range":
- do:
bulk:
index: test
refresh: true
body:
- {"index": {}}
- { "ip" : "::1" }
- {"index": {}}
- { "ip" : "192.168.0.1" }
- {"index": {}}
- { "ip" : "192.168.0.7" }
- do:
search:
body:
size: 0
aggs:
ip_range:
ip_range:
field: "ip"
ranges:
-
to: "192.168.0.0"
-
from: "192.168.0.0"
to: "192.169.0.0"
-
from: "192.169.0.0"
- match: { hits.total.value: 3 }
- match: { hits.total.relation: "eq" }
- length: { aggregations.ip_range.buckets: 3 }
- is_false: aggregations.ip_range.buckets.0.from
- match: { aggregations.ip_range.buckets.0.to: "192.168.0.0" }
- match: { aggregations.ip_range.buckets.0.doc_count: 1 }
- match: { aggregations.ip_range.buckets.1.from: "192.168.0.0" }
- match: { aggregations.ip_range.buckets.1.to: "192.169.0.0" }
- match: { aggregations.ip_range.buckets.1.doc_count: 2 }
- match: { aggregations.ip_range.buckets.2.from: "192.169.0.0" }
- is_false: aggregations.ip_range.buckets.2.to
- match: { aggregations.ip_range.buckets.2.doc_count: 0 }
- do:
search:
body:
size: 0
aggs:
ip_range:
ip_range:
field: "ip"
ranges:
-
from: null
to: "192.168.0.0"
-
from: "192.168.0.0"
to: "192.169.0.0"
-
from: "192.169.0.0"
to: null
- match: { hits.total.value: 3 }
- match: { hits.total.relation: "eq" }
- length: { aggregations.ip_range.buckets: 3 }
- is_false: aggregations.ip_range.buckets.0.from
- match: { aggregations.ip_range.buckets.0.to: "192.168.0.0" }
- match: { aggregations.ip_range.buckets.0.doc_count: 1 }
- match: { aggregations.ip_range.buckets.1.from: "192.168.0.0" }
- match: { aggregations.ip_range.buckets.1.to: "192.169.0.0" }
- match: { aggregations.ip_range.buckets.1.doc_count: 2 }
- match: { aggregations.ip_range.buckets.2.from: "192.169.0.0" }
- is_false: aggregations.ip_range.buckets.2.to
- match: { aggregations.ip_range.buckets.2.doc_count: 0 }
- do:
search:
body:
size: 0
aggs:
ip_range:
ip_range:
field: "ip"
ranges:
-
mask: "::/24"
-
mask: "192.168.0.0/16"
- match: { hits.total.value: 3 }
- match: { hits.total.relation: "eq" }
- length: { aggregations.ip_range.buckets: 2 }
- match: { aggregations.ip_range.buckets.0.key: "::/24" }
- match: { aggregations.ip_range.buckets.0.to: "0:100::" }
- match: { aggregations.ip_range.buckets.0.doc_count: 3 }
- match: { aggregations.ip_range.buckets.1.key: "192.168.0.0/16" }
- match: { aggregations.ip_range.buckets.1.from: "192.168.0.0" }
- match: { aggregations.ip_range.buckets.1.to: "192.169.0.0" }
- match: { aggregations.ip_range.buckets.1.doc_count: 2 }
---
"IP Range Key Generation":
- do:
search:
body:
size: 0
aggs:
ip_range:
ip_range:
field: "ip"
ranges:
-
to: "192.168.0.0"
-
from: "192.168.0.0"
to: "192.169.0.0"
-
from: "192.169.0.0"
- length: { aggregations.ip_range.buckets: 3 }
- match: { aggregations.ip_range.buckets.0.key: "*-192.168.0.0" }
- match: { aggregations.ip_range.buckets.1.key: "192.168.0.0-192.169.0.0" }
- match: { aggregations.ip_range.buckets.2.key: "192.169.0.0-*" }
---
"IP Range avg_bucket":
- requires:
cluster_features: ["gte_v7.8.0"]
reason: Fixed in 7.8.0
- do:
bulk:
refresh: true
index: test
body:
- '{"index": {}}'
- '{"ip": "::1", "v": 1}'
- '{"index": {}}'
- '{"ip": "192.168.0.1", "v": 2}'
- '{"index": {}}'
- '{"ip": "192.168.0.7", "v": 3}'
- do:
search:
index: test
body:
size: 0
aggs:
range:
ip_range:
field: ip
ranges:
- to: 192.168.0.0
- from: 192.168.0.0
to: 192.169.0.0
- from: 192.169.0.0
aggs:
v:
sum:
field: v
range_avg_v:
avg_bucket:
buckets_path: range.v
- match: { hits.total.value: 3 }
- length: { aggregations.range.buckets: 3 }
- match: { aggregations.range.buckets.0.key: "*-192.168.0.0" }
- match: { aggregations.range.buckets.0.doc_count: 1 }
- match: { aggregations.range.buckets.0.v.value: 1 }
- match: { aggregations.range.buckets.1.key: "192.168.0.0-192.169.0.0" }
- match: { aggregations.range.buckets.1.doc_count: 2 }
- match: { aggregations.range.buckets.1.v.value: 5 }
- match: { aggregations.range.buckets.2.key: "192.169.0.0-*" }
- match: { aggregations.range.buckets.2.doc_count: 0 }
- match: { aggregations.range.buckets.2.v.value: 0 }
- match: { aggregations.range_avg_v.value: 3 }