4

i am using python with firebase SDK, and have a table named jobs, each record, has a field named client, that is a map, each client has an id field. I would like to query the table for all the jobs that have the client with a certain id value, I found this explaining for how to query by array members but can't find anything about query by values of map fields.

will something like .where("client.id", "==", id) work and be effective? how can I do this query in an effective way? create index maybe?

enter code here
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
thebeancounter
  • 4,261
  • 8
  • 61
  • 109

1 Answers1

4

It should work without creating an index. What you wrote should filter on the id property of the client field object for all documents of a collection.

See also:

Cecilia
  • 4,512
  • 3
  • 32
  • 75
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • I need it to be an effective query, Does firebase create an automatic index for internal map attributes? – thebeancounter Feb 28 '19 at 15:49
  • Did you try it? If it works, that means and index was used. Firestore won't let you query if there is not index used. Firestore will automatically index single fields and properties. – Doug Stevenson Feb 28 '19 at 17:30
  • I was trying to query an object within an array, this confirmed my suspicions about it: https://stackoverflow.com/questions/54600915/firestore-how-to-query-data-from-a-map-of-an-array – Scott Fister May 10 '20 at 15:16