I am trying to build a searching function on my app, and the user can search from two different categories: The Title and Author of a book. I am using Firebase Firestore for my app, and I am using Android Studio for my project.
FirebaseFirestore db = FirebaseFirestore.getInstance();
CollectionReference booksRef = db.collection("Books");
booksRef
.whereEqualTo("Title", usersearch)
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
//Success Code
}
} else {
//Failure Code
}
}
});
As you can see, I am only using .whereEqualTo("Title", usersearch)
, but I want it to also test if the usersearch
is equal to any of the Authors in the Database. However, if I put .whereEqualTo("Author", usersearch)
Nothing will be found because there is nothing with the same author and title. I have also tried using ||
but that didn't work either. Thank you in Advance!