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_1
body:
settings:
number_of_shards: 1
mappings:
properties:
str:
type: keyword
number:
type: integer
- do:
bulk:
index: test_1
refresh: true
body:
- '{"index": {}}'
- '{"_doc_count": 10, "str": "abc", "number" : 500, "unmapped": "abc" }'
- '{"index": {}}'
- '{"_doc_count": 5, "str": "xyz", "number" : 100, "unmapped": "xyz" }'
- '{"index": {}}'
- '{"_doc_count": 7, "str": "foo", "number" : 100, "unmapped": "foo" }'
- '{"index": {}}'
- '{"_doc_count": 1, "str": "foo", "number" : 200, "unmapped": "foo" }'
- '{"index": {}}'
- '{"str": "abc", "number" : 500, "unmapped": "abc" }'
---
"Test numeric terms agg with doc_count":
- requires:
cluster_features: ["gte_v7.11.0"]
reason: "doc_count field has been added in 7.11"
- do:
search:
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" : { "num_terms" : { "terms" : { "field" : "number" } } } }
- match: { hits.total: 5 }
- length: { aggregations.num_terms.buckets: 3 }
- match: { aggregations.num_terms.buckets.0.key: 100 }
- match: { aggregations.num_terms.buckets.0.doc_count: 12 }
- match: { aggregations.num_terms.buckets.1.key: 500 }
- match: { aggregations.num_terms.buckets.1.doc_count: 11 }
- match: { aggregations.num_terms.buckets.2.key: 200 }
- match: { aggregations.num_terms.buckets.2.doc_count: 1 }
---
"Test keyword terms agg with doc_count":
- requires:
cluster_features: ["gte_v7.11.0"]
reason: "doc_count field has been added in 7.11"
- do:
search:
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" : { "str_terms" : { "terms" : { "field" : "str" } } } }
- match: { hits.total: 5 }
- length: { aggregations.str_terms.buckets: 3 }
- match: { aggregations.str_terms.buckets.0.key: "abc" }
- match: { aggregations.str_terms.buckets.0.doc_count: 11 }
- match: { aggregations.str_terms.buckets.1.key: "foo" }
- match: { aggregations.str_terms.buckets.1.doc_count: 8 }
- match: { aggregations.str_terms.buckets.2.key: "xyz" }
- match: { aggregations.str_terms.buckets.2.doc_count: 5 }
---
"Test unmapped string terms agg with doc_count":
- requires:
cluster_features: ["gte_v7.11.0"]
reason: "doc_count field has been added in 7.11"
- do:
bulk:
index: test_2
refresh: true
body:
- '{"index": {}}'
- '{"_doc_count": 10, "str": "abc" }'
- '{"index": {}}'
- '{"str": "abc" }'
- do:
search:
index: test_2
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" : { "str_terms" : { "terms" : { "field" : "str.keyword" } } } }
- match: { hits.total: 2 }
- length: { aggregations.str_terms.buckets: 1 }
- match: { aggregations.str_terms.buckets.0.key: "abc" }
- match: { aggregations.str_terms.buckets.0.doc_count: 11 }
---
"Test composite str_terms agg with doc_count":
- requires:
cluster_features: ["gte_v7.11.0"]
reason: "doc_count field has been added in 7.11"
- do:
search:
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" :
{ "composite_agg" : { "composite" :
{
"sources": ["str_terms": { "terms": { "field": "str" } }]
}
}
}
}
- match: { hits.total: 5 }
- length: { aggregations.composite_agg.buckets: 3 }
- match: { aggregations.composite_agg.buckets.0.key.str_terms: "abc" }
- match: { aggregations.composite_agg.buckets.0.doc_count: 11 }
- match: { aggregations.composite_agg.buckets.1.key.str_terms: "foo" }
- match: { aggregations.composite_agg.buckets.1.doc_count: 8 }
- match: { aggregations.composite_agg.buckets.2.key.str_terms: "xyz" }
- match: { aggregations.composite_agg.buckets.2.doc_count: 5 }
---
"Test composite num_terms agg with doc_count":
- requires:
cluster_features: ["gte_v7.11.0"]
reason: "doc_count field has been added in 7.11"
- do:
search:
rest_total_hits_as_int: true
body: { "size" : 0, "aggs" :
{ "composite_agg" :
{ "composite" :
{
"sources": ["num_terms" : { "terms" : { "field" : "number" } }]
}
}
}
}
- match: { hits.total: 5 }
- length: { aggregations.composite_agg.buckets: 3 }
- match: { aggregations.composite_agg.buckets.0.key.num_terms: 100 }
- match: { aggregations.composite_agg.buckets.0.doc_count: 12 }
- match: { aggregations.composite_agg.buckets.1.key.num_terms: 200 }
- match: { aggregations.composite_agg.buckets.1.doc_count: 1 }
- match: { aggregations.composite_agg.buckets.2.key.num_terms: 500 }
- match: { aggregations.composite_agg.buckets.2.doc_count: 11 }
---
"Single bucket filters agg with doc_count":
- requires:
cluster_features: ["gte_v8.0.0"]
reason: implementation change in 8.0
test_runner_features: default_shards
- do:
search:
body:
profile: true
size: 0
aggs:
f:
filters:
filters:
abc:
match:
str: abc
- match: { hits.total.value: 5 }
- length: { aggregations.f.buckets: 1 }
- match: { aggregations.f.buckets.abc.doc_count: 11 }
- match: { profile.shards.0.aggregations.0.type: FilterByFilterAggregator }
# We can't assert that segments_with_doc_count_field is > 0 because we might
# end up with two shards and all of the documents with the _doc_count field
# may be on one field. We have a test for this in AggregationProfilerIT
# and here we'd prefer to have two shards to make sure that works.
---
"Filters agg with doc_count":
- requires:
cluster_features: ["gte_v8.3.0"]
reason: implementation changed when there is more than one bucket 8.3.0
test_runner_features: default_shards
- do:
search:
body:
profile: true
size: 0
aggs:
f:
filters:
filters:
abc:
match:
str: abc
foo:
match:
str: foo
xyz:
match:
str: xyz
- match: { hits.total.value: 5 }
- length: { aggregations.f.buckets: 3 }
- match: { aggregations.f.buckets.abc.doc_count: 11 }
- match: { aggregations.f.buckets.foo.doc_count: 8 }
- match: { aggregations.f.buckets.xyz.doc_count: 5 }
- match: { profile.shards.0.aggregations.0.type: FiltersAggregator.Compatible }
# We can't assert that segments_with_doc_count_field is > 0 because we might
# end up with two shards and all of the documents with the _doc_count field
# may be on one field. We have a test for this in AggregationProfilerIT
# and here we'd prefer to have two shards to make sure that works.