Chris Burnham Chris Burnham - 1 year ago 74
Python Question

Managing Autogenerated Indexes

I'm doing an advanced search like the one detailed in

I'm increasing the number of filters from 2 to 4, with 4 sort orders. If I create a perfect index on this search, I'll need 64 indexes in my index.yaml. I followed the advice in the Advanced Search article and created basic indexes for each filter and sort order resulting in 20 indexes. I tested that these indexes satisfy my search by running my development server with --require_indexes

If I go back to my regular development workflow and run just the, accessing my search page creates the perfect indexes. I don't want to give up the ability to generate indexes for other aspects of development by always running with --require_indexes. I also don't want the dev server to create these extra indexes either. Is there a way to have the server only create new indexes if it would otherwise raise a NeedIndexError?

Answer Source

There is currently no way to obtain your (very sensible and useful!) required functionality with the dev appserver.

I believe it would be feasible to add and support a new flag to it, similar to but "softer than" --require_indexes, with exactly the semantics you suggest -- update index.yaml "as needed" but only as a last-ditch fall-back against what would otherwise be a NeedIndexError.

However I would discourage developing this as a fork of the SDK (which would be perfectly legal given its open-source license, but unwise since carrying the patches forward as new SDKs get released would soon become pretty troublesome:-).

Rather I would -- first and foremost -- open a feature request on .

Next, I'd suggest you either (A) save your carefully handcrafted index.yaml and accordingly edit/trim the bloated auto-generated one before deploying, or (B) run with --require_indexes and patiently hand-edit index.yaml as required (whether once a NeedIndexError traceback has told you so, or preventively as you realized you've added some new query.

Yes it's nowhere as fun as editing the SDK to add and support a new flag, but... it will probably serve your app's needs better!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download