有没有办法通过放大GraphQL变换@searchable注释来控制自动生成的弹性搜索索引?

问题描述 投票:0回答:1

我正在使用架构和注释构建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查询“Posts”的查询应返回有效结果。

annotations graphql geospatial aws-amplify aws-elasticsearch
1个回答
0
投票

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

ES中的@searchable注释和AppSyncs功能是开箱即用的超级限制。你甚至无法传递fuzzy_matches。

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

© www.soinside.com 2019 - 2024. All rights reserved.