ó FRTc@s¬ddlmZddlmZmZmZddlZdZdZdZ dZ de fd „ƒYZ d e fd „ƒYZd e fd „ƒYZde fd„ƒYZdS(iÿÿÿÿ(tceil(tjsontmaptsixNtsimplet structuredtlucenetdismaxtSearchServiceExceptioncBseZRS((t__name__t __module__(((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyR!st SearchResultscBs,eZd„Zd„Zd„Zd„ZRS(cKs |dd|_|dd|_|dd|_|dd|_|dd|_|d|_|d |_i|_d |krìxe|d jƒD]P\}}d |kr•t d „t d „|j d gƒƒDƒƒ|j|3scSs|d|dfS(Ntvaluetcount((tx((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyt3s(R ttime_msRtdocsRRRRtitemstdictRtgetRt real_sizetnum_pages_needed(tselftattrstfacettvalues((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyt__init__&s     ?cCs t|jƒS(N(tlenR(R$((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyt__len__7scCs t|jƒS(N(titerR(R$((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/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.cloudsearch2.search.SearchResults` :return: the following page of search results iN(RtpageR#RR"Rt StopIteration(R$((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyt next_page=s (R R R(R*R,R/(((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyR %s   tQueryc BsMeZdZddddddddddddd„ Zd„Zd„ZRS(iôi ic Cs›||_||_||_|p$i|_|p3g|_|pBg|_||_| pZi|_| pii|_| |_ | |_ d|_ |j |ƒdS(Ni( tqtparsertfqtexprtsortt return_fieldsRR&t highlighttpartialtoptionsR-t update_size( R$R1R2R3R4R6tsizeRR5R&R7R8R9((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyR(Os       cCsC||_|jtjks*|jdkr3tjn|j|_dS(Ni(R;R0tRESULTS_PER_PAGER"(R$tnew_size((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyR:as cCsÀi|jd6|jd6}|jr3|j|d\}}t |tj ƒsît j |ƒ}n||d|',post_tag:''}'}`` :type partial: bool :param partial: Should partial results from a partioned service be returned if one or more index partitions are unreachable. :type options: str :param options: Options for the query parser specified in *parser*. Specified as a string in JSON format. ``{fields: ['title^5', 'description']}`` :rtype: :class:`boto.cloudsearch2.search.SearchResults` :return: Returns the results of this search The following examples all assume we have indexed a set of documents with fields: *author*, *date*, *headline* A simple search will look for documents whose default text search fields will contain the search word exactly: >>> 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(q="'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(q="(and 'Tim' (field author 'John Smith'))", parser='structured') Facets allow you to show classification information about the search results. For example, you can retrieve the authors who have written about Tim with a max of 3 >>> search(q='Tim', facet={'Author': '{sort:"bucket", size:3}'}) R1R2R3RTR6R;RR&R7R5R8R9(RU(R$R1R2R3RTR6R;RR&R7R5R8R9R((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pytsearch©s Z! c CsÅd}|jr!|jjj}nd|j|f}|jƒ}|jj|d|ƒ}|jjdƒ}yt j |ƒ}Wnœt k r|j dkrd}ddl } | jd |ƒ} yd | jƒd jƒ}Wntk rñnXtd |ƒ‚ntd ||ƒ‚nXd|kr|d|kr|xp|dD]6} | ddkr?td|| df|ƒ‚q?q?Wn+d|kr§tdt j|ƒ|ƒ‚n||d<||d

403 Forbidden

([^<]+) %stmessages"Unknown error processing search %sRR(RJROt APIVersionRKRGRNR!tcontenttdecodeRtloadst ValueErrort status_codetreRVtgroupststriptAttributeErrorRRCR ( R$Rt api_versionturlRFtrt_bodytdatatmsgRctgtm((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyt__call__ s>      !   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.cloudsearch2.search.Query` :param query: A group of search criteria :type per_page: int :param per_page: Number of docs in each :class:`boto.cloudsearch2.search.SearchResults` object. :rtype: generator :return: Generator containing :class:`boto.cloudsearch2.search.SearchResults` iiN(R:R#RR"(R$Rtper_pageR-R#tresults((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyt get_all_paged7s   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.cloudsearch2.search.Query` :param query: A group of search criteria :rtype: generator :return: All docs matching query iiN(R#RR"(R$RR-R#Rqtdoc((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyt get_all_hitsMs    cCs|jdƒ||ƒjS(sæReturn the total number of hits for query :type query: :class:`boto.cloudsearch2.search.Query` :param query: a group of search criteria :rtype: int :return: Total number of hits for query i(R:R(R$R((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyt get_num_hitses N( R R RER(RURVRoRrRtRu(((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyRH”s  _ -  (tmathRt boto.compatRRRRLtSIMPLEt STRUCTUREDtLUCENEtDISMAXt ExceptionRtobjectR R0RH(((sE/opt/freeware/lib/python2.7/site-packages/boto/cloudsearch2/search.pyts &I