Skip to content

Commit

Permalink
Generate TokenFilter variants
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Nov 11, 2024
1 parent e8e3a99 commit d55b506
Show file tree
Hide file tree
Showing 83 changed files with 3,874 additions and 1,822 deletions.
18 changes: 17 additions & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,20 @@ After:
- Removed the `Runtime` variant from the `DynamicMapping` enum as it is not supported by OpenSearch.

### TypeMapping
- Removed the `runtime` field, getter and builder methods from `TypeMapping` as it is not supported by OpenSearch.
- Removed the `runtime` field, getter and builder methods from `TypeMapping` as it is not supported by OpenSearch.

### InlineScript
- The `lang` property now accepts a `ScriptLanguage` enum instead of a `String`.

### IcuCollationDecomposition enum variants
- The `IcuCollationDecomposition.Identical` variant has been corrected to be `IcuCollationDecomposition.Canonical`.

### IcuCollationTokenFilter property name casing
- The following fields, getters and builder methods on `IcuCollationTokenFilter` have had their casing corrected:
- `casefirst` -> `caseFirst`
- `caselevel` -> `caseLevel`
- `hiraganaquaternarymode` -> `hiraganaQuaternaryMode`
- `variabletop` -> `variableTop`

### TokenFilterDefinition
- The `smartcn_stop` Builder method has been renamed to `smartcnStop`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

/*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types;

import javax.annotation.Generated;
import org.opensearch.client.json.JsonEnum;
import org.opensearch.client.json.JsonpDeserializable;

// typedef: _types.BuiltinScriptLanguage

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public enum BuiltinScriptLanguage implements JsonEnum {
Expression("expression"),

Java("java"),

Mustache("mustache"),

Painless("painless");

private final String jsonValue;

BuiltinScriptLanguage(String jsonValue) {
this.jsonValue = jsonValue;
}

public String jsonValue() {
return this.jsonValue;
}

public static final JsonEnum.Deserializer<BuiltinScriptLanguage> _DESERIALIZER = new JsonEnum.Deserializer<>(
BuiltinScriptLanguage.values()
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,18 @@
* GitHub history for details.
*/

//----------------------------------------------------
// THIS CODE IS GENERATED. MANUAL EDITS WILL BE LOST.
//----------------------------------------------------

package org.opensearch.client.opensearch._types;

import jakarta.json.stream.JsonGenerator;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import javax.annotation.Generated;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
Expand All @@ -47,102 +54,112 @@
// typedef: _types.InlineScript

@JsonpDeserializable
@Generated("org.opensearch.client.codegen.CodeGenerator")
public class InlineScript extends ScriptBase {

@Nullable
private final String lang;
private final ScriptLanguage lang;

@Nonnull
private final Map<String, String> options;

@Nonnull
private final String source;

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

private InlineScript(Builder builder) {
super(builder);

this.lang = builder.lang;
this.options = ApiTypeHelper.unmodifiable(builder.options);
this.source = ApiTypeHelper.requireNonNull(builder.source, this, "source");

}

public static InlineScript of(Function<Builder, ObjectBuilder<InlineScript>> fn) {
public static InlineScript of(Function<InlineScript.Builder, ObjectBuilder<InlineScript>> fn) {
return fn.apply(new Builder()).build();
}

/**
* API name: {@code lang}
*/
@Nullable
public final String lang() {
public final ScriptLanguage lang() {
return this.lang;
}

/**
* API name: {@code options}
*/
@Nonnull
public final Map<String, String> options() {
return this.options;
}

/**
* Required - API name: {@code source}
* Required - The script source.
* <p>
* API name: {@code source}
* </p>
*/
@Nonnull
public final String source() {
return this.source;
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

super.serializeInternal(generator, mapper);
if (this.lang != null) {
generator.writeKey("lang");
generator.write(this.lang);

this.lang.serialize(generator, mapper);
}

if (ApiTypeHelper.isDefined(this.options)) {
generator.writeKey("options");
generator.writeStartObject();
for (Map.Entry<String, String> item0 : this.options.entrySet()) {
generator.writeKey(item0.getKey());
generator.write(item0.getValue());

}
generator.writeEnd();

}

generator.writeKey("source");
generator.write(this.source);

}

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

/**
* Builder for {@link InlineScript}.
*/

public static class Builder extends ScriptBase.AbstractBuilder<Builder> implements ObjectBuilder<InlineScript> {
@Nullable
private String lang;

private ScriptLanguage lang;
@Nullable
private Map<String, String> options;

private String source;

/**
* API name: {@code lang}
*/
public final Builder lang(@Nullable String value) {
public final Builder lang(@Nullable ScriptLanguage value) {
this.lang = value;
return this;
}

/**
* API name: {@code lang}
*/
public final Builder lang(Function<ScriptLanguage.Builder, ObjectBuilder<ScriptLanguage>> fn) {
return lang(fn.apply(new ScriptLanguage.Builder()).build());
}

/**
* API name: {@code options}
*
* <p>
* Adds all entries of <code>map</code> to <code>options</code>.
* Adds all elements of <code>map</code> to <code>options</code>.
* </p>
*/
public final Builder options(Map<String, String> map) {
this.options = _mapPutAll(this.options, map);
Expand All @@ -151,16 +168,21 @@ public final Builder options(Map<String, String> map) {

/**
* API name: {@code options}
*
* <p>
* Adds an entry to <code>options</code>.
* </p>
*/
public final Builder options(String key, String value) {
this.options = _mapPut(this.options, key, value);
return this;
}

/**
* Required - API name: {@code source}
* Required - The script source.
* <p>
* API name: {@code source}
* </p>
*/
public final Builder source(String value) {
this.source = value;
Expand All @@ -175,8 +197,7 @@ protected Builder self() {
/**
* Builds a {@link InlineScript}.
*
* @throws NullPointerException
* if some of the required fields are null.
* @throws NullPointerException if some of the required fields are null.
*/
public InlineScript build() {
_checkSingleUse();
Expand All @@ -196,13 +217,31 @@ public InlineScript build() {
);

protected static void setupInlineScriptDeserializer(ObjectDeserializer<InlineScript.Builder> op) {
ScriptBase.setupScriptBaseDeserializer(op);
op.add(Builder::lang, JsonpDeserializer.stringDeserializer(), "lang");
setupScriptBaseDeserializer(op);
op.add(Builder::lang, ScriptLanguage._DESERIALIZER, "lang");
op.add(Builder::options, JsonpDeserializer.stringMapDeserializer(JsonpDeserializer.stringDeserializer()), "options");
op.add(Builder::source, JsonpDeserializer.stringDeserializer(), "source");

op.shortcutProperty("source");
}

@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + Objects.hashCode(this.lang);
result = 31 * result + Objects.hashCode(this.options);
result = 31 * result + this.source.hashCode();
return result;
}

@Override
public boolean equals(Object o) {
if (!super.equals(o)) {
return false;
}
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
InlineScript other = (InlineScript) o;
return Objects.equals(this.lang, other.lang) && Objects.equals(this.options, other.options) && this.source.equals(other.source);
}
}
Loading

0 comments on commit d55b506

Please sign in to comment.