Cache Memory only works with numbers #2537
-
I did expect that the This works: input:
generate:
mapping: |
root = {}
pipeline:
processors:
- branch:
processors:
- cache:
resource: stringstore
operator: get
key: name
result_map: 'root.name = this'
output:
stdout: {}
cache_resources:
- label: stringstore
memory:
init_values:
name: "0"
And this does not work: input:
generate:
mapping: |
root = {}
pipeline:
processors:
- branch:
processors:
- cache:
resource: stringstore
operator: get
key: name
result_map: 'root.name = this'
output:
stdout: {}
cache_resources:
- label: stringstore
memory:
init_values:
name: "dan"
Is it a bug or a feature? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey @danriedl 👋 It's by design. Values in caches are stored as bytes, so PS: Converting this to a discussion as per #2026. |
Beta Was this translation helpful? Give feedback.
Hey @danriedl 👋 It's by design. Values in caches are stored as bytes, so
this
will throw an error if the data it gets isn't something that can be parsed using a JSON parser. What you want to use there isroot.name = content().string()
. The.string()
part is needed because otherwise the data in thatname
field will get serialised back to JSON using base64 encoding.PS: Converting this to a discussion as per #2026.