Giter Club home page Giter Club logo

guangminglion / firestore-typesense-search Goto Github PK

View Code? Open in Web Editor NEW

This project forked from typesense/firestore-typesense-search

0.0 1.0 0.0 536 KB

Firebase Extension to automatically push Firestore documents to Typesense for full-text search with typo tolerance, faceting, and more

Home Page: https://console.firebase.google.com/project/_/extensions/install?ref=typesense/firestore-search-extension

License: Apache License 2.0

JavaScript 97.21% Shell 2.79%

firestore-typesense-search's Introduction

Firestore / Firebase Typesense Search Extension ⚡ 🔍

CircleCI

A Firebase extension to sync data from your Firestore collection to Typesense, to be able to do full-text fuzzy search on your Firestore data, with typo tolerance, faceting, filtering, sorting, curation, synonyms, geosearch and more.

This extension listens to your specified Firestore collection and syncs Firestore documents to Typesense on creation, updates and deletes. It also provides a function to help you backfill data.

What is Typesense?

If you're new to Typesense, it is an open source search engine that is simple to use, run and scale, with clean APIs and documentation. Think of it as an open source alternative to Algolia and an easier-to-use, batteries-included alternative to ElasticSearch. Get a quick overview from this guide.

⚙️ Usage

1. Setup Prerequisites

Before installing this extension, make sure that you have:

  1. Set up a Cloud Firestore database in your Firebase project.
  2. Setup a Typesense cluster (on Typesense Cloud or Self-Hosted).
  3. Setup a Typesense Collection either through the Typesense Cloud dashboard or through the API.

2. Install the Extension

You can install this extension either through the Firebase Web console or through the Firebase CLI.

Firebase Console

Install this extension in your Firebase project

Firebase CLI
firebase ext:install typesense/firestore-typesense-search --project=[your-project-id]

Learn more about installing extensions in the Firebase Extensions documentation:

3. Backfilling data (optional)

This extension only syncs data that was created or changed in Firestore, after it was installed. In order to backfill data that already exists in your Firestore collection to your Typesense Collection:

  • Create a new Firestore collection called typesense_sync through the Firestore UI.
  • Create a new document with the ID backfill and contents of {trigger: true}

This will trigger the backfill background Cloud function, which will read data from your Firestore collection and create equivalent documents in your Typesense collection.

🧾 Billing

To install an extension, your project must be on the Blaze (pay as you go) plan.

  • You will be charged a small amount (typically around $0.01/month) for the Firebase resources required by this extension (even if it is not used).
  • This extension uses other Firebase and Google Cloud Platform services, which have associated charges if you exceed the service’s free tier:
    • Cloud Firestore
    • Cloud Functions (Node.js 14+ runtime. See FAQs)
  • Usage of this extension also requires you to have a running Typesense cluster either on Typesense Cloud or some self-hosted server. You are responsible for any associated costs with these services.

🎛️ Configuration Parameters

When you install this extension, you'll be able to configure the following parameters:

Parameter Description
Firestore Collection Path The Firestore collection that needs to be indexed into Typesense.
Firestore Collection Fields A comma separated list of fields that need to be indexed from each Firestore document. Leave blank to index all fields.
Typesense Hosts A comma-separated list of Typesense Hosts. For single node clusters, a single hostname is sufficient. For multi-node Highly Available or SDN Clusters, please be sure to mention all hostnames.
Typesense API Key An Typesense API key with admin permissions. Click on "Generate API Key" in cluster dashboard in Typesense Cloud.
Typesense Collection Name Typesense collection name to index data into.
Cloud Functions location Where do you want to deploy the functions created for this extension? You usually want a location close to your database. For help selecting a location, refer to the location selection guide.

☁️ Cloud Functions

  • indexToTypesenseOnFirestoreWrite: A function that indexes data into Typesense when it's triggered by Firestore changes.

  • backfillToTypesenseFromFirestore: A function that backfills data from a Firestore collection into Typesense, triggered when a Firestore document with the path typesense_sync/trigger has the contents of backfill: true.

🔑 Access Required

This extension will operate with the following project IAM roles:

  • datastore.user (Reason: Required to backfill data from your Firestore collection into Typesense)

Development Workflow

Run Emulator

npm run emulator
npm run typesenseServer

Add records in the Firestore UI and they should be created in Typesense.

Run Integration Tests

npm run test

Generate README

The Firebase CLI provides the following convenience command to auto-generate a README file containing content pulled from extension.yaml file and PREINSTALL.md file:

firebase ext:info ./ --markdown > README.md

Publish Extension

  • Update version number in extension.yaml
  • firebase ext:dev:publish typesense/firestore-typesense-search
  • Create release in Github

ℹ️ Support

Please open a Github issue or join our Slack community.

firestore-typesense-search's People

Contributors

jasonbosco avatar kylewill avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.