Supplementary reference: exact aggregation pipeline (as JSON) run by the search_attributes benchmark job on collection bench_attributes.
MongoDB compound index: bench_attributes_compound (sellerKey, attributes.key, attributes.value, inventory.quantity). Atlas Search index: bench_text. $match uses $elemMatch on attributes for each facet dimension present in FILTER_TESTS (same keys as merge_all._add_attributes).
<SELLER_KEY>— replace with thesellerKeybeing benchmarked for that row.- Atlas index name — set via environment variables documented on
mongo_bench.jobs.benchmarks.search_attributes(e.g.BENCH_ATTRIBUTES_COLLECTION,BENCH_ATLAS_SEARCH_INDEX). - Name search query — when a pipeline includes Atlas
textonproduct.name, the string comes from thetextkey in each merged benchmark case (TEST_CASES×FILTER_TESTSinbenchmark_fixtures.py), not from an environment variable. BenchmarkSession.timed(inbenchmark_session.py) appends{"$count": "c"}to the pipeline for timing and count; that stage is not shown below.
{}{
"product_line": [
"Magic The Gathering TCG"
],
"product_sets": [
"Commander Legends",
"Aetherspiral"
],
"language": [
"English"
],
"printing": [
"Normal"
]
}{
"product_line": [
"Pokémon TCG"
],
"product_sets": [
"League & Championship Cards",
"SWSH01: Sword & Shield Base Set"
],
"language": [
"English"
],
"printing": [
"Holofoil"
]
}{
"product_line": [
"Magic The Gathering TCG"
],
"rarity": [
"Common",
"Rare"
]
}{
"product_line": [
"Magic The Gathering TCG"
],
"language": [
"English",
"Japanese"
],
"printing": [
"Normal"
]
}{
"product_line": [
"Magic The Gathering TCG"
]
}{
"product_line": [
"Magic The Gathering TCG"
],
"quantity_min": 10
}{
"product_line": [
"Warhammer Age of Sigmar Champions TCG"
]
}Same $search shape as search_index (different collection / index definitions in bench_collections.json).
[
{
"$search": {
"index": "bench_text",
"compound": {
"filter": [
{
"equals": {
"path": "sellerKey",
"value": "<SELLER_KEY>"
}
}
],
"must": [
{
"text": {
"path": "product.name",
"query": "Dragon"
}
}
]
}
}
}
][
{
"$match": {
"sellerKey": "<SELLER_KEY>"
}
}
][
{
"$search": {
"index": "bench_text",
"compound": {
"filter": [
{
"equals": {
"path": "sellerKey",
"value": "<SELLER_KEY>"
}
}
],
"must": [
{
"text": {
"path": "product.name",
"query": "Dragon"
}
}
]
}
}
},
{
"$match": {
"sellerKey": "<SELLER_KEY>"
}
}
][
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "set",
"value": {
"$in": [
"Commander Legends",
"Aetherspiral"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "language",
"value": {
"$in": [
"English"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "printing",
"value": {
"$in": [
"Normal"
]
}
}
}
}
]
}
}
][
{
"$search": {
"index": "bench_text",
"compound": {
"filter": [
{
"equals": {
"path": "sellerKey",
"value": "<SELLER_KEY>"
}
}
],
"must": [
{
"text": {
"path": "product.name",
"query": "Dragon"
}
}
]
}
}
},
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "set",
"value": {
"$in": [
"Commander Legends",
"Aetherspiral"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "language",
"value": {
"$in": [
"English"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "printing",
"value": {
"$in": [
"Normal"
]
}
}
}
}
]
}
}
][
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Pokémon TCG"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "set",
"value": {
"$in": [
"League & Championship Cards",
"SWSH01: Sword & Shield Base Set"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "language",
"value": {
"$in": [
"English"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "printing",
"value": {
"$in": [
"Holofoil"
]
}
}
}
}
]
}
}
][
{
"$search": {
"index": "bench_text",
"compound": {
"filter": [
{
"equals": {
"path": "sellerKey",
"value": "<SELLER_KEY>"
}
}
],
"must": [
{
"text": {
"path": "product.name",
"query": "Dragon"
}
}
]
}
}
},
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Pokémon TCG"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "set",
"value": {
"$in": [
"League & Championship Cards",
"SWSH01: Sword & Shield Base Set"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "language",
"value": {
"$in": [
"English"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "printing",
"value": {
"$in": [
"Holofoil"
]
}
}
}
}
]
}
}
][
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "rarity",
"value": {
"$in": [
"Common",
"Rare"
]
}
}
}
}
]
}
}
][
{
"$search": {
"index": "bench_text",
"compound": {
"filter": [
{
"equals": {
"path": "sellerKey",
"value": "<SELLER_KEY>"
}
}
],
"must": [
{
"text": {
"path": "product.name",
"query": "Dragon"
}
}
]
}
}
},
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "rarity",
"value": {
"$in": [
"Common",
"Rare"
]
}
}
}
}
]
}
}
][
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "language",
"value": {
"$in": [
"English",
"Japanese"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "printing",
"value": {
"$in": [
"Normal"
]
}
}
}
}
]
}
}
][
{
"$search": {
"index": "bench_text",
"compound": {
"filter": [
{
"equals": {
"path": "sellerKey",
"value": "<SELLER_KEY>"
}
}
],
"must": [
{
"text": {
"path": "product.name",
"query": "Dragon"
}
}
]
}
}
},
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "language",
"value": {
"$in": [
"English",
"Japanese"
]
}
}
}
},
{
"attributes": {
"$elemMatch": {
"key": "printing",
"value": {
"$in": [
"Normal"
]
}
}
}
}
]
}
}
][
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
}
]
}
}
][
{
"$search": {
"index": "bench_text",
"compound": {
"filter": [
{
"equals": {
"path": "sellerKey",
"value": "<SELLER_KEY>"
}
}
],
"must": [
{
"text": {
"path": "product.name",
"query": "Dragon"
}
}
]
}
}
},
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
}
]
}
}
][
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
},
{
"inventory.quantity": {
"$gte": 10
}
}
]
}
}
][
{
"$search": {
"index": "bench_text",
"compound": {
"filter": [
{
"equals": {
"path": "sellerKey",
"value": "<SELLER_KEY>"
}
}
],
"must": [
{
"text": {
"path": "product.name",
"query": "Dragon"
}
}
]
}
}
},
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Magic The Gathering TCG"
]
}
}
}
},
{
"inventory.quantity": {
"$gte": 10
}
}
]
}
}
][
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Warhammer Age of Sigmar Champions TCG"
]
}
}
}
}
]
}
}
][
{
"$search": {
"index": "bench_text",
"compound": {
"filter": [
{
"equals": {
"path": "sellerKey",
"value": "<SELLER_KEY>"
}
}
],
"must": [
{
"text": {
"path": "product.name",
"query": "Dragon"
}
}
]
}
}
},
{
"$match": {
"$and": [
{
"sellerKey": "<SELLER_KEY>"
},
{
"attributes": {
"$elemMatch": {
"key": "productLine",
"value": {
"$in": [
"Warhammer Age of Sigmar Champions TCG"
]
}
}
}
}
]
}
}
]