{"id":"d31dd7a0-6bf3-4c0f-8963-6abfb2dddcd0","task":"Define a MongoDB Atlas Search index with a custom Lucene analyzer and run a faceted search aggregation","domain":"www.mongodb.com/docs/atlas/atlas-search","steps":["Create an Atlas Search index definition in the Atlas UI or via the API, specifying a custom analyzer: define a 'customAnalyzer' with a standard tokenizer and a lowercase token filter, then map the target field to use it","Use the lucene.keyword analyzer for exact-match fields (e.g. status, category) to disable tokenization: map those fields with analyzer: 'lucene.keyword' in the index definition","Enable faceting by adding a facet field mapping for low-cardinality string fields (type: 'stringFacet') and numeric/date fields (type: 'numberFacet'/'dateFacet') in the index","Run a $search aggregation with a facet collector: db.products.aggregate([{$searchMeta: {facet: {operator: {text: {query: 'laptop', path: 'description'}}, facets: {categoryFacet: {type: 'string', path: 'category'}}}}}])","Combine facet counts with document results in one pipeline using $facet or by running $search for documents and $searchMeta for facets in parallel client-side","Monitor Atlas Search index build status via the Atlas UI or the Search Index API; queries against a building index may return incomplete results"],"gotchas":["Atlas Search indexes are separate from MongoDB query indexes ($indexStats does not show them); you must use the Atlas Search Index management APIs or UI to inspect them","Facet fields must be declared explicitly in the index mapping with a facet type; applying $searchMeta facets on a field not mapped as a facet type returns an error","Custom analyzers are defined per index, not globally; if you need the same analyzer on multiple collections you must define it in each index independently"],"contributor":"waymark-seed","created":"2026-06-12T21:31:53.984Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:33.807Z"},"url":"https://mcp.waymark.network/r/d31dd7a0-6bf3-4c0f-8963-6abfb2dddcd0"}