opensearch-project / opensearch-project/opensearch-java
[FEATURE] Raw Json support
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 165
- Forks
- 250
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 26
Description
Is your feature request related to a problem?
Current JavaClient requires TypeMapping type which requires deserializing the Json Parser and Mapper to read raw json of mapping file using TypeMapping._DESERIALIZER. This process is not documented right now.
private String getAnomalyDetectorMappings() throws IOException {
URL url = AnomalyDetectionIndices.class.getClassLoader().getResource(ANOMALY_DETECTORS_INDEX_MAPPING_FILE);
return Resources.toString(url, Charsets.UTF_8);
}
JsonpMapper mapper = sdkClient._transport().jsonpMapper();
JsonParser parser = null;
try {
parser = mapper
.jsonProvider()
.createParser(new ByteArrayInputStream(getAnomalyDetectorMappings().getBytes(StandardCharsets.UTF_8)));
} catch (Exception e) {
e.printStackTrace();
}
CreateIndexRequest request = null;
try {
request = new CreateIndexRequest.Builder()
.index(ANOMALY_DETECTORS_INDEX)
.mappings(TypeMapping._DESERIALIZER.deserialize(parser, mapper))
.build();
} catch (Exception e) {
e.printStackTrace();
}
The mapper and parser should be present in java client and thus avoiding the user to create it on their end everytime.
What solution would you like?
When creating an index, provide a type to pass the raw json file directly which can be later parse on java client side to TyepMapping
request = new CreateIndexRequest.Builder()
.index(ANOMALY_DETECTORS_INDEX)
.mappingFile(<json_file_here>)
.build();
What alternatives have you considered?
A clear and concise description of any alternative solutions or features you've considered.
Do you have any additional context?
Add any other context or screenshots about the feature request here.
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
Start with java-client/src/main/java/org/opensearch/client/opensearch/indices/CreateIndexRequest.java and review how CreateIndexRequest.Builder currently accepts mappings. Read the TypeMapping._DESERIALIZER usage in the issue and determine how a mapping file should be passed and parsed by the Java client. Done means index creation can accept raw JSON mapping input without users creating the mapper and parser themselves.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100