Search Error Unexpected token ' in JSON at position N

Hello
I'm running an elasticsearch cluster with kibana in docker.
when i'm trying to create a pie chart and use Terms aggregation i got this error :

Search Error
Unexpected token ' in JSON at position 433

same thing work fine using line chart or if i used filter aggregation instead of Terms in pie chart.

  • elastisearch version : 7.11.0
  • kibana version : 7.11.0

I have same deployment in local and I did not encounter this problem.

That sounds an awful lot like a bug. Could you export the failing visualization you built and post the resulting file here? That will make it easier to debug what goes wrong here.

Are you using the "Advanced JSON" functionality?

thanks for your reply,
No I don't use Advanced Json functionality.
here is the whole error message :

Search Error

Unexpected token ' in JSON at position 433

SyntaxError: Unexpected token ' in JSON at position 433
    at JSON.parse (<anonymous>)
    at fn (https://*kibana-url*/37897/bundles/plugin/visTypeVislib/visTypeVislib.plugin.js:1:31468)
    at ExpressionFunction.fn (https://*kibana-url*/37897/bundles/plugin/expressions/expressions.plugin.js:1:128388)
    at _callee2$ (https://*kibana-url*/37897/bundles/plugin/expressions/expressions.plugin.js:1:65573)
    at l (https://*kibana-url*/37897/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:321:968491)
    at Generator._invoke (https://*kibana-url*/37897/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:321:968244)
    at Generator.forEach.e.<computed> [as next] (https://*kibana-url*/37897/bundles/kbn-ui-shared-deps/kbn-ui-shared-deps.js:321:968848)
    at asyncGeneratorStep (https://*kibana-url*/37897/bundles/plugin/expressions/expressions.plugin.js:1:57468)
    at _next (https://*kibana-url*/37897/bundles/plugin/expressions/expressions.plugin.js:1:57779)
    at https://*kibana-url*/37897/bundles/plugin/expressions/expressions.plugin.js:1:57929

Can you please export the visualization and paste it here? You can do this by going to Management > Saved objects : Saved Objects | Kibana Guide [7.11] | Elastic

Ok, this is what you ask

    {"attributes":{"fieldAttrs":"{\"Présence d'allergies\":{\"count\":2},\"0000000000000011\":{\"count\":1},\"_id\":{\"count\":1}}","fields":"[]","title":"data"},"id":"4c9f6790-750a-11eb-b3b3-035fd300da33","migrationVersion":{"index-pattern":"7.11.0"},"references":[],"type":"index-pattern","updated_at":"2021-02-27T20:06:01.825Z","version":"Wzc5NTUsMl0="}
{"attributes":{"description":"Unexpected token ' in JSON at position 433","kibanaSavedObjectMeta":{"searchSourceJSON":"{\"query\":{\"query\":\"\",\"language\":\"kuery\"},\"filter\":[],\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.index\"}"},"title":"Error ","uiStateJSON":"{}","version":1,"visState":"{\"title\":\"Error \",\"type\":\"pie\",\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"params\":{},\"schema\":\"metric\"},{\"id\":\"2\",\"enabled\":true,\"type\":\"terms\",\"params\":{\"field\":\"Présence d'allergies.keyword\",\"orderBy\":\"1\",\"order\":\"desc\",\"size\":5,\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\"},\"schema\":\"segment\"}],\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":false,\"values\":true,\"last_level\":true,\"truncate\":100}}}"},"id":"c6b99f80-7a9d-11eb-b183-7b4b720dbafe","migrationVersion":{"visualization":"7.11.0"},"references":[{"id":"4c9f6790-750a-11eb-b3b3-035fd300da33","name":"kibanaSavedObjectMeta.searchSourceJSON.index","type":"index-pattern"}],"type":"visualization","updated_at":"2021-03-01T14:52:42.750Z","version":"WzEwODMxLDNd"}
{"exportedCount":2,"missingRefCount":0,"missingReferences":[]}

I see, the ' in the field name is breaking it. I tested a bit and this problem seems to be isolated to the pie chart (metric chart for example works fine)

I opened an issue for this here: Pie: Field names are not escaped in expression · Issue #93069 · elastic/kibana · GitHub

For now you should be able to use Lens instead - it also features a pie chart and as far as I can tell is not affected by this bug

1 Like

Thank you very much for your responsiveness. while waiting for a fix for pie chart, i will use lens, it works correctly.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.