'How to use email as a ID of your firebase data and retrieve data according to it

I am trying to make a app where user can login with email and password. But i have saved its credentials with the ID (user ID) how can I retrieve data according to my email not my user ID.

Firebase database

When I try to retrieve data with the "email" in my query it is showing the error

Query check=db_refer.orderByChild("email").equalTo(emails);
        check.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot snapshot) {
                if(snapshot.exists()){
                    String db_pass=snapshot.child(emails).child("pass").getValue(String.class);
                    if(db_pass.equals(passs)){
                        Toast.makeText(SignIn.this, "SIGNED IN", Toast.LENGTH_SHORT).show();
                    }
                    else{                                  Toast.makeText(SignIn.this, db_pass+" and "+passs, Toast.LENGTH_SHORT).show();
                        Toast.makeText(SignIn.this, "NOT SIGNED IN", Toast.LENGTH_SHORT).show();

                    }
                }
            }

            @Override
            public void onCancelled(@NonNull DatabaseError error) {
            }
        });
    }
});

This is the error message which my compiler is showing:

W/PersistentConnection: pc_0 - Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '".indexOn": "email"' at Workers to your security and Firebase Database rules for better performance



Solution 1:[1]

The error message says that the filtering of the data is currently being done inside the Android application, instead of on the server. This is highly unscalable, so you'll want to fix that by adding an index in your database rules:

{
  "rules": {
    ...
    "Workers": {
      ".indexOn": "email"
    }
  }
}

I recommend searching for any error messages that you get going forward, as this error came up before.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Frank van Puffelen