Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into termvectorsresponse…
Browse files Browse the repository at this point in the history
…_optionals_main

Signed-off-by: pieper <[email protected]>
  • Loading branch information
MikePieperSer committed Oct 4, 2023
2 parents ecded52 + aea607a commit e2e8386
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 51 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- { opensearch_version: 1.0.1, java: 11 }
- { opensearch_version: 1.1.0, java: 11 }
- { opensearch_version: 1.2.4, java: 11 }
- { opensearch_version: 1.3.9, java: 11 }
- { opensearch_version: 1.3.13, java: 11 }
- { opensearch_version: 2.0.1, java: 11 }
- { opensearch_version: 2.1.0, java: 11 }
- { opensearch_version: 2.2.1, java: 11 }
Expand All @@ -21,6 +21,9 @@ jobs:
- { opensearch_version: 2.5.0, java: 11 }
- { opensearch_version: 2.6.0, java: 11 }
- { opensearch_version: 2.7.0, java: 11 }
- { opensearch_version: 2.8.0, java: 11 }
- { opensearch_version: 2.9.0, java: 11 }
- { opensearch_version: 2.10.0, java: 11 }
steps:
- name: Checkout Java Client
uses: actions/checkout@v3
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Fix version and build ([#254](https://github.com/opensearch-project/opensearch-java/pull/254))
- Fix PutMappingRequest by removing unsupported fields ([#597](https://github.com/opensearch-project/opensearch-java/pull/597))
- Fix parsing of GetFieldMappingResponse ([#641](https://github.com/opensearch-project/opensearch-java/pull/641))
- [BUG] Fix TermvectorsResponse for optional fields. ([#642](https://github.com/opensearch-project/opensearch-java/pull/642))

### Security

## [Unreleased 2.x]

### Added
- Added support for "smartcn" analyzer ([#605](https://github.com/opensearch-project/opensearch-java/pull/605))
- Added support for "script_fields" in multi search request ([#632](https://github.com/opensearch-project/opensearch-java/pull/632))

### Dependencies

Expand Down Expand Up @@ -196,4 +199,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
[2.5.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.4.0...v2.5.0
[2.4.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.3.0...v2.4.0
[2.3.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.2.0...v2.3.0
[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0
[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0
10 changes: 2 additions & 8 deletions COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,8 @@ The below matrix shows the compatibility of the [`opensearch-java-client`](https

| Client Version | OpenSearch Version |
|----------------|--------------------|
| 1.0.0 | 1.0.0-1.3.9 |
| 2.0.0 | 1.3.9-2.0.1 |
| 2.1.0 | 1.3.9-2.3.0 |
| 2.2.0 | 1.3.9-2.5.0 |
| 2.3.0 | 1.3.9-2.7.0 |
| 2.4.0 | 1.3.9-2.7.0 |
| 2.5.0 | 1.3.9-2.7.0 |
| 2.6.0 | 1.3.9-2.7.0 |
| 1.0.0 | 1.x |
| 2.x.0 | 1.3.13-2.10.0 |

## Upgrading

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@

@JsonpDeserializable
public class FieldMapping implements JsonpSerializable {
// Single key dictionary
private final String field;

private final String fullName;

private final Map<String, Property> mapping;
Expand All @@ -61,8 +58,6 @@ public class FieldMapping implements JsonpSerializable {

private FieldMapping(Builder builder) {

this.field = ApiTypeHelper.requireNonNull(builder.field, this, "field");

this.fullName = ApiTypeHelper.requireNonNull(builder.fullName, this, "fullName");
this.mapping = ApiTypeHelper.unmodifiableRequired(builder.mapping, this, "mapping");

Expand All @@ -72,13 +67,6 @@ public static FieldMapping of(Function<Builder, ObjectBuilder<FieldMapping>> fn)
return fn.apply(new Builder()).build();
}

/**
* Required - The target field
*/
public final String field() {
return this.field;
}

/**
* Required - API name: {@code full_name}
*/
Expand All @@ -103,8 +91,6 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject(this.field);

generator.writeKey("full_name");
generator.write(this.fullName);

Expand All @@ -120,8 +106,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

generator.writeEnd();

}

// ---------------------------------------------------------------------------------------------
Expand All @@ -131,15 +115,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<FieldMapping> {
private String field;

/**
* Required - The target field
*/
public final Builder field(String value) {
this.field = value;
return this;
}

private String fullName;

Expand Down Expand Up @@ -208,8 +183,6 @@ protected static void setupFieldMappingDeserializer(ObjectDeserializer<FieldMapp
op.add(Builder::fullName, JsonpDeserializer.stringDeserializer(), "full_name");
op.add(Builder::mapping, JsonpDeserializer.stringMapDeserializer(Property._DESERIALIZER), "mapping");

op.setKey(Builder::field, JsonpDeserializer.stringDeserializer());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package org.opensearch.client.opensearch.core.msearch;

import org.opensearch.client.opensearch._types.ScriptField;
import org.opensearch.client.opensearch._types.SortOptions;
import org.opensearch.client.opensearch._types.aggregations.Aggregation;
import org.opensearch.client.opensearch._types.query_dsl.Query;
Expand Down Expand Up @@ -96,6 +97,8 @@ public class MultisearchBody implements JsonpSerializable {
@Nullable
private SourceConfig source;

private final Map<String, ScriptField> scriptFields;

// ---------------------------------------------------------------------------------------------

private MultisearchBody(Builder builder) {
Expand All @@ -113,7 +116,7 @@ private MultisearchBody(Builder builder) {
this.suggest = builder.suggest;
this.highlight = builder.highlight;
this.source = builder.source;

this.scriptFields = ApiTypeHelper.unmodifiable(builder.scriptFields);
}

public static MultisearchBody of(Function<Builder, ObjectBuilder<MultisearchBody>> fn) {
Expand Down Expand Up @@ -221,6 +224,10 @@ public final SourceConfig source() {
return this.source;
}

public final Map<String, ScriptField> scriptFields() {
return this.scriptFields;
}

/**
* Serialize this object to JSON.
*/
Expand Down Expand Up @@ -316,6 +323,18 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

}

if (ApiTypeHelper.isDefined(this.scriptFields)) {
generator.writeKey("script_fields");
generator.writeStartObject();
for (Map.Entry<String, ScriptField> item0 : this.scriptFields.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);

}
generator.writeEnd();

}

}

// ---------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -364,6 +383,8 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<M
@Nullable
private SourceConfig source;

private Map<String, ScriptField> scriptFields;


/**
* API name: {@code aggregations}
Expand Down Expand Up @@ -571,6 +592,29 @@ public final Builder source(Function<SourceConfig.Builder, ObjectBuilder<SourceC
return this.source(fn.apply(new SourceConfig.Builder()).build());
}

/**
* API name: {@code script_fields}
*/
public final Builder scriptFields(Map<String, ScriptField> map) {
this.scriptFields = _mapPutAll(this.scriptFields, map);
return this;
}

/**
* API name: {@code script_fields}
*/
public final Builder scriptFields(String key, ScriptField value) {
this.scriptFields = _mapPut(this.scriptFields, key, value);
return this;
}

/**
* API name: {@code script_fields}
*/
public final Builder scriptFields(String key, Function<ScriptField.Builder, ObjectBuilder<ScriptField>> fn) {
return scriptFields(key, fn.apply(new ScriptField.Builder()).build());
}

/**
* Builds a {@link MultisearchBody}.
*
Expand Down Expand Up @@ -609,6 +653,8 @@ protected static void setupMultisearchBodyDeserializer(ObjectDeserializer<Multis
op.add(Builder::suggest, Suggester._DESERIALIZER, "suggest");
op.add(Builder::highlight, Highlight._DESERIALIZER, "highlight");
op.add(Builder::source, SourceConfig._DESERIALIZER, "_source");
op.add(Builder::scriptFields, JsonpDeserializer.stringMapDeserializer(ScriptField._DESERIALIZER),
"script_fields");

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

package org.opensearch.client.opensearch.indices.get_field_mapping;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.opensearch.client.opensearch._types.mapping.FieldMapping;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
Expand All @@ -51,13 +54,13 @@

@JsonpDeserializable
public class TypeFieldMappings implements JsonpSerializable {
private final FieldMapping mappings;
private final Map<String, FieldMapping> mappings;

// ---------------------------------------------------------------------------------------------

private TypeFieldMappings(Builder builder) {

this.mappings = ApiTypeHelper.requireNonNull(builder.mappings, this, "mappings");
this.mappings = ApiTypeHelper.unmodifiableRequired(builder.mappings, this, "mappings");

}

Expand All @@ -68,7 +71,7 @@ public static TypeFieldMappings of(Function<Builder, ObjectBuilder<TypeFieldMapp
/**
* Required - API name: {@code mappings}
*/
public final FieldMapping mappings() {
public final Map<String, FieldMapping> mappings() {
return this.mappings;
}

Expand All @@ -84,7 +87,13 @@ public void serialize(JsonGenerator generator, JsonpMapper mapper) {
protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

generator.writeKey("mappings");
this.mappings.serialize(generator, mapper);
generator.writeStartObject();
for (Map.Entry<String, FieldMapping> item0 : this.mappings.entrySet()) {
generator.writeKey(item0.getKey());
item0.getValue().serialize(generator, mapper);

}
generator.writeEnd();

}

Expand All @@ -95,21 +104,39 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<TypeFieldMappings> {
private FieldMapping mappings;
private Map<String, FieldMapping> mappings;

/**
* Required - API name: {@code mappings}
*/
public final Builder mappings(FieldMapping value) {
public Builder mappings(Map<String, FieldMapping> value) {
this.mappings = value;
return this;
}

/**
* Required - API name: {@code mappings}
* Add a key/value to {@link #mappings(Map)}, creating the map if needed.
*/
public Builder putMappings(String key, FieldMapping value) {
if (this.mappings == null) {
this.mappings = new HashMap<>();
}
this.mappings.put(key, value);
return this;
}

/**
* Set {@link #mappings(Map)} to a singleton map.
*/
public Builder mappings(String key, Function<FieldMapping.Builder, ObjectBuilder<FieldMapping>> fn) {
return this.mappings(Collections.singletonMap(key, fn.apply(new FieldMapping.Builder()).build()));
}

/**
* Add a key/value to {@link #mappings(Map)}, creating the map if needed.
*/
public final Builder mappings(Function<FieldMapping.Builder, ObjectBuilder<FieldMapping>> fn) {
return this.mappings(fn.apply(new FieldMapping.Builder()).build());
public Builder putMappings(String key, Function<FieldMapping.Builder, ObjectBuilder<FieldMapping>> fn) {
return this.putMappings(key, fn.apply(new FieldMapping.Builder()).build());
}

/**
Expand All @@ -135,7 +162,7 @@ public TypeFieldMappings build() {

protected static void setupTypeFieldMappingsDeserializer(ObjectDeserializer<TypeFieldMappings.Builder> op) {

op.add(Builder::mappings, FieldMapping._DESERIALIZER, "mappings");
op.add(Builder::mappings, JsonpDeserializer.stringMapDeserializer(FieldMapping._DESERIALIZER), "mappings");

}

Expand Down
Loading

0 comments on commit e2e8386

Please sign in to comment.