【问题标题】:Is there a way to control auto generated Elastic Search Index with amplify GraphQL transform @searchable annotation?有没有办法通过放大 GraphQL 转换 @searchable 注释来控制自动生成的弹性搜索索引?
【发布时间】:2019-05-27 03:37:38
【问题描述】:

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

【问题讨论】:

    标签: annotations graphql geospatial aws-amplify aws-elasticsearch


    【解决方案1】:

    对此的简短回答是否。

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

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

    【讨论】:

    • 这有改变吗?从 dev 创建 prod 环境时,没有一个索引是在 ES 上创建的。不知道该怎么办。
    猜你喜欢
    • 1970-01-01
    • 2018-08-20
    • 2019-10-10
    • 1970-01-01
    • 1970-01-01
    • 2020-06-30
    • 2020-03-02
    • 2010-10-01
    • 2015-12-13
    相关资源
    最近更新 更多