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
ElasticSearch can't parse celery result correctly #5660
Comments
This depends on #5661 |
The proposed patch is not enough. |
Hey folks, just wanted shamelessly add a +1. My use case is the same, but I'm afraid I don't have the skillset to improve it in the way @thedrow mentioned myself. |
Of course you do. See the documentation for details. from kombu import serialization
serialization.register(
'elasticsearch', lambda x: x, lambda x: x,
content_type='application/x-elasticsearch',
) Try using it and let me know if that resolves your issue. |
I'm confirming that @thedrow example does indeed work for me. I registered the serializer before my Celery app object and then set Keep in mind, this is converting from a string to an object and Elasticsearch won't let you do that inthe same index. Better to version the index name to not clash on types. |
Scratch that! There is a issue with this method. Unless you can guarantee the
The result itself needs to be serialized in some way it seems (maybe the result is JSON but everything else can be native fields). |
@andyshinn due to the Elasticsearch's dynamic mapping feature, the mapping is created when a document that contains a field is indexed. You cannot alter the field type in subsequent indexing requests, since that would cause be a mapping incompatibility. I don't think we can find a generic solution for this issue, but it could be handled by your custom serializer instead. |
Any updates regarding this issue? |
None unfortunately. |
As #5661 is fixed, I think it is easier now to make a patch for this. |
This should be fixed by #6141. You can now set |
@auvipy you can close this issue! 👍 |
thanks @safwanrahman |
@auvipy that's the wrong milestone, isn't it? |
yes it should be on 4.4.0 which is closed |
Was this released on 4.4.0? |
no sorry, I recheck and got https://github.com/celery/celery/blob/v4.5/Changelog.rst#444 so the 4.4.x milestone could be OK for the already released version I guess. |
Checklist
contribution guide
on reporting bugs.
for similar or identical bug reports.
for existing proposed fixes.
to find out if the bug was already fixed in the master branch.
in this issue (If there are none, check this box anyway).
Mandatory Debugging Information
celery -A proj report
in the issue.(if you are not able to do this, then at least specify the Celery
version affected).
master
branch of Celery.pip freeze
in the issue.to reproduce this bug.
Optional Debugging Information
and/or implementation.
result backend.
broker and/or result backend.
ETA/Countdown & rate limits disabled.
and/or upgrading Celery and its dependencies.
Related Issues and Possible Duplicates
Related Issues
Possible Duplicates
Environment & Settings
Celery version: 4.3.0
celery report
Output:Steps to Reproduce
Add elasticsearch as backend
Run any command
Required Dependencies
Python Packages
pip freeze
Output:Other Dependencies
N/A
Minimally Reproducible Test Case
Expected Behavior
Result is sent as a dictionary. At
body
dictionary creation, result added as inner dictionary, not as a string. Correct mapping is created. Results in Elasticsearch will be shown correctly and nested type could be used.Correct mapping example:
Kibana:
Actual Behavior
Result value is serialized into a JSON string. At
body
dictionary creation, result added as a string. Elasticsearch can't parse it correctly.Actual mapping:
Kibana:
My stackoverflow question
Solution
In my fork I've imported
json package
and addedjson.loads(value)
:Is there a way to disable JSON serialization of results for the Elasticsearch backend? If no, is this solution good enough for the pull-request?
The text was updated successfully, but these errors were encountered: