1
votes

I'm executing this query on firebase firestore using python:

groups = ['AG', 'PA']

docs = db.collection(u'companies').document(company).collection('counts').\
document(count_name).collection('preprocess').\
where('status', '==', 'done').where('statuslayers', '==', 'done').\
where('statuslive', '==', 'created').\
where('load', '==', False).where('group', 'in', groups).\
order_by(u'area').stream()

for doc in docs:
    print(u'{} => {}'.format(doc.id, doc.to_dict()))

This error is triggered:

Operator string 'in' is invalid. Valid choices are: <, <=, ==, >, >=, array_contains.

The sample on firebase documentation page is very near:

cities_ref = db.collection(u'cities')

query = cities_ref.where(u'country', u'in', [u'USA', u'Japan'])
return query

I couldn't find any reason to this error, if I remove the where('group', 'in', groups) clause everything works fine.

My google related packages:

  • google-api-core 1.15.0
  • google-api-python-client 1.7.11
  • google-auth 1.10.0
  • google-auth-httplib2 0.0.3
  • google-cloud 0.34.0
  • google-cloud-core 1.1.0
  • google-cloud-firestore 1.6.1
  • google-cloud-storage 1.24.1
  • google-resumable-media 0.5.0
  • googleapis-common-protos 1.6.0
1
It appears support for this was added fairly recently, but if you for sure have google-cloud-firestore==1.6.1 ISTM it should have that update, but you might want to double-check that it's actually there and that you're using the version of the package you think you're using. - Iguananaut
@Iguananaut I quickly looked at the changelog, and it seems IN was added in 1.6.0. I'm not sure why it's not working for Randolfo. - Frank van Puffelen

1 Answers

0
votes

I've made a new virtual environment with the same packages and problem solved, before this I tried update an existing virtual environment without success.

Packages in the new virtual environment:

  • google-api-core 1.15.0

  • google-api-python-client 1.7.11

  • google-auth 1.10.0

  • google-auth-httplib2 0.0.3

  • google-cloud-core 1.1.0

  • google-cloud-firestore 1.6.1

  • google-cloud-pubsub 1.1.0 google-cloud-storage 1.24.1

  • google-cloud-tasks 1.3.0

  • google-resumable-media 0.5.0

  • googleapis-common-protos 1.6.0

Notice that they are the same before. Nevertheless it worked.

Thanks for the comments.