Revolyssup opened a new pull request, #12364:
URL: https://github.com/apache/apisix/pull/12364

   Fixes #
   ![Screenshot From 2025-06-23 
12-29-02](https://github.com/user-attachments/assets/00fc81be-2134-496c-9dce-c8196dcf87be)
   
   
   
   It's the issue of header incompatibility. I have also reproduced the issue 
and the fix.
   If you're on X version of Elasticsearch server then you can allow requests 
coming from client with version X-1 by putting them in the header.
   This means server with version 8 can support requests from 7 with 
compatible-with=7. But when Elasticsearch server is version 9, this will break 
as it can only support compatible-with=8.
   This means our current implementation will need to support multiple versions 
and not hardcode to 7 or 8.
   Since our usage is pretty simple and we use the bulk API to POST logs, no 
change is needed in request body format. Although there is one change that I 
propose in the last point below.
   
   Proposed solution
   We should add a field version in the elasticsearch plugin config to allow 
users to configure which version they are using. Current supported versions 
will be 7,8,9
   When user specifies 7, no compatibility headers needed.
   When user specifies 8, compatible-with=7 header.
   When user specifies 9, compatible-with=8 header.
   
   When user version 9, we should [not support the type 
field](https://github.com/apache/apisix/blob/7d5aeafdb442151667be95ad4ebc37cd3b1fa6bb/t/plugin/elasticsearch-logger.t#L692)
 as it is deprecated as shown in the docs. Till version 8, the problem can be 
avoided with compatible-with=7 heade but on version 9 we cant be compat with 
version 7 so it should be removed. Currently this field is set by plugin conf. 
We can enforce in schema that when Elasticsearch server version is 9, this 
field is not supported as it's deprecated.
   
   I have used the current tests with Elasticsearch version 9 to confirm the 
same error log as given in task. And by making the above changes, I can pass 
the tests.
   
   References:
   https://www.elastic.co/docs/reference/elasticsearch/rest-apis/compatibility
   
https://www.elastic.co/guide/en/elasticsearch/reference/8.18/rest-api-compatibility.html
   https://github.com/elastic/elasticsearch-ruby/issues/2665
   ### Checklist
   
   - [ ] I have explained the need for this PR and the problem it solves
   - [ ] I have explained the changes or the new features added to this PR
   - [ ] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change
   - [ ] I have verified that this change is backward compatible (If not, 
please discuss on the [APISIX mailing 
list](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to