Python 3.9 is now generally available.

google.appengine.datastore.datastore_index.IndexXmlForQuery

Returns the composite index definition XML needed for a query.

Given a query, the arguments for this method can be computed with:

  _, kind, ancestor, props = datastore_index.CompositeIndexForQuery(query)
  props = datastore_index.GetRecommendedIndexProperties(props)

kind The kind or None
ancestor True if this is an ancestor query, False otherwise.
props PropertySpec objects.

A string with the XML for the composite index needed by the query.