I am trying to have multiple inequality filters on multiple fields in my Firebase Firestore collection to be able to search for certain properties on certain criteria, but Firebase Firestore doesn't allow this for no obvious or acceptable reason. What I want to know is if there is a way to achieve what I am trying to do but with a different methodology.
for example i want to filter my properties based on price and number of bed rooms so i would write something like .where("price",">=",price).where("bedrooms",">="bedrooms)
But of course, Firebase and its unlimited limitations don't allow us to do something as simple as this. So, is there a way I can overcome this?
Here is my code:
const search = () => {
firebase
.firestore()
.collection("Properties")
.where("location", "==", address)
.where("bedrooms", "==", rooms)
.where("category", "==", category)
.where("price", ">=", price)
.where("type","==", type)
.get()
.then((result) => {
if (result.size == 0) {
// Toast.fire({
// icon: "error",
// title: "No properties were found, please modify your search",
// });
} else {
setPropertyCount(result.size);
const properties = result.docs.map((doc) => doc.data());
setSearchData(properties);
}
});
};