0

how to apply full text search on flutter firebase without third party app like algolia

 stream: FirebaseFirestore.instance
                .collection('cars')
                .orderBy('time', descending: true)
                .where('name', isEqualTo: test)
                .snapshots(),

this how i'm trying to search but its not working good becoous i need to type the full name for the document i tryed to use algolia but the google function asked to upgrade my plane and its not an option now

  • 1
    you *will* need to use an third-party tool; Firestore has no such tools for scaling and Efficiency reasons. BUT I have been using the Blaze plan for some months, with multiple Cloud Functions, Firebase Storage, Firebase Firestore, etc etc - and so far my largest bill has ben for $0.01 (yes, you read that right). Watch out for runaway and/or infinite loops, don't try to store hundreds of GB, etc, and you'll likely be fine. – LeadDreamer Feb 14 '21 at 20:36
  • what is the best third party tool to use? – Hadi Elhossiny Feb 14 '21 at 21:38
  • 1
    Sorry, but that's an opinion question - it's dependent on *your* needs and *your* data. – LeadDreamer Feb 14 '21 at 23:01

2 Answers2

1

From this answer ( please note that this will not behave as a full-text search, but more as a "starts with" search) :

stream: FirebaseFirestore.instance
    .collection('cars')
    .orderBy('name', descending: true)
    .startAt(test)
    .endAt(test+'\uf8ff')
    .snapshots(),

About '\uf8ff' :

The character \uf8ff used in the query is a very high code point in the Unicode range (it is a Private Usage Area [PUA] code). Because it is after most regular characters in Unicode, the query matches all values that start with searchName

Augustin R
  • 7,089
  • 3
  • 26
  • 54
1

If you decide to go for a local database, you can do full text search with the moor library on top of sqlite, with the fts5 extension enabled: https://moor.simonbinder.eu/docs/using-sql/extensions/#fts5

Pavel M.
  • 374
  • 6
  • 7