firesearch_sdk 0.1.3
firesearch_sdk: ^0.1.3 copied to clipboard

An sdk for Firesearch

Firesearch SDK for Dart #

Unofficial Firesearch SDK for Dart


Firesearch is a solution for full-text search on top of Firestore.

Services #

You use indexes & documents to enable full-text search. An index stores the documents. It can be configured to allow stemming & case-sensitive search.

You will need to instantiate a firesearch client for every one of the services:

var firesearchClient = Client(
    host: "<Your Firesearch Host>",
    apiKey: "<Your API Key>");

Using in Flutter Web or Flutter Mobile #

In a frontend application you will only need to search documents. Indexing and putting documents into Firesearch should only be done by a backend service.

  1. Retrieve an access key from your backend api.
  2. Create a SearchQuery with the retrieved key:
final searchQuery = SearchQuery(
          indexPath: 'path/to/index',
          accessKey: '<accessKey retrieved from a server>',
          limit: 100,
          text: 'search for this');
final request = SearchRequest(query: searchQuery);

var response =;

Access Key Service #

Access Keys allow you to safely search from web & mobile. Without access keys you will have to expose the Firesearch API Key. It is recommended to have a backend endpoint that returns an access key to the mobile or web client, which they can then use for executing search requests against Firesearch.

Create Access Key #

Note This should ideally be done in the backend. In your frontend application, you should be requesting for the access key from the backend.

var request = GenerateKeyRequest(indexPathPrefix: 'path/to/index');
var accessKey = await accessKeyService.generateKey(request);

Index Service #

Create an index service:

var indexService = IndexService(firesearchClient);
  • Create an index:
var index = Index(
    indexPath: 'path/to/index',
    name: 'My Test Index',
    language: 'english');
final request = CreateIndexRequest(index: index);
var indexResponse = await indexService.createIndex(request);
  • Delete an index:
final request = DeleteIndexRequest(
          indexPath: 'path/to/index');
var indexResponse = await indexService.deleteIndex(request);
  • Put a document in the index:
 final request = PutDocRequest(
          indexPath: 'path/to/index',
          doc: Doc(id: 'document-id', fields: [
            Field(key: 'key', value: {'name': 'searchable_field'})
var response = await indexService.putDoc(request);
  • Delete a document from the index:
 final request = DeleteDocRequest(
    indexPath: 'firesearch-tutorial/indexes/index-name',
    id: 'document-id');

var response = await indexService.deleteDoc(request);
  • Get an index:
final request =
      GetIndexRequest(indexPath: 'path/to/index');
var response = await indexService.getIndex(request);
  • Get a list of indexes:
var response = await indexService.getIndexes();
  • Search
final searchQuery = SearchQuery(
          indexPath: 'path/to/index',
          accessKey: 'accessKey',
          limit: 100,
          text: 'search for this');
final request = SearchRequest(query: searchQuery);

var response =;

Development #

Generate types #

The official Firesearch SDK is highly typed. Every output & input to a function has a corresponding type. We try to leverage freezed and json_serializable to generate these types.

pub run build_runner build --delete-conflicting-outputs

Dart Versions #

  • Dart 2: >= 2.12

Maintainers #