def es_search_cmd(query, pages=1, log=log):
 from kitsune.sumo.tests import LocalizingClient
 from kitsune.sumo.urlresolvers import reverse
 client = LocalizingClient()
 output = []
 output.append(('Search for: %s' % query))
 output.append('')
 data = {'q': query, 'format': 'json'}
 url = reverse('search')
 for pageno in range(pages):
  pageno = (pageno + 1)
  data['page'] = pageno
  resp = client.get(url, data)
  if (resp.status_code != 200):
   output.append(('ERROR: %s' % resp.content))
   break
  else:
   content = json.loads(resp.content)
   results = content[u'results']
   for mem in results:
    output.append((u'%4d  %5.2f  %-10s  %-20s' % (mem['rank'], mem['score'], mem['type'], mem['title'])))
   output.append('')
 for line in output:
  log.info(line.encode('ascii', 'ignore'))

def es_search_cmd ( query , pages = 1 , log = log ) : from kitsune . sumo . tests import LocalizingClient from kitsune . sumo . urlresolvers import reverse client = LocalizingClient ( ) output = [ ] output . append ( ( 'Search for: %s' % query ) ) output . append ( '' ) data = { 'q' : query , 'format' : 'json' } url = reverse ( 'search' ) for pageno in range ( pages ) : pageno = ( pageno + 1 ) data [ 'page' ] = pageno resp = client . get ( url , data ) if ( resp . status_code != 200 ) : output . append ( ( 'ERROR: %s' % resp . content ) ) break else : content = json . loads ( resp . content ) results = content [ u'results' ] for mem in results : output . append ( ( u'%4d  %5.2f  %-10s  %-20s' % ( mem [ 'rank' ] , mem [ 'score' ] , mem [ 'type' ] , mem [ 'title' ] ) ) ) output . append ( '' ) for line in output : log . info ( line . encode ( 'ascii' , 'ignore' ) )
simulates a front page search .