Firebase database, find the existing value

I have a firebase databse of structure as shown below :

[unique key1]

        [key1]
            value1 : abc
            value2 : def

        [key2]
            value1 : xyz
            value2 : pqr

I know the unique key unique key1 and i need to know whether there is any value abc in value1 in this database. I have written the code as shown below, but it always return zero.

 FirebaseDatabase.getInstance().getReference().child(unique key1).orderByChild("value1").equalTo("abc").addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {

            if (dataSnapshot.getChildrenCount() == 0) {
                      Toast.makeText(context, abc, Toast.LENGTH_SHORT).show();
            } else {
               Toast.makeText(context, "Not found", Toast.LENGTH_SHORT).show();
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

Can anyone point out what is wrong with my code. Thanks in advance.


ANSWERS:


You are really close. Instead of orderByChild you need orderByValue in this case, since you're actually looking for the child that has a specific value. So:

FirebaseDatabase.getInstance().getReference()
    .child(unique key1).orderByValue().equalTo("abc")
    .addListenerForSingleValueEvent(new ValueEventListener() {
        public void onDataChange(DataSnapshot snapshot) {
            for (DataSnapshot item: snapshot.getChildren()) {
                System.out.println("Found matching value in "+item.getKey());
            }
        }


 MORE:


 ? Firebase Database run in service
 ? Firebase Database run in service
 ? Firebase Database run in service
 ? Setting custom key when pushing new data to firebase database
 ? Firebase Android method to check existence of user's profile info in Firebase database
 ? Retrive all data from Firebase Database
 ? Are there some service to MOCK Firebase database?
 ? Android Studio firebase database wait for read before adding new values
 ? Determine if any cells in a column range equal to 0, final result is 0, or else is 2
 ? Determine if any cells in a column range equal to 0, final result is 0, or else is 2