Is your feature request related to a problem?
note: i'm using the ApacheHttpClient5Transport APIs.
i'm doing a request through OpenSearchClient#create because the API allows me to ensure that a document is only indexed once, as per the javadoc:
|
/** |
|
* Creates a new document in the index. |
|
* <p> |
|
* Returns a 409 response when a document with a same ID already exists in the |
|
* index. |
|
* |
|
* |
|
*/ |
|
|
|
public <TDocument> CreateResponse create(CreateRequest<TDocument> request) throws IOException, OpenSearchException { |
however, if the document with this ID already exists then the API throws an exception instead of returning a response. and while the ResponseException would offer access to the actual Response:
|
public Response getResponse() { |
|
return response; |
|
} |
which would also offer access to the HTTP status via
StatusLine:
|
public StatusLine getStatusLine() { |
|
return new StatusLine(response); |
|
} |
the problem is that
Response is package-private, so i cannot access any of its methods (even though they're marked as
public):
What solution would you like?
there should be a clear, canonical (and documented) way of accessing the HTTP status if such a request fails.
one possibility could be to make Response public (i don't understand why it isn't).
What alternatives have you considered?
parsing the exception as a string to see if it contains "[HTTP/1.1 409 Conflict]" is at best an ugly hack as the string is not a guaranteed API
Do you have any additional context?
i wasn't sure whether to categorise this as a feature request (because it needs a new API to be exposed), a bug report (because i consider it wrong that i can't access this information) or a question (because i might just have missed a way of getting to that information; in that case it'd be good if it could be documented as i didn't find it in this repo!).
Is your feature request related to a problem?
note: i'm using the
ApacheHttpClient5TransportAPIs.i'm doing a request through
OpenSearchClient#createbecause the API allows me to ensure that a document is only indexed once, as per the javadoc:opensearch-java/java-client/src/main/java/org/opensearch/client/opensearch/OpenSearchClient.java
Lines 329 to 338 in c0f51d0
however, if the document with this ID already exists then the API throws an exception instead of returning a response. and while the
ResponseExceptionwould offer access to the actualResponse:opensearch-java/java-client/src/main/java/org/opensearch/client/transport/httpclient5/ResponseException.java
Lines 92 to 94 in c0f51d0
which would also offer access to the HTTP status via
StatusLine:opensearch-java/java-client/src/main/java/org/opensearch/client/transport/httpclient5/Response.java
Lines 84 to 86 in c0f51d0
the problem is that
Responseis package-private, so i cannot access any of its methods (even though they're marked aspublic):opensearch-java/java-client/src/main/java/org/opensearch/client/transport/httpclient5/Response.java
Line 52 in c0f51d0
What solution would you like?
there should be a clear, canonical (and documented) way of accessing the HTTP status if such a request fails.
one possibility could be to make
Responsepublic (i don't understand why it isn't).What alternatives have you considered?
parsing the exception as a string to see if it contains "[HTTP/1.1 409 Conflict]" is at best an ugly hack as the string is not a guaranteed API
Do you have any additional context?
i wasn't sure whether to categorise this as a feature request (because it needs a new API to be exposed), a bug report (because i consider it wrong that i can't access this information) or a question (because i might just have missed a way of getting to that information; in that case it'd be good if it could be documented as i didn't find it in this repo!).