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

Discrepancy between multisearch and multisearch template response formats. #83029

Closed
swallez opened this issue Jan 25, 2022 · 6 comments
Closed
Labels
>bug help wanted adoptme :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team

Comments

@swallez
Copy link
Member

swallez commented Jan 25, 2022

Elasticsearch version (bin/elasticsearch --version): 7.16, 8.0, 8.1.

Description of the problem including expected versus actual behavior:

The format of the multisearch response and the multisearch template response are different. The former adds a status field in every response item while the latter does not. I guess this is a discrepancy that was introduced when one was updated and not the other.

Reported by a user of the Java API Client: elastic/elasticsearch-java#110, workaround added to the API specification: elastic/elasticsearch-specification#1320

MultiSearchResponse:

public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
builder.startObject();
builder.field("took", tookInMillis);
builder.startArray(Fields.RESPONSES);
for (Item item : items) {
builder.startObject();
if (item.isFailure()) {
ElasticsearchException.generateFailureXContent(builder, params, item.getFailure(), true);
builder.field(Fields.STATUS, ExceptionsHelper.status(item.getFailure()).getStatus());
} else {
item.getResponse().innerToXContent(builder, params);
builder.field(Fields.STATUS, item.getResponse().status().getStatus());
}
builder.endObject();
}
builder.endArray();
builder.endObject();
return builder;
}

MultiSearchTemplateResponse:

public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
builder.startObject();
builder.field("took", tookInMillis);
builder.startArray(Fields.RESPONSES);
for (Item item : items) {
if (item.isFailure()) {
builder.startObject();
ElasticsearchException.generateFailureXContent(builder, params, item.getFailure(), true);
builder.endObject();
} else {
item.getResponse().toXContent(builder, params);
}
}
builder.endArray();
builder.endObject();
return builder;
}

@swallez swallez added >bug needs:triage Requires assignment of a team area label labels Jan 25, 2022
@nik9000 nik9000 added :Search/Search Search-related issues that do not fall into other categories team-discuss and removed needs:triage Requires assignment of a team area label labels Jan 26, 2022
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jan 26, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@javanna
Copy link
Member

javanna commented Jan 27, 2022

Good catch, status was added to multi search responses with #18586 and should have been added to msearch template too. Would be nice to share some code between the two if possible.

@javanna javanna added help wanted adoptme and removed team-discuss labels Jan 27, 2022
@AbeleMM
Copy link
Contributor

AbeleMM commented Mar 29, 2022

@javanna Hey! Sorry for resurrecting the issue, but I wondered if help is still wanted for it. If so, I think I have a fix, so I would be happy to submit a PR and have it checked out.

@javanna
Copy link
Member

javanna commented Mar 29, 2022

Help is still wanted, please go ahead @AbeleMM !

@cbuescher
Copy link
Member

@swallez we are going to add the "status" field by default in 8.3 with #85496, just pinging you in case there are any follow ups or actions for the clients team in that case.

@swallez
Copy link
Member Author

swallez commented May 20, 2022

Thanks @cbuescher! I've opened elastic/elasticsearch-specification#1721 so that we update the API specification for 8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug help wanted adoptme :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team
Projects
None yet
Development

No branches or pull requests

6 participants