Home » Android » how to search at firestore document's field

how to search at firestore document's field

Posted by: admin November 1, 2017 Leave a comment


How to search at firestore documents? if firestore collection contains certain document and if there has a string field at document named ‘title’. How can i search specific title using firebase android api.


It is documented in the Docs here, in the last section of the page, titled Get multiple documents from a collection.

Firestore provides a whereEqualTo function to query your data.

Example code (from Docs):

        .whereEqualTo("capital", true) // <-- This line
        .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
            public void onComplete(@NonNull Task<QuerySnapshot> task) {
                if (task.isSuccessful()) {
                    for (DocumentSnapshot document : task.getResult()) {
                        Log.d(TAG, document.getId() + " => " + document.getData());
                } else {
                    Log.d(TAG, "Error getting documents: ", task.getException());