我正在构建一个带有模式和注释的 graphQL api,以使用 AWS Amplify 的 GraphQL 转换。如何控制它在幕后产生什么样的 ES 索引?
这是一个简单的 API,它提供基于“距当前位置 5 公里半径”、时间戳和其他关键字的搜索功能。关键字搜索工作得很好,但地理空间搜索却不行。根据我的研究,为了进行地理空间搜索,需要在 ES 中具有特定类型的模式。这是我的架构:
type User @model {
id: ID!
deviceID: [String!]
posts: [Post] @connection(name: "UserPosts")
comments: [Comment] @connection(name: "UserComments")
}
type Post @model @searchable {
id: ID!
items: String!
latitude: Float
longitude: Float
user: User @connection(name: "UserPosts")
comments: [Comment] @connection(name: "PostComments")
}
type Comment @model {
id: ID!
content: String
timestamp: AWSDateTime
location: String
post: Post @connection(name: "PostComments")
user: User @connection(name: "UserComments")
}
使用 lat、lon 和 distance 查找“帖子”的查询应返回有效结果。