Skip to content

Support fields under body as well as in url for field_caps API. #86875

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
pryadko opened this issue May 18, 2022 · 12 comments · Fixed by #88972
Closed

Support fields under body as well as in url for field_caps API. #86875

pryadko opened this issue May 18, 2022 · 12 comments · Fixed by #88972
Labels
>enhancement good first issue low hanging fruit help wanted adoptme :Search/Search Search-related issues that do not fall into other categories Team:Search Meta label for search team

Comments

@pryadko
Copy link

pryadko commented May 18, 2022

Description

Before ES 7.x it was possible to provide a list of fields by URL or BODY request for field_caps API.
https://www.elastic.co/guide/en/elasticsearch/reference/6.8/search-field-caps.html
POST _field_caps { "fields" : ["rating"] }

Starting from 7.x this feature was removed, and only one possible way it uses URI but in this case, it is possible to have an error 414 (Request-URI Too Long).

I would like to return this feature back.

@pryadko pryadko added >enhancement needs:triage Requires assignment of a team area label labels May 18, 2022
@jtibshirani jtibshirani added :Search/Search Search-related issues that do not fall into other categories and removed needs:triage Requires assignment of a team area label labels May 18, 2022
@elasticmachine elasticmachine added the Team:Search Meta label for search team label May 18, 2022
@elasticmachine
Copy link
Collaborator

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

@jtibshirani
Copy link
Contributor

jtibshirani commented May 19, 2022

@pryadko I had a few questions to make sure we have all the context.

  • First, where are you receiving the error "414 Request-URI Too Long"? Is it from a proxy layer, client, or Elasticsearch itself?
  • Also, what is your use case for providing all these fields? Is it possible to use field name patterns (like *) instead of specifying the fields individually?

@pryadko
Copy link
Author

pryadko commented May 19, 2022

@jtibshirani
This error comes from the Elasticsearch server.
* isn't an option because you may receive fields that you don't request
use case - the user wants to know mappings for some specific fields.

@javanna
Copy link
Member

javanna commented Jun 1, 2022

This is somehow similar to #61141 , but for fields and very specific to the field_caps API. I do worry that there are possibly many other places where a similar change should be made if we go down this route. I marked it for discussion with the team.

@jtibshirani
Copy link
Contributor

@pryadko sorry for the slow reply. I discussed with the team, and confirmed that Elasticsearch should not be throwing "414 "Request-URI Too Long". This must be coming from some other place, like a web server. Maybe it's possible to change the server configuration to allow larger requests?

We also recognized how the change we made could cause inconvenience. In other places like search you can pass parameters like fields in the body.

@pryadko
Copy link
Author

pryadko commented Jun 13, 2022

@jtibshirani thank you for your answer.
Allowing larger requests on ES server doesn't really solve this issue because nobody guarantee that tomorrow we won't have "414 "Request-URI Too Long" for some combination of request, also I don't think it is good idea to configure ES server in such a way to allow actually any request with such long URI.

Do you have a plan to fix this? or it still continues discussion?
It will be good to allow user to choose which way to provide fields via URI or payload.

@jtibshirani
Copy link
Contributor

We don't have immediate plans to change this. The motivation for removing the ability to specify fields in the body was that we wanted only one way to specify the parameter. When there are multiple ways, it's unclear which one takes precedence (or if they're somehow merged together). This is part of our API design guidelines so we'd prefer not to undo that change.

We are still discussing the topic internally though, I'll post an update if anything changes.

@pryadko
Copy link
Author

pryadko commented Jun 13, 2022

@jtibshirani thanks,
I see it as a general issue for all APIs

https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html#search-search-api-query-params

Several options for this API can be specified using a query parameter or a request body parameter. If both parameters are specified, only the query parameter is used.

I'm looking forward to your decision.

@jtibshirani
Copy link
Contributor

@elastic/es-clients do you have a suggestion for how to move forward? We want to avoid making a breaking change, like removing the ability to pass fields through a URI parameter. I see two options:

  • Re-add support for fields in the request body. This violates our convention of "one single way to pass a parameter", but follows the convention of "passing variable-length request components in the request body".
  • Just close without making changes to minimize disruption.

@jtibshirani jtibshirani added help wanted adoptme and removed team-discuss labels Jun 21, 2022
@jtibshirani
Copy link
Contributor

We discussed offline and decided to re-add support for fields in the request body. We do not want to deprecate passing fields in the URI, as this could place a burden on users upgrading. This seemed like the best compromise given the situation.

I don't think I have time to tackle this soon, but I am marking it as "help wanted".

@pryadko
Copy link
Author

pryadko commented Jun 21, 2022

@jtibshirani thank you, I will try to help with this.

@javanna javanna added the good first issue low hanging fruit label Jun 21, 2022
@javanna javanna changed the title Make posible to provide fields under body as well as in url for field_caps API. Support fields under body as well as in url for field_caps API. Jun 21, 2022
@gcamach0
Copy link

gcamach0 commented Jul 5, 2022

Hi! I would love to help, you think I can give it a try?

pull bot pushed a commit to NOUIY/elasticsearch that referenced this issue Aug 4, 2022
…uest body (elastic#88972)

We previously removed support for `fields` in the request body, to ensure there
was only one way to specify the parameter. We've now decided to undo the
change, since it was disruptive and the request body is actually the best place to
pass variable-length data like `fields`.

This PR restores support for `fields` in the request body. It throws an error
if the parameter is specified both in the URL and the body.

Closes elastic#86875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement good first issue low hanging fruit 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

Successfully merging a pull request may close this issue.

5 participants