Last updated:
0 purchases
firesearch sdk
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>");
copied to clipboard
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.
Retrieve an access key from your backend api.
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 = indexService.search(request);
copied to clipboard
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);
copied to clipboard
Index Service #
Create an index service:
var indexService = IndexService(firesearchClient);
copied to clipboard
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);
copied to clipboard
Delete an index:
final request = DeleteIndexRequest(
indexPath: 'path/to/index');
var indexResponse = await indexService.deleteIndex(request);
copied to clipboard
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);
copied to clipboard
Delete a document from the index:
final request = DeleteDocRequest(
indexPath: 'firesearch-tutorial/indexes/index-name',
id: 'document-id');
var response = await indexService.deleteDoc(request);
copied to clipboard
Get an index:
final request =
GetIndexRequest(indexPath: 'path/to/index');
var response = await indexService.getIndex(request);
copied to clipboard
Get a list of indexes:
var response = await indexService.getIndexes();
copied to clipboard
Search
final searchQuery = SearchQuery(
indexPath: 'path/to/index',
accessKey: 'accessKey',
limit: 100,
text: 'search for this');
final request = SearchRequest(query: searchQuery);
var response = indexService.search(request);
copied to clipboard
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
copied to clipboard
Dart Versions #
Dart 3: >= 3.4.0
Maintainers #
Roberto Guerra
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.