doraemon0769 2019-05-24 12:31
浏览 204

Elasticsearch \ RuntimeException:JSON编码失败:第33行文件/Elasticsearch/Serializers/SmartSerializer.php中的5

I am trying to run a project that uses elasticsearch on my computer. But at the point that the API. Queries something from elasticsearch I get the following error and the query does not execute:

Elasticsearch\Common\Exceptions\RuntimeException: Failed to JSON encode: 5 in file /Users/sobhan.bagheri/projects/laravel/regionsdelen-api/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Serializers/SmartSerializer.php on line 33

I am using: laravel framework with valet - php7.1 - elasticsearch 6.1.2 - and elasticsearch/elasticsearch:v6.0.1 for the driver.

I tried everything like changing elasticsearch to newer or older versions. Changing the way of the client connects to elasticsearch and also changed versions of the elasticsearch/elasticsearch driver but nothing seems to work.

btw: those versions I mentioned are the exact ones running on another machine without this error.

P.S: This error only occurres when I query a swedish character.

  • 写回答

1条回答 默认 最新

  • duanke6249 2019-08-01 11:45
    关注

    I also was facing the same problem. For me, the issue was that string contained special character which creates an issue while encoding to JSON so try this.

    $array= array_map('utf8_encode', $array);

    Hopefully, this will work for you.

    评论

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用