首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在类型识别中使用键值存储数组

如何在类型识别中使用键值存储数组
EN

Stack Overflow用户
提问于 2021-08-26 12:49:44
回答 1查看 416关注 0票数 1

我是一个新的类型,我创建了一个模式中的geoloc。

模式

代码语言:javascript
复制
curl "http://localhost:8108/collections" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: xyz" \
        -d '{
              "name": "demo",
              "fields": [
                {"name": "name", "type": "string" },
                {"name": "city", "type": "string" },
                {"name": "country", "type": "string" },
                {"name": "iata_code", "type": "string" },
                {"name": "_geoloc", "type": "string[]" , "facet": true },
                {"name": "links_count", "type": "int32" },
                {"name": "objectID", "type": "string" }
              ]
            }'

我试着用

代码语言:javascript
复制
curl "http://localhost:8108/collections/airports4/documents/import" \
        -X POST \
        -H "Content-Type: application/json" \
        -H "X-TYPESENSE-API-KEY: xyz" \
        -d '
           {"name": "Kalemie","city": "Kalemie","country": "Congo (Kinshasa)","iata_code": "FMI","_geoloc": { "lat" : -5.875556 ,  "long" : 29.25 },"links_count":1,"objectID": "1040"}'

但是它返回一个错误

代码语言:javascript
复制
{"code":400,"document":"{","error":"Bad JSON: [json.exception.parse_error.101] parse error at line 1, column 2: syntax error while parsing object key - unexpected end of input; expected string literal","success":false}
{"code":400,"document":"\t\"name\": \"Kalemie\",","error":"Bad JSON: [json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected ':'; expected end of input","success":false}
{"code":400,"document":"\t\"city\": \"Kalemie\",","error":"Bad JSON: [json.exception.parse_error.101] parse error at line 1, column 8: syntax error while parsing value - unexpected ':'; expected end of input","success":false}
{"code":400,"document":"\t\"country\": \""Congo (Kinshasa)\",","error":"Bad JSON: [json.exception.parse_error.101] parse error at line 1, column 11: syntax error while parsing value - unexpected ':'; expected end of input","success":false}
{"code":400,"document":"\t\"iata_code\": \"FMI\",","error":"Bad JSON: [json.exception.parse_error.101] parse error at line 1, column 13: syntax error while parsing value - unexpected ':'; expected end of input","success":false}
{"code":400,"document":"\t\"_geoloc\" : [{\"lat\":-5.875556 , \"lng\": 29.25 }],","error":"Bad JSON: [json.exception.parse_error.101] parse error at line 1, column 12: syntax error while parsing value - unexpected ':'; expected end of input","success":false}
{"code":400,"document":"\t\"links_count\": 1,","error":"Bad JSON: [json.exception.parse_error.101] parse error at line 1, column 15: syntax error while parsing value - unexpected ':'; expected end of input","success":false}
{"code":400,"document":"\t\"objectID\": \"1040\"","error":"Bad JSON: [json.exception.parse_error.101] parse error at line 1, column 12: syntax error while parsing value - unexpected ':'; expected end of input","success":false}
{"code":400,"document":"}","error":"Bad JSON: [json.exception.parse_error.101] parse error at line 1, column 1: syntax error while parsing value - unexpected '}'; expected '[', '{', or a literal","success":false}

我不知道如何用lat long存储_geoloc。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-08-27 14:48:07

您必须使用geopoint类型的字段。

下面是文档中的一个示例:https://typesense.org/docs/0.21.0/api/documents.html#geosearch

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68938830

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档