How to search for a value in firebase Android

前端 未结 7 1839
孤城傲影
孤城傲影 2020-12-01 05:37

I am saving data as follows in the Firebase:

I want to find all records that have #Yahoo in their title. What will be the exact query for that?

I am

7条回答
  •  猫巷女王i
    2020-12-01 06:32

    Answer : simply do following query :

    databaseReference.orderByChild('_searchLastName')
     .startAt(queryText)
     .endAt(queryText+"\uf8ff");
    

    We can combine startAt and endAt to limit both ends of our query. The following example finds all dinosaurs whose name starts with the letter b:

    curl 'https://dinosaur-facts.firebaseio.com/dinosaurs.json?orderBy="$key"&startAt="b"&endAt="b\uf8ff"&print=pretty'
    

    The \uf8ff character used in the query above is a very high code point in the Unicode range. Because it is after most regular characters in Unicode, the query matches all values that start with a b.

    Here's a related question and the official docs.

提交回复
热议问题