主键不能是字符串?

问题描述

定义架构就像这样:

field id type string {
                indexing: summary | index
            }

然后发布一些数据

curl --location --request POST 'http://xxxxxxx:xxx/document/v1/mt_challenge/mt_challenge/docid/1680092807002114?create=true' --header 'Content-Type: application/json' --data-raw ' {"fields": {"id": {"assign": "1680092807002114"}}}'

然后返回

{"errors":[{"description":"UNSPECIFIED Has created a composite field value the reader does not kNow how to handle: com.yahoo.document.datatypes.StringFieldValue This is a bug. token = START_OBJECT","id":-15}],"id":"id:mt_challenge:mt_challenge::1680092807002114","pathId":"/document/v1/mt_challenge/mt_challenge/docid/1680092807002114"}

解决方法

POST 用于创建文档,PUT 用于更新。在这里,您使用 POST 和使用 assign 产生错误。

POST(创建)的正确语法:

curl --location --request POST 'http://xxxxxxx:xxx/document/v1/mt_challenge/mt_challenge/docid/1680092807002114?create=true' --header 'Content-Type: application/json' --data-raw ' {"fields": {"id":"1680092807002114"}}'