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:
double:
type: double
long:
type: long
float:
type: float
half_float:
type: half_float
- do:
indices.create:
index: date_range_test
body:
mappings:
properties:
date:
type: date
format: strict_date_time||strict_date
- do:
indices.create:
index: long_value_test
body:
mappings:
properties:
long:
type: long
- do:
bulk:
index: test
refresh: true
body:
- {"index": {}}
- { "double" : 42.1, "long": 25, "float": 0.01, "half_float": 0.01 }
- {"index": {}}
- { "double" : 100.7, "long": 80, "float": 0.03, "half_float": 0.0152 }
- {"index": {}}
- { "double" : 50.5, "long": 75, "float": 0.04, "half_float": 0.04 }
# For testing missing values
- {"index": {}}
- {}
- do:
bulk:
index: long_value_test
refresh: true
body:
- { "index": { } }
- { "long": -9223372036854775808 }
- do:
bulk:
index: date_range_test
refresh: true
body:
- { "index": { } }
- { "date": "2021-05-01T07:10:00Z" }
- { "index": { } }
- { "date": "2021-05-02T08:34:00Z" }
- { "index": { } }
- { "date": "2021-05-03T08:36:00Z" }
- { "index": { } }
- { "date": "2021-05-04T09:05:00Z" }
- { "index": { } }
- { "date": "2021-05-06T09:22:00Z" }
---
"Float Endpoint Exclusive":
- requires:
cluster_features: ["gte_v7.16.0"]
reason: Bug fixed in 7.16.0
- do:
search:
index: test
body:
size: 0
aggs:
double_range:
range:
format: "0.0#"
field: "float"
ranges:
-
from: 0
to: 0.04
- from: 0.04
to: 1.0
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.double_range.buckets: 2 }
- match: { aggregations.double_range.buckets.0.key: "0.0-0.04" }
- match: { aggregations.double_range.buckets.0.doc_count: 2 }
- match: { aggregations.double_range.buckets.1.key: "0.04-1.0" }
- match: { aggregations.double_range.buckets.1.doc_count: 1 }
---
"Half Float Endpoint Exclusive":
- requires:
cluster_features: ["gte_v7.16.0"]
reason: Bug fixed in 7.16.0
- do:
search:
index: test
body:
size: 0
aggs:
double_range:
range:
format: "0.0###"
field: "half_float"
ranges:
-
from: 0
to: 0.0152
- from: 0.0152
to: 1.0
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.double_range.buckets: 2 }
- match: { aggregations.double_range.buckets.0.key: "0.0-0.0152" }
- match: { aggregations.double_range.buckets.0.doc_count: 1 }
- match: { aggregations.double_range.buckets.1.key: "0.0152-1.0" }
- match: { aggregations.double_range.buckets.1.doc_count: 2 }
---
"Float range":
- requires:
cluster_features: ["gte_v7.17.1"]
reason: Bug fixed in 8.1.0 and backported to 7.17.1
- do:
search:
index: test
body:
size: 0
aggs:
float_range:
range:
field: "float"
ranges:
-
to: 6.0
-
from: 6.0
to: 10.6
-
from: 10.6
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.float_range.buckets: 3 }
- match: { aggregations.float_range.buckets.0.key: "*-6.0" }
- is_false: aggregations.float_range.buckets.0.from
- match: { aggregations.float_range.buckets.0.to: 6.0 }
- match: { aggregations.float_range.buckets.0.doc_count: 3 }
- match: { aggregations.float_range.buckets.1.key: "6.0-10.6" }
- match: { aggregations.float_range.buckets.1.from: 6.0 }
- match: { aggregations.float_range.buckets.1.to: 10.6 }
- match: { aggregations.float_range.buckets.1.doc_count: 0 }
- match: { aggregations.float_range.buckets.2.key: "10.6-*" }
- match: { aggregations.float_range.buckets.2.from: 10.6 }
- is_false: aggregations.float_range.buckets.2.to
- match: { aggregations.float_range.buckets.2.doc_count: 0 }
---
"Double range":
- requires:
cluster_features: ["gte_v7.17.0"]
reason: Bug fixed in 8.1.0 and backported to 7.17.0
- do:
search:
index: test
body:
size: 0
aggs:
float_range:
range:
field: "double"
ranges:
-
to: 6.0
-
from: 6.0
to: 10.6
-
from: 10.6
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.float_range.buckets: 3 }
- match: { aggregations.float_range.buckets.0.key: "*-6.0" }
- is_false: aggregations.float_range.buckets.0.from
- match: { aggregations.float_range.buckets.0.to: 6.0 }
- match: { aggregations.float_range.buckets.0.doc_count: 0 }
- match: { aggregations.float_range.buckets.1.key: "6.0-10.6" }
- match: { aggregations.float_range.buckets.1.from: 6.0 }
- match: { aggregations.float_range.buckets.1.to: 10.6 }
- match: { aggregations.float_range.buckets.1.doc_count: 0 }
- match: { aggregations.float_range.buckets.2.key: "10.6-*" }
- match: { aggregations.float_range.buckets.2.from: 10.6 }
- is_false: aggregations.float_range.buckets.2.to
- match: { aggregations.float_range.buckets.2.doc_count: 3 }
---
"Double range on long field":
- requires:
cluster_features: ["gte_v8.1.0"]
reason: Bug fixed in 8.1.0
- do:
search:
index: test
body:
size: 0
aggs:
double_range:
range:
field: "long"
ranges:
-
to: 24.9
-
from: 24.9
to: 79.9
-
from: 79.9
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.double_range.buckets: 3 }
- match: { aggregations.double_range.buckets.0.key: "*-24.9" }
- is_false: aggregations.double_range.buckets.0.from
- match: { aggregations.double_range.buckets.0.to: 24.9 }
- match: { aggregations.double_range.buckets.0.doc_count: 0 }
- match: { aggregations.double_range.buckets.1.key: "24.9-79.9" }
- match: { aggregations.double_range.buckets.1.from: 24.9 }
- match: { aggregations.double_range.buckets.1.to: 79.9 }
- match: { aggregations.double_range.buckets.1.doc_count: 2 }
- match: { aggregations.double_range.buckets.2.key: "79.9-*" }
- match: { aggregations.double_range.buckets.2.from: 79.9 }
- is_false: aggregations.double_range.buckets.2.to
- match: { aggregations.double_range.buckets.2.doc_count: 1 }
---
"Double range no decimal":
- do:
search:
index: test
body:
size: 0
aggs:
double_range:
range:
field: "double"
ranges:
-
to: 50
-
from: 50
to: 150
-
from: 150
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.double_range.buckets: 3 }
- match: { aggregations.double_range.buckets.0.key: "*-50.0" }
- is_false: aggregations.double_range.buckets.0.from
- match: { aggregations.double_range.buckets.0.to: 50.0 }
- match: { aggregations.double_range.buckets.0.doc_count: 1 }
- match: { aggregations.double_range.buckets.1.key: "50.0-150.0" }
- match: { aggregations.double_range.buckets.1.from: 50.0 }
- match: { aggregations.double_range.buckets.1.to: 150.0 }
- match: { aggregations.double_range.buckets.1.doc_count: 2 }
- match: { aggregations.double_range.buckets.2.key: "150.0-*" }
- match: { aggregations.double_range.buckets.2.from: 150.0 }
- is_false: aggregations.double_range.buckets.2.to
- match: { aggregations.double_range.buckets.2.doc_count: 0 }
---
"Double range with missing value":
- do:
search:
index: test
body:
size: 0
aggs:
double_range:
range:
field: "double"
missing: 1000
ranges:
-
to: 50
-
from: 50
to: 150
-
from: 150
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.double_range.buckets: 3 }
- match: { aggregations.double_range.buckets.0.key: "*-50.0" }
- is_false: aggregations.double_range.buckets.0.from
- match: { aggregations.double_range.buckets.0.to: 50.0 }
- match: { aggregations.double_range.buckets.0.doc_count: 1 }
- match: { aggregations.double_range.buckets.1.key: "50.0-150.0" }
- match: { aggregations.double_range.buckets.1.from: 50.0 }
- match: { aggregations.double_range.buckets.1.to: 150.0 }
- match: { aggregations.double_range.buckets.1.doc_count: 2 }
- match: { aggregations.double_range.buckets.2.key: "150.0-*" }
- match: { aggregations.double_range.buckets.2.from: 150.0 }
- is_false: aggregations.double_range.buckets.2.to
- match: { aggregations.double_range.buckets.2.doc_count: 1 }
---
"Null to and from":
- do:
search:
index: test
body:
size: 0
aggs:
double_range:
range:
field: "double"
ranges:
-
from: null
to: 50
-
from: 50
to: 150
-
from: 150
to: null
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.double_range.buckets: 3 }
- match: { aggregations.double_range.buckets.0.key: "*-50.0" }
- is_false: aggregations.double_range.buckets.0.from
- match: { aggregations.double_range.buckets.0.to: 50.0 }
- match: { aggregations.double_range.buckets.0.doc_count: 1 }
- match: { aggregations.double_range.buckets.1.key: "50.0-150.0" }
- match: { aggregations.double_range.buckets.1.from: 50.0 }
- match: { aggregations.double_range.buckets.1.to: 150.0 }
- match: { aggregations.double_range.buckets.1.doc_count: 2 }
- match: { aggregations.double_range.buckets.2.key: "150.0-*" }
- match: { aggregations.double_range.buckets.2.from: 150.0 }
- is_false: aggregations.double_range.buckets.2.to
- match: { aggregations.double_range.buckets.2.doc_count: 0 }
---
"Range agg on long field":
- do:
search:
index: test
body:
size: 0
aggs:
long_range:
range:
field: "long"
ranges:
-
to: 50
-
from: 50
to: 150
-
from: 150
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.long_range.buckets: 3 }
- match: { aggregations.long_range.buckets.0.key: "*-50.0" }
- is_false: aggregations.long_range.buckets.0.from
- match: { aggregations.long_range.buckets.0.to: 50 }
- match: { aggregations.long_range.buckets.0.doc_count: 1 }
- match: { aggregations.long_range.buckets.1.key: "50.0-150.0" }
- match: { aggregations.long_range.buckets.1.from: 50 }
- match: { aggregations.long_range.buckets.1.to: 150 }
- match: { aggregations.long_range.buckets.1.doc_count: 2 }
- match: { aggregations.long_range.buckets.2.key: "150.0-*" }
- match: { aggregations.long_range.buckets.2.from: 150 }
- is_false: aggregations.long_range.buckets.2.to
- match: { aggregations.long_range.buckets.2.doc_count: 0 }
---
"Double range default keyed response":
- do:
search:
index: test
body:
size: 0
aggs:
double_range:
range:
field: "double"
keyed: true
ranges:
-
key: "first"
to: 50
-
key: "another"
from: 50
to: 150
-
key: "last"
from: 150
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 4 }
- length: { aggregations.double_range.buckets: 3 }
- is_false: aggregations.double_range.buckets.first.from
- match: { aggregations.double_range.buckets.first.to: 50.0 }
- match: { aggregations.double_range.buckets.first.doc_count: 1 }
- match: { aggregations.double_range.buckets.another.from: 50.0 }
- match: { aggregations.double_range.buckets.another.to: 150.0 }
- match: { aggregations.double_range.buckets.another.doc_count: 2 }
- match: { aggregations.double_range.buckets.last.from: 150.0 }
- is_false: aggregations.double_range.buckets.last.to
- match: { aggregations.double_range.buckets.last.doc_count: 0 }
---
"Range aggregation on date field":
- requires:
cluster_features: ["gte_v7.17.0"]
reason: Fixed in 8.1.0 and backported to 7.17.0
- do:
search:
index: date_range_test
body:
size: 0
aggs:
date_range:
range:
field: date
ranges:
-
from: 2021-05-01T00:00:00Z
to: 2021-05-05T00:00:00Z
- match: { hits.total.value: 5 }
- length: { aggregations.date_range.buckets: 1 }
- match: { aggregations.date_range.buckets.0.doc_count: 4 }
- match: { aggregations.date_range.buckets.0.key: "2021-05-01T00:00:00.000Z-2021-05-05T00:00:00.000Z" }
- match: { aggregations.date_range.buckets.0.from: 1619827200000 }
- match: { aggregations.date_range.buckets.0.from_as_string: "2021-05-01T00:00:00.000Z" }
- match: { aggregations.date_range.buckets.0.to: 1620172800000 }
- match: { aggregations.date_range.buckets.0.to_as_string: "2021-05-05T00:00:00.000Z" }
---
"Min and max long range bounds":
- requires:
cluster_features: ["gte_v8.1.0"]
reason: Bug fixed in 8.1.0
- do:
search:
index: long_value_test
body:
size: 0
aggs:
long_range:
range:
field: "long"
ranges:
-
from: -9223372036854775808
to: 9223372036854775807
- match: { hits.total.relation: "eq" }
- match: { hits.total.value: 1 }
- length: { aggregations.long_range.buckets: 1 }
- match: { aggregations.long_range.buckets.0.key: "-9.223372036854776E18-9.223372036854776E18" }
- match: { aggregations.long_range.buckets.0.from: -9.223372036854776E18 }
- match: { aggregations.long_range.buckets.0.to: 9.223372036854776E18 }
- match: { aggregations.long_range.buckets.0.doc_count: 1 }