0

我正在构建一个带有模式和注释的 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 查找“帖子”的查询应返回有效结果。

4

1 回答 1

0

对此的简短回答是否定的。

ES 中的@searchable注释和 AppSyncs 功能开箱即用是非常有限的。你甚至不能传入fuzzy_matches。

我想要走的路是自己实现它。您可以修改解析器,因此也可以修改 ES 搜索查询。但是,解析器是用 VST 编写的。这可能不是那么容易挖掘。

于 2019-02-12T14:07:04.080 回答