forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Synonyms API - GET Request #5
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
Closed
carlosdelest
wants to merge
88
commits into
carlosdelest/synonyms-move-to-server
from
carlosdelest/synonyms-get
Closed
Changes from 4 commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
2394f71
Add internal method to force connection close after request. (#96305)
stu-elastic 1a1dcd9
Update serverless submodule update build trigger
mark-vieira ddd9024
Add CI pipeline for testing Elasticsearch changes in serverless
mark-vieira 5bc7d26
Avoid stack overflow while parsing mapping (#95705)
mayya-sharipova 085beea
Update branch triggering settings so GitHub pushes trigger build
mark-vieira 870ca07
Enforce license for cross-cluster API key APIs (#96307)
ywangd 905b8fe
Chunk profiling stacktrace response (#96340)
danielmitterdorfer d8e7373
Simplify node shutdown handling. (#96292)
idegtiarenko 354992e
Make cluster info rest endpoint cancellable (#96327)
6208df0
Allow the removal of an in use template if there are other matching o…
gmarouli 1762733
Stateless real-time GET (#93976)
pxsalehi f6e9bbf
Remove COMMON_PREFIX from MockLogAppender (#96331)
kingherc 62bad38
PUT refactoring so service does not depend on response
carlosdelest e58094c
Initial GET action implementation
carlosdelest 9d3bb2f
Added pagination
carlosdelest 2a49ad9
Slightly better hot threads for transport workers (#96315)
DaveCTurner 5717968
Add testing for GET
carlosdelest 8b83636
Clean up `adjustSearchType` method (#96334)
jdconrad ea36a8b
Don't publish commit status to github for serverless checks
mark-vieira 39c83d7
Universal Profiling: Remove cluster id from metrics mapping (#96335)
christos68k be6d5bb
Bump versions after 8.8.0 release
mark-vieira e0852a5
Prune changelogs after 8.8.0 release
mark-vieira 3c3c14f
Introduce GlobalCheckpointSyncer interface (#96345)
DaveCTurner ecef641
Use assertBusy for task unregistration events (#96347)
pxsalehi 3c5d96d
Support defining workflows restriction for API keys (#96215)
slobodanadamovic ac829ed
Enable skip methods on retrying inputstreams (#96337)
Tim-Brooks d68a2e0
[DOCS] Fixes a typo in the stop transform API docs (#96358)
abdonpijpelink d67a3ed
Update release notes for 8.8.0 release (#96354)
gmarouli 9cee43b
Remove dependency license check for all org.elasticsearch (#96355)
rjernst 08c0a9c
[Profiling] Add status API (#96272)
danielmitterdorfer fdabe7d
[Profiling] Rename lastprocessed into next_time in profiling-executab…
rockdaboot 3808b53
Warn if allocation diverged from the desired allocation (#95458)
idegtiarenko 244da06
Add `ingest` information to the cluster info endpoint (#96328)
41d4642
Dedicated internal user for DLM runtime tasks (#96253)
n1v0lg 870ee28
Mute MultiNodesStatsTests#testMultipleNodes (#96375)
pxsalehi 48c6547
remove unnecessary routing entry null checks (#96341)
pxsalehi 77a80b0
Reject defining workflows restriction via file and Role API (#96304)
slobodanadamovic 193e920
Use dynamic port range in testLoadsProxySettings (#96378)
pxsalehi b8a5704
[Profiling] Add comment to profiling-stackframes.json (#96384)
rockdaboot 3228058
Adding manage_dlm privilege (#95512)
masseyke 9649ee0
add analytics_collections to ent search usage test (#96385)
2b0d6e6
Introduce CancellableFanOut (#96373)
DaveCTurner d5f9e11
Update tsds-index-settings.asciidoc (#96366)
martijnvg 9aead84
Fixing DataLifecycleServiceIT.testAutomaticForceMerge() using a Stubb…
masseyke 860ccfd
Ignoring DataLifecycleServiceIT.testAutomaticForceMerge (#96395)
masseyke a71e988
[Test] Include DLM actions only when feature flag is enabled (#96118)
ywangd e5e2a04
REST spec and YAML tests for cross-cluster API key APIs (#96339)
ywangd f183d5c
Speed up SharedBytes.IO (#96388)
original-brownbear 06f0276
Convert ThreadPool stats objects to records (#96400)
7eaa868
Reduce indirection in AbstractRefCounted (#96403)
DaveCTurner 0e95bb4
Reject OPTIONS requests with a body (#96357)
albertzaharovits dae0c6f
Remove fair version of KeyedLock (#96411)
original-brownbear 0cf80f4
Move global checkpoint sync to write threadpool (#96364)
Tim-Brooks 2513104
Improve cancellability in TransportTasksAction (#96279)
DaveCTurner 23a592d
[Profiling] Set index:true for Symbolization.next_time (#96417)
rockdaboot 815190a
Move the registration of the aggregation collector manager to SearchC…
iverase 4ca12c1
Require DLM enabled in the mixed-cluster QA cluster (#96391)
andreidan 16aba06
[DOCS] Make 2028 dims 'experimental' warning inline (#96369)
abdonpijpelink 94ed4ca
[Test] Add missing feature flag checks for RCS 2.0 tests (#96424)
slobodanadamovic 651ec81
Promptly fail recovery from snapshot (#96421)
DaveCTurner e5111e3
Make list-tasks API cancellable (#96283)
DaveCTurner 17ff9f0
Adding `data_lifecycle` to the `_xpack/usage` API (#96177)
masseyke dd4641d
AwaitsFix for #96427
DaveCTurner 433ce88
Rank_feature field null_value test and small edits (#96392)
mayya-sharipova b7bbc19
Test fix: add dlm usage as a non-operator action (#96428)
gmarouli 1f8169d
Mention DLM in ignored docs test comments (#96422)
n1v0lg 66a951e
Fix tchar pattern in RestRequest (#96406)
pgomulka 494847b
Remove unnecessary reroute from tests (#96435)
idegtiarenko 6cb97a5
Allow unsigned long field to use decay functions (#96394)
jdconrad ad463c9
Fix race in testCancelledRecoveryAbortsDownloadPromptly (#96431)
DaveCTurner 31044b9
Count refs to index commit held by snapshot (#96426)
DaveCTurner 0a7bb64
Fix recovery permit exhaustion message (#96336)
volodk85 1ae63ac
Optimize KeyedLock and related concurrency primitives (#96372)
original-brownbear 0b8b5aa
Revert "Temporarily disable retries in docker build tasks (#96256)" (…
mark-vieira 83bfcc6
Disallow derived cross-cluster API keys (#96401)
ywangd 47c70f9
Format message only when debug is enabled (#96437)
idegtiarenko e5768d9
Upgrade Lucene to a 9.7.0 snapshot (#96433)
javanna 39b7b5e
Synonym Mgmnt API: PUT request (#95895)
carlosdelest b7d9442
Add known issue docs for #95114 (#96448)
DaveCTurner 224d367
Optimize SparseFileTracker (#96379)
original-brownbear 856a244
Reduce overhead in blob cache service get (#96399)
henningandersen e6031d8
Port DLM permissions test to internal REST test style (#96434)
n1v0lg 4617095
Ignore BlobStoreIndexShardSnapshot#indexVersion (#96450)
DaveCTurner 9a8bb61
Known-issue docs for #95454 (#96459)
DaveCTurner b70a1f6
Merge remote-tracking branch 'origin/main' into carlosdelest/synonyms…
carlosdelest e2c3045
WIP
carlosdelest cdf05a0
Removed SynonymsSet class
carlosdelest a69457c
Remove changelog YAML
carlosdelest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
rest-api-spec/src/main/resources/rest-api-spec/api/synonyms.get.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"synonyms.get": { | ||
"documentation": { | ||
"url": "https://www.elastic.co/guide/en/elasticsearch/reference/master/get-synonyms.html", | ||
"description": "Retrieves a synonym set" | ||
}, | ||
"stability": "experimental", | ||
"visibility": "feature_flag", | ||
"feature_flag": "es.synonyms_feature_flag_enabled", | ||
"headers": { | ||
"accept": [ | ||
"application/json" | ||
] | ||
}, | ||
"url": { | ||
"paths": [ | ||
{ | ||
"path": "/_synonyms/{synonyms_set}", | ||
"methods": [ | ||
"GET" | ||
], | ||
"parts": { | ||
"synonyms_set": { | ||
"type": "string", | ||
"description": "The name of the synonyms set to be retrieved" | ||
} | ||
} | ||
} | ||
] | ||
}, | ||
"params": { | ||
"from": { | ||
"type": "int", | ||
"description": "Starting offset (default: 0)" | ||
}, | ||
"size": { | ||
"type": "int", | ||
"description": "specifies a max number of results to get" | ||
} | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/synonyms/20_synonyms_get.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
setup: | ||
- do: | ||
synonyms.put: | ||
synonyms_set: test-get-synonyms | ||
body: | ||
synonyms_set: | ||
- synonyms: "hello, hi" | ||
id: "test-id-1" | ||
- synonyms: "bye => goodbye" | ||
id: "test-id-2" | ||
- synonyms: "test => check" | ||
id: "test-id-3" | ||
|
||
--- | ||
"Get synonyms set": | ||
- skip: | ||
version: " - 8.8.99" | ||
reason: Introduced in 8.9.0 | ||
- do: | ||
synonyms.get: | ||
synonyms_set: test-get-synonyms | ||
|
||
- match: | ||
count: 3 | ||
- match: | ||
synonyms_set: | ||
- synonyms: "hello, hi" | ||
id: "test-id-1" | ||
- synonyms: "bye => goodbye" | ||
id: "test-id-2" | ||
- synonyms: "test => check" | ||
id: "test-id-3" | ||
|
||
--- | ||
"Get synonyms set - not found": | ||
- skip: | ||
version: " - 8.8.99" | ||
reason: Introduced in 8.9.0 | ||
- do: | ||
catch: missing | ||
synonyms.get: | ||
synonyms_set: unknown-synonym-set | ||
|
||
--- | ||
"Pagination - size": | ||
- skip: | ||
version: " - 8.8.99" | ||
reason: Introduced in 8.9.0 | ||
- do: | ||
synonyms.get: | ||
synonyms_set: test-get-synonyms | ||
size: 2 | ||
|
||
- match: | ||
count: 3 | ||
- match: | ||
synonyms_set: | ||
- synonyms: "hello, hi" | ||
id: "test-id-1" | ||
- synonyms: "bye => goodbye" | ||
id: "test-id-2" | ||
|
||
--- | ||
"Pagination - from": | ||
- skip: | ||
version: " - 8.8.99" | ||
reason: Introduced in 8.9.0 | ||
- do: | ||
synonyms.get: | ||
synonyms_set: test-get-synonyms | ||
from: 1 | ||
|
||
- match: | ||
count: 3 | ||
- match: | ||
synonyms_set: | ||
- synonyms: "bye => goodbye" | ||
id: "test-id-2" | ||
- synonyms: "test => check" | ||
id: "test-id-3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
server/src/main/java/org/elasticsearch/action/synonyms/GetSynonymsAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.action.synonyms; | ||
|
||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionRequestValidationException; | ||
import org.elasticsearch.action.ActionResponse; | ||
import org.elasticsearch.action.ActionType; | ||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.common.io.stream.StreamOutput; | ||
import org.elasticsearch.synonyms.SynonymsManagementAPIService; | ||
import org.elasticsearch.synonyms.SynonymsSet; | ||
import org.elasticsearch.xcontent.ToXContentObject; | ||
import org.elasticsearch.xcontent.XContentBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
import static org.elasticsearch.action.ValidateActions.addValidationError; | ||
|
||
public class GetSynonymsAction extends ActionType<GetSynonymsAction.Response> { | ||
|
||
public static final GetSynonymsAction INSTANCE = new GetSynonymsAction(); | ||
public static final String NAME = "cluster:admin/synonyms/get"; | ||
|
||
public GetSynonymsAction() { | ||
super(NAME, Response::new); | ||
} | ||
|
||
public static class Request extends ActionRequest { | ||
private final String SynonymsSetId; | ||
private final int from; | ||
private final int size; | ||
|
||
public Request(StreamInput in) throws IOException { | ||
super(in); | ||
this.SynonymsSetId = in.readString(); | ||
this.from = in.readInt(); | ||
this.size = in.readInt(); | ||
} | ||
|
||
public Request(String SynonymsSetId, int from, int size) { | ||
Objects.requireNonNull(SynonymsSetId, "Synonym set ID cannot be null"); | ||
this.SynonymsSetId = SynonymsSetId; | ||
this.from = from; | ||
this.size = size; | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
ActionRequestValidationException validationException = null; | ||
if (from < 0) { | ||
validationException = addValidationError("from must be a positive integer", validationException); | ||
} | ||
if (size < 0) { | ||
validationException = addValidationError("size must be a positive integer", validationException); | ||
} | ||
return validationException; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
super.writeTo(out); | ||
out.writeString(SynonymsSetId); | ||
out.writeInt(from); | ||
out.writeInt(size); | ||
} | ||
|
||
public String synonymsSetId() { | ||
return SynonymsSetId; | ||
} | ||
|
||
public int from() { | ||
return from; | ||
} | ||
|
||
public int size() { | ||
return size; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Request request = (Request) o; | ||
return from == request.from && size == request.size && Objects.equals(SynonymsSetId, request.SynonymsSetId); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(SynonymsSetId, from, size); | ||
} | ||
} | ||
|
||
public static class Response extends ActionResponse implements ToXContentObject { | ||
|
||
private final SynonymsManagementAPIService.SynonymsSetResult synonymsSetResults; | ||
|
||
public Response(StreamInput in) throws IOException { | ||
super(in); | ||
this.synonymsSetResults = new SynonymsManagementAPIService.SynonymsSetResult(in.readLong(), new SynonymsSet(in)); | ||
} | ||
|
||
public Response(SynonymsManagementAPIService.SynonymsSetResult synonymsSetResult) { | ||
super(); | ||
Objects.requireNonNull(synonymsSetResult, "Synonyms set result must not be null"); | ||
this.synonymsSetResults = synonymsSetResult; | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject(); | ||
{ | ||
builder.field("count", synonymsSetResults.totalSynonymRules()); | ||
synonymsSetResults.synonymsSet().toXContent(builder, params); | ||
} | ||
builder.endObject(); | ||
|
||
return builder; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeLong(synonymsSetResults.totalSynonymRules()); | ||
synonymsSetResults.synonymsSet().writeTo(out); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
Response response = (Response) o; | ||
return Objects.equals(this.synonymsSetResults, response.synonymsSetResults); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(synonymsSetResults); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
server/src/main/java/org/elasticsearch/action/synonyms/TransportGetSynonymsAction.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
package org.elasticsearch.action.synonyms; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.action.support.HandledTransportAction; | ||
import org.elasticsearch.client.internal.Client; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.synonyms.SynonymsManagementAPIService; | ||
import org.elasticsearch.tasks.Task; | ||
import org.elasticsearch.transport.TransportService; | ||
|
||
public class TransportGetSynonymsAction extends HandledTransportAction<GetSynonymsAction.Request, GetSynonymsAction.Response> { | ||
|
||
private final SynonymsManagementAPIService synonymsManagementAPIService; | ||
|
||
@Inject | ||
public TransportGetSynonymsAction(TransportService transportService, ActionFilters actionFilters, Client client) { | ||
super(GetSynonymsAction.NAME, transportService, actionFilters, GetSynonymsAction.Request::new); | ||
|
||
this.synonymsManagementAPIService = new SynonymsManagementAPIService(client); | ||
} | ||
|
||
@Override | ||
protected void doExecute(Task task, GetSynonymsAction.Request request, ActionListener<GetSynonymsAction.Response> listener) { | ||
synonymsManagementAPIService.getSynonymsSet( | ||
request.synonymsSetId(), | ||
request.from(), | ||
request.size(), | ||
listener.map(GetSynonymsAction.Response::new) | ||
); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some refactoring for PUT. It didn't feel right that the
SynonymsManagementAPIService
depended on the request, so I defined the response enum in theSynonymsManagementAPIService
and the response now uses it.