Skip to content

Add implementation to update service settings method for Alibaba Cloud Search service#142738

Merged
Jan-Kazlouski-elastic merged 6 commits intoelastic:mainfrom
Jan-Kazlouski-elastic:implement-update-service-settings-method-alibabacloudsearch
Feb 23, 2026
Merged

Add implementation to update service settings method for Alibaba Cloud Search service#142738
Jan-Kazlouski-elastic merged 6 commits intoelastic:mainfrom
Jan-Kazlouski-elastic:implement-update-service-settings-method-alibabacloudsearch

Conversation

@Jan-Kazlouski-elastic
Copy link
Copy Markdown
Contributor

This PR is a part of a broader initiative related to endpoint _update operation: #122356
In particular - this PR provides implementation for updateServiceSettings method used in _update operation for Alibaba Cloud Search service.
Initially the changes present in this PR were a part of a bigger PR #140082.
API reference for the update operation can be found here: https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-update.

service_id, host, workspace, similarity and dimensions in service settings map are immutable, meaning they cannot be updated with _update operation.

  • - Have you signed the contributor license agreement?
  • - Have you followed the contributor guidelines?
  • - If submitting code, have you built your formula locally prior to submission with gradle check?
  • - If submitting code, is your pull request against main? Unless there is a good reason otherwise, we prefer pull requests against main and will backport as needed.
  • - If submitting code, have you checked that your submission is for an OS and architecture that we support?
  • - If you are submitting this code for a class then read our policy for that.

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/search-inference-team (Team:Search - Inference)

@elasticsearchmachine elasticsearchmachine added v9.4.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Feb 19, 2026
public static final String NAME = "alibabacloud_search_completion_service_settings";

public static AlibabaCloudSearchCompletionServiceSettings fromMap(Map<String, Object> map, ConfigurationParseContext context) {
ValidationException validationException = new ValidationException();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ValidationException was not passed anywhere and couldn't be filled out with any validation errors. Actual validation was performed only within the AlibabaCloudSearchServiceSettings.fromMap method

public static AlibabaCloudSearchEmbeddingsServiceSettings fromMap(Map<String, Object> map, ConfigurationParseContext context) {
ValidationException validationException = new ValidationException();
var validationException = new ValidationException();
var commonServiceSettings = AlibabaCloudSearchServiceSettings.fromMap(map, context);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you may see, the validation is happening in 2 steps here. If AlibabaCloudSearchServiceSettings.fromMap introduces validation fails - it will fail early without checking embedding specific fields and without filling out the potential errors in these fields.
I don't see this approach as optimal. We could alter the signature of the AlibabaCloudSearchServiceSettings.fromMap to take validation exception as param and fill it out with validation errors for the common fields while keeping the responsibility of throwing the exception on task specific classes. I implemented that locally. If it is decided that we would want to go with this approach I can push it here.

CC @DonalEvans

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of passing the ValidationException into AlibabaCloudSearchServiceSettings.fromMap(). The purpose of the way we use ValidationException is to allow us to capture ALL of the validation problems with a given input, so having two places we can throw while parsing a single object feels wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Copy Markdown
Contributor

@DonalEvans DonalEvans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few suggestions for minor test improvements, but nothing worth holding the PR up for if you don't feel like implementing the changes.

);
}

public void testUpdateServiceSettings_EmptyMap_Success() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than simply *_Success this test might be better named something like *_DoesNotChangeSettings

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Also changed it for AI21 so the approach is the same for both services. I want to keep same more or less unified across the services.

Comment on lines +85 to +108
var serviceSettings = new AlibabaCloudSearchCompletionServiceSettings(
new AlibabaCloudSearchServiceSettings(
INITIAL_TEST_SERVICE_ID,
INITIAL_TEST_HOST,
INITIAL_TEST_WORKSPACE_NAME,
INITIAL_TEST_HTTP_SCHEMA,
new RateLimitSettings(INITIAL_TEST_RATE_LIMIT)
)
).updateServiceSettings(new HashMap<>());

assertThat(
serviceSettings,
is(
new AlibabaCloudSearchCompletionServiceSettings(
new AlibabaCloudSearchServiceSettings(
INITIAL_TEST_SERVICE_ID,
INITIAL_TEST_HOST,
INITIAL_TEST_WORKSPACE_NAME,
INITIAL_TEST_HTTP_SCHEMA,
new RateLimitSettings(INITIAL_TEST_RATE_LIMIT)
)
)
)
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test can be simplified/clarified a little if we do:

        var originalServiceSettings = new AlibabaCloudSearchCompletionServiceSettings(
            new AlibabaCloudSearchServiceSettings(
                INITIAL_TEST_SERVICE_ID,
                INITIAL_TEST_HOST,
                INITIAL_TEST_WORKSPACE_NAME,
                INITIAL_TEST_HTTP_SCHEMA,
                new RateLimitSettings(INITIAL_TEST_RATE_LIMIT)
            )
        );
        
        var updatedServiceSettings = originalServiceSettings.updateServiceSettings(new HashMap<>());

        assertThat(updatedServiceSettings, is(originalServiceSettings));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Done that for AI21 as well.

);
}

