Elasticsearch / Intermediate: models, pipelines and relevance evidence / Lesson 14
Investigate field capabilities across indices
Find incompatible field definitions before searching or aggregating across multiple indices.
On this page
Lesson goals
- Explain field type and capability differences across targets.
- Inspect field capabilities and mappings in a disposable fixture.
- Plan a compatible migration and verify the application query.
Define the multi-index contract
A search spanning several indices can encounter the same field name with different types or capabilities. A dashboard may work on a new index but fail when an older index is included. Define what the field means, which indices or aliases the application targets, and whether it must be searchable, sortable, or aggregatable. Similar names do not prove compatible mappings or equivalent business semantics.
Create incompatible lab mappings
The following requests create two new synthetic indices in an isolated Elasticsearch 8.19 lab. One maps code as keyword and the other as long. They are intentionally different and contain no real documents. Never create these lab names on a configured cluster. Exact API responses, authorization, and deployment capabilities depend on the environment.
PUT /lab-catalog-a
{ "mappings": { "properties": { "code": { "type": "keyword" } } } }
PUT /lab-catalog-b
{ "mappings": { "properties": { "code": { "type": "long" } } } }
The two code fields have incompatible type families for a shared field contract. The example illustrates a mapping difference; it does not claim that any particular dashboard or query was executed.
Compare capabilities and definitions
Field capabilities summarizes properties such as type family, searchability, and aggregatability across the requested targets. Mapping inspection supplies the underlying definitions. Use both pieces of evidence to locate the differing indices and compare them with the intended application query. Responses can include index-specific details; the examples below are read-only and do not change mappings.
GET /lab-catalog-a,lab-catalog-b/_field_caps?fields=code
GET /lab-catalog-a,lab-catalog-b/_mapping
The field-capabilities request asks about code across both lab indices; the mapping request exposes each definition. Actual response structure and privileges depend on the deployed version. No output is asserted.
Plan a compatible target
An existing field type generally cannot be changed in place to an incompatible type. Design a new target mapping and an approved reindex or data transformation when needed, including malformed values, concurrent writes, aliases, and rollback or forward repair. Validate representative documents and business meaning before switching consumers. Restricting an index pattern can be a temporary diagnostic, but it can also omit required data.
Test the full search scope
In the isolated lab, compare field capabilities before and after the planned migration, then run the applicationโs representative filter, sort, and aggregation where applicable. Verify result counts and expected documents across the full intended index range. Test old and new client versions during cutover and inspect individual reindex failures. A field that is technically aggregatable is not automatically semantically comparable across historical data.
Common errors and fixes
A cross-index aggregation fails or behaves inconsistently.
- Why it happens
- The same field name has incompatible mappings or capabilities.
- How to fix it
- Inspect field capabilities and mappings, then plan a compatible target.
- Prevent it next time
- Validate templates and mappings before new index creation.
A dashboard appears fixed but misses history.
- Why it happens
- The target pattern was narrowed without checking required data.
- How to fix it
- Reconcile the intended index range and restore compatible coverage.
- Prevent it next time
- Test expected documents across old and new indices.
A migration loses concurrent updates.
- Why it happens
- The reindex and alias cutover plan omitted writes during copying.
- How to fix it
- Follow a documented reconciliation or forward-repair procedure.
- Prevent it next time
- Rehearse concurrent writes and cutover on isolated data.
2 practice exercises
1. How is code mapped in each lab index?
Show worked solution
lab-catalog-a maps code as keyword, while lab-catalog-b maps code as long. A shared application contract must resolve that difference before relying on the same field across both.
2. Does a successful field-capabilities response prove that historical values have the same business meaning?
Show worked solution
No. It reports technical field properties. Inspect representative source data and the application contract as well.
Key takeaways
- Field names alone do not guarantee cross-index compatibility.
- Compare field capabilities with the actual mappings and data.
- Rehearse reindexing, concurrent writes, and cutover before migration.