docs-builder / Elastic.Documentation.Search.Contract
AGENTS.md25 starsChanged 19 days agoApache-2.0View on GitHub
The shared document/mapping/analysis schema consumed by two independent indexers: the docs build pipeline (Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchMarkdownExporter.cs) and essc (src/tooling/essc/). Nothing here should assume which one is calling it — that's the whole point of the project existing separately instead of living inside either. One folder per document type/concern; each document type owns its own *MappingConfig.cs and composes Common/SharedMappingConfig.cs's shared field mappings. Folder layout is concern-based but the project deliberately exposes only two namespaces — root and .Mapping — not one per folder;…
We split this AGENTS.md into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
AOT-safe polymorphism, not reflection: All document types are declared as [JsonDerivedType(typeof(X), "discriminator")] directly on …
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Elastic.Documentation.Search.Contract
The shared document/mapping/analysis schema consumed by two independent indexers: the docs
build pipeline (Elastic.Markdown/Exporters/Elasticsearch/ElasticsearchMarkdownExporter.cs) and
essc (src/tooling/essc/). Nothing here should assume which one is calling it — that's the whole
point of the project existing separately instead of living inside either.
Structure
Common/ Shared plumbing: ISearchDocument, the polymorphism wiring, mapping/analysis config
shared across document types, content-tier and synonym types.
Docs/ DocumentationDocument — docs-builder's own indexed pages.
Site/ SiteDocument — elastic.co website content.
Labs/ LabsDocument — Labs content source.
Guide/ GuideDocument — Guide content source.
WebsiteSearch/ WebsiteSearchDocument — the unified cross-source search index.
Autocomplete/ Request/response types for autocomplete, not a document type.
Search/ ISearchService and query/aggregation request/response types.One folder per document type/concern; each document type owns its own *MappingConfig.cs and
composes Common/SharedMappingConfig.cs's shared field mappings.
Folder layout is concern-based but the project deliberately exposes only two namespaces — root
and .Mapping — not one per folder; the .csproj suppresses IDE0130 (namespace-doesn't-match-
folder) for exactly this reason. Don't "fix" that warning by adding folder-matching namespaces.
Rules
AOT-safe polymorphism, not reflection. All document types are declared as
[JsonDerivedType(typeof(X), "discriminator")] directly on ISearchDocument (Common/ISearchDocument.cs)
with string discriminators ("site", "labs", "guide", "website", "docs"), and
Common/SearchDocumentPolymorphism.cs builds the equivalent config into JsonSerializerOptions for
callers that need it dynamically. Adding a document type means adding both a [JsonDerivedType]
attribute and registering it in whichever JsonSerializerContext serializes it — this project is
IsAotCompatible, and reflection-based discovery isn't an option.
Analyzer/normalizer names must match across two files, by string, not by reference.
Common/SharedMappingConfig.cs declares name constants (KeywordNormalizer = "keyword_normalizer",
StartsWithAnalyzer, HierarchyAnalyzer, SynonymsAnalyzer, ...); Common/SharedAnalysisFactory.cs
builds the actual Elasticsearch analyzer/normalizer definitions using raw string literals, not
the constants. If you rename one side, you silently break the mapping↔analysis link with no compiler
error — grep for the literal string on both sides before renaming anything here.
Schema/discriminator stability is a rule, not a preference. Both consumers reindex from these
types; an incompatible change to a document type or a discriminator value breaks one indexer without
necessarily breaking the other's build. Bump the contract version (see essc/docs-builder normalization
history) rather than changing a shipped shape in place.
Where do I put X?
| Change | Location |
| New document type for a new content source | New folder + *Document.cs + *MappingConfig.cs, register discriminator in Common/ISearchDocument.cs |
| Field shared by every document type | Common/SharedMappingConfig.cs (mapping) — keep SharedAnalysisFactory.cs in sync by string |
| New analyzer/normalizer | Common/SharedAnalysisFactory.cs, name constant in SharedMappingConfig.cs |
| Search/autocomplete request or response shape | Search/ or Autocomplete/ |
| Content-tier / synonym logic shared across sources | Common/ContentTiers.cs / Common/IndexTimeSynonyms.cs |
Related docs
docs/development/essc.md covers the operator/config side (credentials, sources, container image);
this file is the code-facing contract rules that doc doesn't repeat.
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- src/Elastic.ApiExplorer/AGENTS.mdAGENTS.md
- src/Elastic.Documentation.Site/AGENTS.mdAGENTS.md
- src/Elastic.Markdown/AGENTS.mdAGENTS.md
- commitSkill
- feature-flagSkill
- issueSkill
- lintSkill
- mcp-searchSkill
- prSkill
- style-reviewSkill
- testSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

