I have several queries using more than one property in my code. For example, suppose one ndb.Model called user
And some queries:
user.query(user.enabled == Ture, user.name == "demo").order(user.age).fetch(limit=10)
user.query(user.enabled == True, user.domain == "demo.com").fetch(limit=10)
user.query(user.enabled == False, user.phone == 2).fetch(limit=10)
I want to use only one index (containing all fields) in order to reduce a large set. (Google limits to 200)
- kind: user
properties:
- name: enabled
- name: name
- name: age
- name: domain
- name: phone
But is not working.
If it's impossible, is there any way to increase the index limit?
Thx, sorry for my English.
I'm not sure if i understand.
Here are a real sample.
class dbRealEstateImages(ndb.Model):
realestate = ndb.IntegerProperty(required=True)
md5 = ndb.StringProperty()
image_file = ndb.BlobKeyProperty()
image_url = ndb.StringProperty()
position = ndb.IntegerProperty(default=0)
And I want this query:
dbRealEstateImages.query(dbRealEstateImages.realestate == reID).order(dbRealEstateImages.position).fetch(limit=None, projection=[dbRealEstateImages.image_url])
We have 3 properties, one for filter, other for sorting, and another one as a projection.
So we need one index for property and sort order, based on the documentation, could be something like this:
Index(dbRealestateImage, realestate, position)
Index(dbRealestateImage, image_url, position)
But, in ascending order, we don't need to include into the index, so:
Index(dbRealestateImage, realestate)
Index(dbRealestateImage, image_url)
If we have only one property, we don't need to index, so i think, "this query don't need indexes"
But appengine raises
no matching index found.
The suggested index for this query is:
- kind: dbRealEstateImages
properties:
- name: realestate
- name: position
- name: image_url
So, I'm a little bit counfused :(
P.D.: In my quota details, all the index are count, autogenerated, included.