Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add indexing and search index settings #667

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This section is for maintaining a changelog for all breaking changes for the cli
## [Unreleased 2.x]

### Added
- Added support for indexing and search index settings ([#667](https://github.com/opensearch-project/opensearch-java/pull/667))

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ public class IndexSettings implements JsonpSerializable {
@Nullable
private final IndexSettingsMapping mapping;

@Nullable
private final IndexSettingsIndexing indexing;

@Nullable
private final IndexSettingsSearch search;

@Nullable
private final Boolean knn;

Expand Down Expand Up @@ -280,6 +286,8 @@ private IndexSettings(Builder builder) {
this.analysis = builder.analysis;
this.settings = builder.settings;
this.mapping = builder.mapping;
this.indexing = builder.indexing;
this.search = builder.search;
this.knn = builder.knn;
this.knnAlgoParamEfSearch = builder.knnAlgoParamEfSearch;

Expand Down Expand Up @@ -748,6 +756,22 @@ public final IndexSettingsMapping mapping() {
return this.mapping;
}

/**
* API name: {@code indexing}
*/
@Nullable
public final IndexSettingsIndexing indexing() {
return this.indexing;
}

/**
* API name: {@code search}
*/
@Nullable
public final IndexSettingsSearch search() {
return this.search;
}

/**
* API name: {@code knn}
*/
Expand Down Expand Up @@ -1054,6 +1078,16 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("mapping");
this.mapping.serialize(generator, mapper);

}
if (this.indexing != null) {
generator.writeKey("indexing");
this.indexing.serialize(generator, mapper);

}
if (this.search != null) {
generator.writeKey("search");
this.search.serialize(generator, mapper);

}
if (this.knn != null) {
generator.writeKey("knn");
Expand Down Expand Up @@ -1240,6 +1274,12 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<I
@Nullable
private IndexSettingsMapping mapping;

@Nullable
private IndexSettingsIndexing indexing;

@Nullable
private IndexSettingsSearch search;

@Nullable
private Boolean knn;

Expand Down Expand Up @@ -1821,6 +1861,36 @@ public final Builder mapping(Function<IndexSettingsMapping.Builder, ObjectBuilde
return this.mapping(fn.apply(new IndexSettingsMapping.Builder()).build());
}

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

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

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

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

/**
* Builds a {@link IndexSettings}.
*
Expand Down Expand Up @@ -1995,6 +2065,8 @@ protected static void setupIndexSettingsDeserializer(ObjectDeserializer<IndexSet
op.add(Builder::analysis, IndexSettingsAnalysis._DESERIALIZER, "analysis", "index.analysis");
op.add(Builder::settings, IndexSettings._DESERIALIZER, "settings");
op.add(Builder::mapping, IndexSettingsMapping._DESERIALIZER, "mapping");
op.add(Builder::indexing, IndexSettingsIndexing._DESERIALIZER, "indexing");
op.add(Builder::search, IndexSettingsSearch._DESERIALIZER, "search");
op.add(Builder::knn, JsonpDeserializer.booleanDeserializer(), "knn", "index.knn");
op.add(
Builder::knnAlgoParamEfSearch,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
* 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.
*/

/*
russcam marked this conversation as resolved.
Show resolved Hide resolved
* 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.
*/

package org.opensearch.client.opensearch.indices;

import jakarta.json.stream.JsonGenerator;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.*;
import org.opensearch.client.util.ObjectBuilder;
import org.opensearch.client.util.ObjectBuilderBase;

@JsonpDeserializable
public class IndexSettingsIndexing implements JsonpSerializable {
@Nullable
private final IndexingSlowlog slowlog;

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

private IndexSettingsIndexing(Builder builder) {

this.slowlog = builder.slowlog;

}

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

/**
* API name: {@code slowlog}
*/
@Nullable
public final IndexingSlowlog slowlog() {
return this.slowlog;
}

/**
* Serialize this object to JSON.
*/
public void serialize(JsonGenerator generator, JsonpMapper mapper) {
generator.writeStartObject();
serializeInternal(generator, mapper);
generator.writeEnd();
}

protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

if (this.slowlog != null) {
generator.writeKey("slowlog");
this.slowlog.serialize(generator, mapper);

}

}

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

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

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<IndexSettingsIndexing> {
@Nullable
private IndexingSlowlog slowlog;

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

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

/**
* Builds a {@link IndexSettingsIndexing}.
*
* @throws NullPointerException
* if some of the required fields are null.
*/
public IndexSettingsIndexing build() {
_checkSingleUse();

return new IndexSettingsIndexing(this);
}
}

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

/**
* Json deserializer for {@link IndexSettingsIndexing}
*/
public static final JsonpDeserializer<IndexSettingsIndexing> _DESERIALIZER = ObjectBuilderDeserializer.lazy(
Builder::new,
IndexSettingsIndexing::setupSettingsSearchDeserializer
);

protected static void setupSettingsSearchDeserializer(ObjectDeserializer<Builder> op) {

op.add(Builder::slowlog, IndexingSlowlog._DESERIALIZER, "slowlog");

}

}
Loading
Loading