how to do full text search in flutter firebase

Issue

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

Solution

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

Answered By – Augustin R

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published