You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] PPL cannot properly handle fields with mixed keyword and text data types across multiple indices #4659
What is the bug?
PPL cannot properly handle fields with mixed keyword and text data types across multiple indices. Currently, when PPL merges field types, it randomly selects one. For example, if the msg field is mapped as both text and keyword across indices, PPL may select keyword. As a result, when PPL attempts to fetch the msg value from doc_values on each shard, it will return null for documents where msg is defined as a text field, since text fields do not have doc_values.
How can one reproduce the bug?
Prepare dataset, create 2 indices, msg field type is Text in index1, and keyword in index2.
changed the title [-][BUG] PPL can not properly handle field has keyword / text data type accross mulitple index[/-][+][BUG] PPL cannot properly handle fields with mixed keyword and text data types across multiple indices[/+]on Oct 24, 2025
The issue arises when executing PPL queries against wildcard indices with conflicting field mappings:
POST {{baseUrl}}/_plugins/_ppl/
Content-Type: application/x-ndjson
{
"query": "source=log* | rex field=msg 'status=(?<statusCode>\\d+)' | where statusCode=200"
}
Expected Result: Multiple matching documents across indicesActual Result: Limited results due to silenced shard failures:
{
"datarows": [
[
"status=200",
2,
"200"
]
]
}
By default, OpenSearch silences partial shard failures and returns available results. To expose the underlying errors, disable partial results:
When querying wildcard indices, OpenSearch merges field mappings from all matching indices. The critical issue: when field types conflict, the selection is non-deterministic due to random ordering of the index mapping list. Code Link
Impact: A field may be treated as int or keyword randomly, depending on which index mapping is processed last
Calcite Script Engine Optimization Conflict
The Calcite script engine optimizes text field performance by treating them as keywords when multifields are present, accessing doc_values for better performance. Code Link
Problem: When the merged mapping indicates keyword type but an index actually has text-only fields, doc_values access fails.
The Problem: Even though both indices define body as text, the presence of multifields in logs-1 causes intermittent failures. During mapping merge:
If logs-1 mapping is selected → Script engine assumes keyword type available
Script engine attempts doc_values access for performance
When processing logs-2 documents → Failure occurs (no keyword field/doc_values)
Action Items apart from bug fix
Run Integration Tests (ITS) with search.default_allow_partial_results=false to uncover any existing partial shard failure scenarios across the codebase
Short-term solution: Implement a fast-fail mechanism when incompatible field index types are detected (e.g., keyword vs. text).
Long-term solution:
Option 1: Enable PPL to execute the query plan on each shard independently. This allows PPL to tolerate incompatible field index types across indices. For example, in an expression like REX(field=msg, 'status=(?\d+)'), PPL can generate a docValues fetch operation on shards where the field type is keyword, and a _source fetch operation on shards where the field type is text.
Activity
[-][BUG] PPL can not properly handle field has keyword / text data type accross mulitple index[/-][+][BUG] PPL cannot properly handle fields with mixed keyword and text data types across multiple indices[/+]vamsimanohar commentedon Oct 24, 2025
Additional Analysis and Information
The issue arises when executing PPL queries against wildcard indices with conflicting field mappings:
Expected Result: Multiple matching documents across indicesActual Result: Limited results due to silenced shard failures:
By default, OpenSearch silences partial shard failures and returns available results. To expose the underlying errors, disable partial results:
Root Cause Analysis
When querying wildcard indices, OpenSearch merges field mappings from all matching indices. The critical issue: when field types conflict, the selection is non-deterministic due to random ordering of the index mapping list. Code Link
The Calcite script engine optimizes text field performance by treating them as keywords when multifields are present, accessing doc_values for better performance. Code Link
Problem: When the merged mapping indicates keyword type but an index actually has text-only fields, doc_values access fails.
Concrete Example
The Problem: Even though both indices define body as text, the presence of multifields in logs-1 causes intermittent failures. During mapping merge:
Action Items apart from bug fix
xinyual commentedon Oct 27, 2025
I will look into it.
LantaoJin commentedon Oct 27, 2025
@penghuo have any conclusion on this? do we need more discussions?
penghuo commentedon Nov 5, 2025
Add text/keyword merge rule for cross-index type conflicts (opensearc…
[BugFix] Fix PPL mixed text/keyword field type across wildcard indices (
[BugFix] Fix PPL mixed text/keyword field type across wildcard indices (
Merge upstream/main into feature/mustang-ppl-integration
[BugFix] Fix PPL mixed text/keyword field type across wildcard indices (