Skip to content

Long _source_excludes/_source_includes passed in query parameter, HTTP 400 'too long http line exception' #2824

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
plexaikm opened this issue Mar 5, 2025 · 3 comments
Labels
Area: Client Manually written code that fits in no other area Category: Question

Comments

@plexaikm
Copy link

plexaikm commented Mar 5, 2025

Using search with list of long named parameters in es.search _source_excludes/_source_includes fails with HTTP 400 'too long http line exception'

Elasticsearch 8.14.1 and python Elasticsearch client 8.14.0

es.search(
...
_source_includes=[... list of fields ...],
_source_excludes=[... list of fields ...],
...
)

POST .../_search:
the _source_excludes/_source_includes are passed as query parameters bloating the http line,
can be passed in request body _source.excludes/_source.includes to avoid this issue

GET _mget:
same solution can be applied

Same issue with GET .../_doc/... but there no easy way around

@pquentin
Copy link
Member

pquentin commented Mar 5, 2025

Hello, and thanks for your question. Unfortunately, there's nothing I can do with the client, this is the default value in Netty. If you're hosting Elasticsearch yourself, you can tune http.max_initial_line_length wich default to 4096.

Otherwise, you can use the mget API or try to reduce the list of fields, possibly by using regexes.

@plexaikm
Copy link
Author

plexaikm commented Mar 5, 2025

Hi,
Thank you for the reply and suggestion to alter parameter, yes it is self hosted so I can try it

For search/mget the client can put the lists of includes/excludes in body and not in query parameters

I'm trying a local workaround using es.search(body=es_body) which is deprecated

es_body = {
"query": ...
"_source": {
"includes": [... list of fields ...],
"excludes": [... list of fields ...]
}
...
}

@pquentin
Copy link
Member

pquentin commented Mar 6, 2025

This is no longer deprecated, what version are you using? You can also pass individual parameters like source and query.

That said I would caution against using search, it is more expensive than get or mget and requires a refresh for read after write operations.

@pquentin pquentin added Area: Client Manually written code that fits in no other area Category: Question labels Mar 7, 2025
@pquentin pquentin closed this as completed Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Client Manually written code that fits in no other area Category: Question
Projects
None yet
Development

No branches or pull requests

2 participants