ó FRTc@sªddlmZddlmZmZmZddlZdefd„ƒYZdefd„ƒYZ de fd „ƒYZ d e fd „ƒYZ d e fd „ƒYZ dS(iÿÿÿÿ(tceil(tjsontmaptsixNtSearchServiceExceptioncBseZRS((t__name__t __module__(((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyRstCommitMismatchErrorcBseZRS((RR(((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyR!st SearchResultscBs,eZd„Zd„Zd„Zd„ZRS(cKs/|dd|_|dd|_|dd|_|dd|_|dd|_|dd|_|d |_|d |_|d |_|d |_ i|_ d |krx]|d j ƒD]H\}}d|krÀt d„t d„|dƒDƒƒ|j |7scSs|d|dfS(Ntvaluetcount((tx((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyt7s(R t cpu_time_msttime_msR tdocsRRtmatch_expressionRRRtitemstdictRRt real_sizetnum_pages_needed(tselftattrstfacettvalues((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyt__init__&s        7cCs t|jƒS(N(tlenR(R#((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyt__len__;scCs t|jƒS(N(titerR(R#((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyt__iter__>scCsY|jj|jkrO|jj|jj7_|jjd7_|j|jƒSt‚dS(s¶Call Cloudsearch to get the next page of search results :rtype: :class:`boto.cloudsearch.search.SearchResults` :return: the following page of search results iN(RtpageR"RR!Rt StopIteration(R#((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyt next_pageAs (RRR'R)R+R.(((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyR%s   tQueryc BsJeZdZdddddddddddd„ Zd„Zd„ZRS(iôi ic Csž||_||_|pg|_|p*g|_||_|pBg|_|pQi|_| p`i|_| poi|_| p~i|_ d|_ |j |ƒdS(Ni( tqtbqRt return_fieldsRR%tfacet_constraintst facet_sortt facet_top_nttR,t update_size( R#R0R1RR2tsizeRR%R3R4R5R6((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyR'Ss    cCsC||_|jtjks*|jdkr3tjn|j|_dS(Ni(R8R/tRESULTS_PER_PAGER!(R#tnew_size((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyR7es cCsªi|jd6|jd6}|jr3|j|d>> search(q='Tim') # Return documents with the word Tim in them (but not Timothy) A simple search with more keywords will return documents whose default text search fields contain the search strings together or separately. >>> search(q='Tim apple') # Will match "tim" and "apple" More complex searches require the boolean search operator. Wildcard searches can be used to search for any words that start with the search string. >>> search(bq="'Tim*'") # Return documents with words like Tim or Timothy) Search terms can also be combined. Allowed operators are "and", "or", "not", "field", "optional", "token", "phrase", or "filter" >>> search(bq="(and 'Tim' (field author 'John Smith'))") Facets allow you to show classification information about the search results. For example, you can retrieve the authors who have written about Tim: >>> search(q='Tim', facet=['Author']) With facet_constraints, facet_top_n and facet_sort more complicated constraints can be specified such as returning the top author out of John Smith and Mark Smith who have a document with the word Tim in it. >>> search(q='Tim', ... facet=['Author'], ... facet_constraints={'author': "'John Smith','Mark Smith'"}, ... facet=['author'], ... facet_top_n={'author': 1}, ... facet_sort={'author': 'count'}) R0R1RR2R8RR%R3R4R5R6(RE( R#R0R1RR2R8RR%R3R4R5R6R((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pytsearch£sic Csd|j}|jƒ}tj|d|ƒ}|jjdƒ}ytj|ƒ}Wnžtk ró}|j dkrÝd}ddl } | j d|ƒ} yd | j ƒd j ƒ}Wntk rÉnXtd |ƒ‚ntd ||ƒ‚nXd |krTd|krTxp|d D]6} | ddkrtd|| df|ƒ‚qqWn+d|krtdtj|ƒ|ƒ‚n||d<||dsutf-8i“tiÿÿÿÿNs*

403 Forbidden

([^<]+) %stmessages"Unknown error processing search %sRR(RCR?trequeststgettcontenttdecodeRtloadst ValueErrort status_codetreRFtgroupststriptAttributeErrorRtdumpsR( R#RturlR>trtbodytdatatetmsgRTtgtm((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyt__call__s8    !   ccsf|j|ƒd}d}xF||kra||ƒ}|j}|V|j|j7_|d7}qWdS(s¦Get a generator to iterate over all pages of search results :type query: :class:`boto.cloudsearch.search.Query` :param query: A group of search criteria :type per_page: int :param per_page: Number of docs in each :class:`boto.cloudsearch.search.SearchResults` object. :rtype: generator :return: Generator containing :class:`boto.cloudsearch.search.SearchResults` iiN(R7R"RR!(R#Rtper_pageR,R"tresults((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyt get_all_paged>s   ccsjd}d}xW||kre||ƒ}|j}x|D] }|Vq7W|j|j7_|d7}qWdS(sÈGet a generator to iterate over all search results Transparently handles the results paging from Cloudsearch search results so even if you have many thousands of results you can iterate over all results in a reasonably efficient manner. :type query: :class:`boto.cloudsearch.search.Query` :param query: A group of search criteria :rtype: generator :return: All docs matching query iiN(R"RR!(R#RR,R"Rctdoc((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyt get_all_hitsTs    cCs|jdƒ||ƒjS(såReturn the total number of hits for query :type query: :class:`boto.cloudsearch.search.Query` :param query: a group of search criteria :rtype: int :return: Total number of hits for query i(R7R (R#R((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyt get_num_hitsls N( RRR@R'RERFRaRdRfRg(((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyRA“s    o *  (tmathRt boto.compatRRRRMt ExceptionRRtobjectRR/RA(((sD/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch/search.pyts *D