{"service":"epistery-scan query","summary":"Run a read-only MongoDB aggregation pipeline over the signed-web index and get back results with their origin facts.","collection":"entities","how":{"GET":"http://epistery.com/scan/api/query?pipeline=<url-encoded JSON array>&limit=50","POST":"http://epistery.com/scan/api/query  with JSON body { \"pipeline\": [ ...stages ], \"limit\": 50 }","accept":"application/json"},"rules":{"readOnly":"The pipeline may only read. Writes ($out, $merge), cross-collection joins ($lookup, $graphLookup, $unionWith), sub-pipeline fan-out ($facet), server introspection and Atlas search stages are refused — only the allowed stages below run.","allowedStages":["$match","$project","$addFields","$set","$unset","$group","$sortByCount","$bucket","$bucketAuto","$count","$sort","$limit","$skip","$unwind","$sample","$replaceRoot","$replaceWith"],"refusedAnywhere":["$where","$function","$accumulator"],"textSearch":"A full-text narrow is allowed and fast as the FIRST stage: `{ $match: { $text: { $search: \"...\" } } }` rides the index over titles, keywords and summaries. Plain words are ORed (broad — a following $group over the whole match set can exceed the time budget); wrap a \"phrase\" in quotes to narrow to an exact match before you aggregate.","limits":{"maxStages":24,"maxResults":200,"defaultResults":50,"maxTimeMS":5000}},"fields":{"note":"Each document is an indexed entity. Common fields to match and group on:","type":"one of AIDiscovery (a signed domain), AppIdentity, Object (an imported signed object — campaign, vehicle, fuel price, …), or an on-chain type (IdentityContract, CampaignWallet, Contract, Wallet).","address":"the entity address or source-prefixed object id (lowercased).","chain":"the chain slug for on-chain entities.","metadata.object.type":"the declared object type (e.g. Campaign, Vehicle, GasStation).","metadata.object.schema":"the public schema IRI; its map is at /api/schema/{name}.","metadata.source.name":"the data source an imported object came from.","metadata.source.domain":"the publishing domain.","metadata.signals":"observed posture signals (contractExists, domainBinding, dnsVerified, selfSigned), each { present, at }."},"results":{"shape":"Rows come back as your pipeline shaped them. A row that is a whole entity also carries `present` — the fixed present.ai envelope with the locator to the live signed origin and the origin facts (schema at /api/schema). Pull the locator and verify the origin yourself (PullOnHit).","visibility":"This is the same index the public search serves, held to the same policy: a domain that has delisted itself (its own VISIBILITY directive) or gone dark is pruned BEFORE your pipeline runs, so it never appears in a row or a $group count. This query surface is the service, not a back door around that."},"examples":[{"description":"Which dealers list a given truck model, how many each, and how fresh their signed inventory is. The point is trust, not the count: narrow with a PHRASE (\"Ford F-750\" — quoted, so the text index returns an exact match instead of OR-ing the words across the whole index), then group — and every number traces to a signed object you fetch and verify at `verifyOne`, with no aggregator standing in the middle claiming it.","pipeline":[{"$match":{"$text":{"$search":"\"Ford F-750\""}}},{"$group":{"_id":"$metadata.object.jsonld.offers.seller.name","listings":{"$sum":1},"freshestSignedAt":{"$max":"$_modified"},"origin":{"$first":"$metadata.source.domain"},"verifyOne":{"$first":"$metadata.source.url"}}},{"$sort":{"listings":-1}}]},{"description":"The listings themselves — each result carries `present` (the present.ai envelope): a locator to the dealer's own page and the origin facts. Note rung is often \"open\" here — these are harvested, not yet signed by the dealer, and scan does not overclaim; the locator is how you verify at the source.","pipeline":[{"$match":{"$text":{"$search":"\"Ford F-750\""}}},{"$limit":10}]}],"pricing":"Free and unmetered during evaluation. A flat per-query toll drawn on a presented identity is planned once usage shows the surface is worth pricing."}