0

I am building a graphQL api with schema and annotations to use AWS Amplify's GraphQL transform. How can I control what kind of ES index it produces behind the scene?

This is a simple API that provides search functionality based on the, lets say, "5 km radius from the current location", timestamp and other keywords. The keywords search work absolutely fine but not the geospatial search. As per my research, for doing geospatial search, one needs to have a specific type of schema in ES. Here is my schema:

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")
}

The query with lat, lon and distance to find "Posts" should return valid results.

Rahul
  • 133
  • 1
  • 7

1 Answers1

0

The short answer to that is no.

The @searchable annotation and AppSyncs functionalities within ES are super limited out of the box. You can't even pass in fuzzy_matches.

I guess the way to go is to implement it yourself. You can modify the resolvers and thus also modify the ES search query. However, the resolvers are written in VST. Which might be not so easy to dig in.

Jakub Juszczak
  • 7,126
  • 3
  • 21
  • 38