public void testUpdateServiceSettings_EmptyMap_Success() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments on AlibabaCloudSearchCompletionServiceSettingsTests.testUpdateServiceSettings_EmptyMap_Success()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

);
}

public void testUpdateServiceSettings_EmptyMap_Success() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments on AlibabaCloudSearchCompletionServiceSettingsTests.testUpdateServiceSettings_EmptyMap_Success()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

);
}

public void testUpdateServiceSettings_EmptyMap_Success() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments on AlibabaCloudSearchCompletionServiceSettingsTests.testUpdateServiceSettings_EmptyMap_Success()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

);
}

public void testUpdateServiceSettings_EmptyMap_Success() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments on AlibabaCloudSearchCompletionServiceSettingsTests.testUpdateServiceSettings_EmptyMap_Success()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@Jan-Kazlouski-elastic
Copy link
Copy Markdown
Contributor Author

Hi @DonalEvans ! Thank you for your comments and approval. I implemented the proposed fixes and a few more. Also unified testing approaches with the one taken for AI21. I want to keep everything more or less the same across the implementations.
Would you please give this PR another look so we could merge this one?

@Jan-Kazlouski-elastic Jan-Kazlouski-elastic merged commit d5a327a into elastic:main Feb 23, 2026
37 checks passed
szybia added a commit to szybia/elasticsearch that referenced this pull request Feb 23, 2026
…on-sliced-reindex

* upstream/main: (110 commits)
  Add search task watchdog to log hot threads on slow search (elastic#142746)
  Fix return_intermediate_results query param on get async search results (elastic#142875)
  Mute org.elasticsearch.compute.operator.exchange.BatchDriverTests testSinglePageSingleBatch elastic#142895
  Cancel reindex body always has status (elastic#142766)
  Fix built-in roles sync losing updates (elastic#142433)
  ESQL: Clarify docs and add csv test for WHERE in STATS (elastic#133629)
  Fix and unmute ReindexResumeIT (elastic#142788)
  Fix broken release notes
  Mute org.elasticsearch.benchmark.vector.scorer.VectorScorerOSQBenchmarkTests testSingleScalarVsVectorized {p0=384 p1=4 p2=NIO p3=COSINE} elastic#142883
  ES|QL: fix Generative tests for commands that don't change the output schema (elastic#142864)
  Mute org.elasticsearch.benchmark.vector.scorer.VectorScorerOSQBenchmarkTests testSingleScalarVsVectorized {p0=1024 p1=1 p2=NIO p3=DOT_PRODUCT} elastic#142881
  SQL: Fix QlIllegalArgumentException with non-foldable date range queries (elastic#142386)
  Add more errors to the allowed_errors with github issue links (elastic#142862)
  ESQL: reapply "NDJSON datasource" (elastic#142855)
  Add implementation to update service settings method for Alibaba Cloud Search service (elastic#142738)
  Mute org.elasticsearch.snapshots.SnapshotShutdownIT testStartRemoveNodeButDoNotComplete elastic#142871
  Mute org.elasticsearch.snapshots.SnapshotShutdownIT testDeleteSnapshotWithPausedShardSnapshots elastic#142870
  Mute org.elasticsearch.snapshots.SnapshotShutdownIT testAbortSnapshotWhileRemovingNode elastic#142869
  Mute org.elasticsearch.snapshots.SnapshotShutdownIT testRemoveNodeDuringSnapshot elastic#142868
  ES|QL: Guard exponential_histogram TO_STRING against too large inputs (elastic#140718)
  ...
jdconrad pushed a commit to jdconrad/elasticsearch that referenced this pull request Feb 24, 2026
…d Search service (elastic#142738)

* Add updateServiceSettings method to AlibabaCloudSearchCompletionServiceSettings and related classes

* Fix unit tests and add changelog

* Fix validation exception handling

* Refactor updateServiceSettings tests to improve clarity and consistency
sidosera pushed a commit to sidosera/elasticsearch that referenced this pull request Feb 24, 2026
…d Search service (elastic#142738)

* Add updateServiceSettings method to AlibabaCloudSearchCompletionServiceSettings and related classes

* Fix unit tests and add changelog

* Fix validation exception handling

* Refactor updateServiceSettings tests to improve clarity and consistency
@Jan-Kazlouski-elastic Jan-Kazlouski-elastic deleted the implement-update-service-settings-method-alibabacloudsearch branch April 2, 2026 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contributor Pull request authored by a developer outside the Elasticsearch team :SearchOrg/Inference Label for the Search Inference team Team:Search - Inference >tech-debt v9.4.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants