DEV Community

Cover image for Amplify Algolia Search
Chris Finn
Chris Finn

Posted on

1 1

Amplify Algolia Search

I built a custom directive to enable searching with Algolia:
https://github.com/thefinnomenon/graphql-algolia-transformer

It has been a pleasure building MVPs with Amplify but I was annoyed at the monthly cost of Elasticsearch and wanted a search that fits the Serverless "pay per use" model -- enter Algolia. It has a decent free monthly quota so you can make a low cost MVP or small app. It also has a really simple management interface and solid client libraries and UI widgets.

I created a simple searchable blog example (which turned more into a recipe search 😆) that can be found in the Github repo. If you need to add search to your Amplify project, give this transformer a shot.

type Blog @model {
  id: ID!
  name: String!
  posts: [Post] @connection(keyName: "byBlog", fields: ["id"])
}

type Post @model @algolia(fields:{include:["title"]}) @key(name: "byBlog", fields: ["blogID"]) {
  id: ID!
  title: String!
  blogID: ID!
  blog: Blog @connection(fields: ["blogID"])
  comments: [Comment] @connection(keyName: "byPost", fields: ["id"])
}

type Comment @model @key(name: "byPost", fields: ["postID", "content"]) {
  id: ID!
  postID: ID!
  post: Post @connection(fields: ["postID"])
  content: String!
}
Enter fullscreen mode Exit fullscreen mode
Retry later

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay