opensearch-project / opensearch-project/opensearch-java
[BUG] Opensearch Java client can't index "null" value
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 165
- Forks
- 250
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 26
Description
What is the bug?
A clear and concise description of the bug.
Opensearch java client can't index null value. When I pass a field with null value, it skips that field altogether. The field is not indexed.
How can one reproduce the bug?
Steps to reproduce the behavior.
{
"index-1": {
"mappings": {
"dynamic": "false",
"_source": {
"includes": [
"*"
]
},
"dynamic_templates": [
{
"string_permissions": {
"path_match": "perms.*",
"mapping": {
"type": "keyword"
}
}
}
],
"properties": {
"__createdAt": {
"type": "date"
},
"__creator": {
"type": "keyword"
},
"__fromCV": {
"type": "long"
},
"__id": {
"type": "keyword"
},
"__modifiedAt": {
"type": "date"
},
"__modifier": {
"type": "keyword"
},
"__toCV": {
"type": "long"
},
"cId": {
"type": "keyword"
},
"cVersion": {
"type": "long"
},
"k": {
"properties": {
"1": {
"type": "keyword",
"null_value": "NONE"
},
"2": {
"type": "keyword",
"null_value": "NONE"
},
"3": {
"type": "keyword",
"null_value": "NONE"
},
"4": {
"type": "keyword",
"null_value": "NONE"
},
"5": {
"type": "keyword",
"null_value": "NONE"
}
}
},
"perms": {
"dynamic": "true",
"properties": {
"acm": {
"type": "keyword"
},
"custom": {
"type": "keyword"
},
"l2cs": {
"type": "boolean"
},
"wipdm": {
"type": "keyword"
}
}
}
}
}
}
}
When I pass null values for any of the k properties, it skips them. For example, if k.2: null, this value won't be indexed. Other values get properly indexed.
But if I directly index the value k.2: null using OpenSearch dashboard, it gets indexed properly. The same mappings have been used.
What is the expected behavior?
A clear and concise description of what you expected to happen.
Expectation is that even with OpenSearch java client I can index null value
What is your host/environment?
Operating system, version.
macOS & Windows 11
Do you have any screenshots?
If applicable, add screenshots to help explain your problem.
Do you have any additional context?
Add any other context about the problem.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by tracing the Java client's indexing request serialization and compare how a nested null field is represented with the dashboard request. Done means an index request containing k.2: null preserves that field so OpenSearch applies the mapping's null_value behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100