1

I have a database on Firebase Cloud Firestore. I'm trying to query the database by 2 separate fields using range comparisons. In Firebase I created an Index for it. But for some reason, I'm getting this error...

Error: Invalid query. All where filters with an inequality (<, <=, >, or >=) must be on the same field. But you have inequality filters on 'Lat' and 'Lng'

Why can't I use range comparisons it on 2 fields? Is there any way around this?

Here is my js query code...

db.collection("MyCollection")
.where("Lat", ">", 30)
.where("Lat", "<", 40)
.where("Lng", ">", 70)
.where("Lng", "<", 80)
.get()...

Any ideas?

3
  • 1
    The constraints imposed by Firestore are almost certainly related to performance issues on the backend. Remember that Firestore is a NoSQL database that's optimized for id lookups, so you don't have all the flexibility of full SQL queries. Commented Nov 30, 2017 at 20:27
  • 1
    You may find a solution that uses geohashing. Look at the linked info and also search for "geohash bounding box". Commented Nov 30, 2017 at 21:01
  • Bob Snyder - Geohashing seems promising. Could you maybe elaborate a little more? What did you have in mind exactly? Commented Dec 2, 2017 at 23:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.