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

3
  • 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. Feb 14, 2021 at 20:36
  • what is the best third party tool to use? Feb 14, 2021 at 21:38
  • 1
    Sorry, but that's an opinion question - it's dependent on your needs and your data. Feb 14, 2021 at 23:01

3 Answers 3

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

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

0

If you don't want to use services like algolia and typesense and you don't need any ai prebuilt tools then i have one simple solution using list.

For this solution you have to add all words of your content what you want to search in list by splitting with space and keywords like the,a,is,with,etc unnecessary words and don't pass string in where query use splitted list with spaces and now you have to search from flutter firebase sdk like below 👇 code

_carscollection.where('wordlistfieldname',
arrayContainsAny: carsearchquerylist);

Note: change wordlistfieldname with your array field name in firestore document, and use splitted list of search query string and pass that list in arraycontainsany

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.