def get_collection_ids_matching_query(query_string, cursor=None):
 returned_collection_ids = []
 search_cursor = cursor
 for _ in range(MAX_ITERATIONS):
  remaining_to_fetch = (feconf.SEARCH_RESULTS_PAGE_SIZE - len(returned_collection_ids))
  (collection_ids, search_cursor) = search_collections(query_string, remaining_to_fetch, cursor=search_cursor)
  invalid_collection_ids = []
  for (ind, model) in enumerate(collection_models.CollectionSummaryModel.get_multi(collection_ids)):
   if (model is not None):
    returned_collection_ids.append(collection_ids[ind])
   else:
    invalid_collection_ids.append(collection_ids[ind])
  if ((len(returned_collection_ids) == feconf.SEARCH_RESULTS_PAGE_SIZE) or (search_cursor is None)):
   break
  else:
   logging.error(('Search index contains stale collection ids: %s' % ', '.join(invalid_collection_ids)))
 if ((len(returned_collection_ids) < feconf.SEARCH_RESULTS_PAGE_SIZE) and (search_cursor is not None)):
  logging.error(('Could not fulfill search request for query string %s; at least %s retries were needed.' % (query_string, MAX_ITERATIONS)))
 return (returned_collection_ids, search_cursor)

def get_collection_ids_matching_query ( query_string , cursor = None ) : returned_collection_ids = [ ] search_cursor = cursor for _ in range ( MAX_ITERATIONS ) : remaining_to_fetch = ( feconf . SEARCH_RESULTS_PAGE_SIZE - len ( returned_collection_ids ) ) ( collection_ids , search_cursor ) = search_collections ( query_string , remaining_to_fetch , cursor = search_cursor ) invalid_collection_ids = [ ] for ( ind , model ) in enumerate ( collection_models . CollectionSummaryModel . get_multi ( collection_ids ) ) : if ( model is not None ) : returned_collection_ids . append ( collection_ids [ ind ] ) else : invalid_collection_ids . append ( collection_ids [ ind ] ) if ( ( len ( returned_collection_ids ) == feconf . SEARCH_RESULTS_PAGE_SIZE ) or ( search_cursor is None ) ) : break else : logging . error ( ( 'Search index contains stale collection ids: %s' % ', ' . join ( invalid_collection_ids ) ) ) if ( ( len ( returned_collection_ids ) < feconf . SEARCH_RESULTS_PAGE_SIZE ) and ( search_cursor is not None ) ) : logging . error ( ( 'Could not fulfill search request for query string %s; at least %s retries were needed.' % ( query_string , MAX_ITERATIONS ) ) ) return ( returned_collection_ids , search_cursor )
returns a list with all collection ids matching the given search query string .