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:
- requires:
cluster_features: ["gte_v8.7.0"]
reason: serialization bug fixed in 8.7.0
- do:
indices.create:
index: test
body:
settings:
number_of_shards: 3
number_of_routing_shards: 3
mappings:
"properties":
"val1":
"type": "double"
"val2":
"type": "double"
"val3":
"type": "double"
"vals":
"type": "float"
- do:
indices.create:
index: unmapped
body:
settings:
number_of_shards: 3
- do:
index:
index: test
id: "1"
body: { "val1": 1.9, "val2": 3.1, "val3": 2.3, "vals" : [1.9, 16.143] }
- do:
index:
index: test
id: "2"
body: { "val1": -5.2, "val2": -3.4, "val3": 2.3, "vals" : [155, 16.23]}
- do:
index:
index: test
id: "3"
body: { "val1": -5.2, "val3": 2.3, "vals" : [-455, -32.32]}
- do:
index:
index: test
id: "4"
body: { "val1": 18.3, "val2": 104.4, "val3": 2.3, "vals" : [0.14, 92.1]}
- do:
index:
index: test
id: "5"
body: { "val1": -53.2, "val2": -322.4, "val3": 2.3, "vals" : [16, 16]}
- do:
index:
index: test
id: "6"
body: { "val1": -578.9, "val2": 69.9, "val3": 2.3}
- do:
index:
index: test
id: "7"
body: { "val1": 16.2, "val2": 17.2, "val3": 2.3, "vals" : [1234.3, -3433]}
- do:
index:
index: test
id: "8"
body: { "val1": -4222.63, "val2": 316.44, "val3": 2.3, "vals" : [177.2, -93.333]}
- do:
index:
index: test
id: "9"
body: { "val1": -59999.55, "val2": -3163.4, "val3": 2.3, "vals" : [-29.9, 163.0]}
- do:
index:
index: test
id: "10"
body: { "val1": 782.7, "val2": 789.7, "val3": 2.3, "vals" : [-0.2, 1343.3]}
- do:
index:
index: test
id: "11"
body: { "val1": -1.2, "val2": 6.3, "val3": 2.3, "vals" : [15.3, 16.9]}
- do:
index:
index: test
id: "12"
body: { "val1": 0, "val2": 1.11, "val3": 2.3, "vals" : [-644.4, -644.4]}
- do:
index:
index: test
id: "13"
body: { "val1": 0.1, "val2": 0.92, "val3": 2.3, "vals" : [73.2, 0.12]}
- do:
index:
index: test
id: "14"
body: { "val1": 0.12, "val2": -82.4, "val3": 2.3, "vals" : [-0.001, 1295.3]}
- do:
index:
index: test
id: "15"
body: { "val1": 98.2, "val2": 32.4, "val3": 2.3, "vals" : [15.5, 16.5]}
- do:
indices.refresh:
index: [test, unmapped]
- do:
cluster.health:
wait_for_status: yellow
---
"Unmapped":
- do:
search:
rest_total_hits_as_int: true
index: unmapped
body: {"aggs": { "mfs" : { "matrix_stats": {"fields": ["val1", "val2", "vals"]} } } }
- match: {hits.total: 0}
- match: {aggregations.mfs.doc_count: 0}
---
"Multi value field Max":
- skip:
features: close_to
- do:
search:
rest_total_hits_as_int: true
index: test
body: {"aggs": { "mfs" : { "matrix_stats": {"fields": ["val1", "vals"], "mode" : "max"} } } }
- match: {hits.total: 15}
- match: {aggregations.mfs.doc_count: 14}
- match: {aggregations.mfs.fields.0.count: 14}
- close_to: {aggregations.mfs.fields.0.correlation.val1: {value: 0.06838646533369998, error: 0.00000000001}}
---
"Multi value field Min":
- skip:
features: close_to
- do:
search:
rest_total_hits_as_int: true
index: test
body: {"aggs": { "mfs" : { "matrix_stats": {"fields": ["val1", "vals"], "mode" : "min"} } } }
- match: {hits.total: 15}
- match: {aggregations.mfs.doc_count: 14}
- match: {aggregations.mfs.fields.0.count: 14}
- close_to: {aggregations.mfs.fields.0.correlation.val1: {value: -0.09777682707831963, error: 0.00000000001}}
---
"Partially unmapped":
- skip:
features: close_to
- do:
search:
rest_total_hits_as_int: true
index: [test, unmapped]
body: {"aggs": { "mfs" : { "matrix_stats": {"fields": ["val1", "val2", "vals"]} } } }
- match: {hits.total: 15}
- match: {aggregations.mfs.doc_count: 13}
- match: {aggregations.mfs.fields.0.count: 13}
- close_to: {aggregations.mfs.fields.0.correlation.val1: {value: -0.044997535185684244, error: 0.00000000001}}
---
"Partially unmapped with missing defaults":
- skip:
features: close_to
- do:
search:
rest_total_hits_as_int: true
index: [test, unmapped]
body: {"aggs": { "mfs" : { "matrix_stats": {"fields": ["val1", "val2", "vals"], "missing" : {"val2" : 10, "vals" : 5 } } } } }
- match: {hits.total: 15}
- match: {aggregations.mfs.doc_count: 15}
- match: {aggregations.mfs.fields.0.count: 15}
- close_to: {aggregations.mfs.fields.0.correlation.val2: {value: 0.04028024709708195, error: 0.00000000001}}
---
"With script":
- do:
catch: /parsing_exception/
search:
rest_total_hits_as_int: true
index: test
body: {"aggs": { "mfs" : { "matrix_stats": {"fields": ["vals", "val3"], "script" : { "my_script" : {"source" : "1 + doc['val1'].value", "lang" : "js"} } } } } }
---
"With script params":
- do:
catch: /parsing_exception/
search:
rest_total_hits_as_int: true
index: test
body: {"aggs": { "mfs" : { "matrix_stats": {"fields": ["val1", "val3", "vals"], "script" : { "my_script" : {"source" : "my_var + doc['val1'].value", "params" : { "my_var" : 1 }, "lang" : "js" } } } } } }