當前位置: 首頁>>代碼示例>>Python>>正文


Python SolrResult.toString方法代碼示例

本文整理匯總了Python中com.googlecode.fascinator.common.solr.SolrResult.toString方法的典型用法代碼示例。如果您正苦於以下問題:Python SolrResult.toString方法的具體用法?Python SolrResult.toString怎麽用?Python SolrResult.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.googlecode.fascinator.common.solr.SolrResult的用法示例。


在下文中一共展示了SolrResult.toString方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __buildResumptionTokenSets

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import toString [as 別名]
    def __buildResumptionTokenSets(self):
        self.__result = SolrResult(None)

        portal = self.services.getPortalManager().get(self.__portalName)
        recordsPerPage = portal.recordsPerPage
        # Resolve our identifier
        id = self.vc("formData").get("identifier")
        query = "*:*"
        if id is not None and id != "":
            # A default TF2 OID
            if id.startswith("oai:fascinator.usq.edu.au:"):
                idString = id.replace("oai:fascinator.usq.edu.au:", "")
                idString = self.__escapeQuery(idString)
                query = "id:" + idString
            # Or a custom OAI ID
            else:
                idString = self.__escapeQuery(id)
                query = "oai_identifier:" + idString

        req = SearchRequest(query)
        req.setParam("facet", "true")
        req.setParam("rows", str(recordsPerPage))
        req.setParam("facet.field", portal.facetFieldList)
        req.setParam("facet.limit", str(portal.facetCount))
        req.setParam("sort", "f_dc_title asc")

        portalQuery = portal.query
        if portalQuery:
            req.addParam("fq", portalQuery)
        req.addParam("fq", "item_type:object")

        # Date data... is supplied
        fromDate = self.__request.getFromDate()
        untilDate = self.__request.getUntilDate()
        if fromDate is not None:
            fromStr = fromDate.isoformat() + "Z"
            self.log.debug("From Date: '{}'", fromStr)
            if untilDate is not None:
                untilStr = untilDate.isoformat() + "Z"
                self.log.debug("Until Date: '{}'", untilStr)
                queryStr = "last_modified:[%s TO %s]" % (fromStr, untilStr)
            else:
                queryStr = "last_modified:[%s TO *]" % (fromStr)
            self.log.debug("Date query: '{}'", queryStr)
            req.addParam("fq", queryStr)
        else:
            if untilDate is not None:
                untilStr = untilDate.isoformat() + "Z"
                self.log.debug("Until Date: '{}'", untilDate.isoformat())
                queryStr = "last_modified:[* TO %s]" % (untilStr)
                self.log.debug("Date query: '{}'", queryStr)
                req.addParam("fq", queryStr)

        # Check if there's resumption token exist in the formData
        start = 0
        

        req.setParam("start", str(start))

        out = ByteArrayOutputStream()
        self.services.indexer.search(req, out)
        self.__result = SolrResult(ByteArrayInputStream(out.toByteArray()))

        totalFound = self.__result.getNumFound()
        self.log.debug("Total found:" + str(totalFound))
        if totalFound > recordsPerPage:
            
            startRow = 0
            random.seed()
            resumptionToken = "%016x" % random.getrandbits(128)
            
            nextResumptionToken = resumptionToken
            firstLoop = True
            while True:
                self.log.debug("Current Resumption Token: " + resumptionToken)
                req.setParam("start", str(startRow)) 
                out = ByteArrayOutputStream()
                self.services.indexer.search(req, out)
                result = SolrResult(ByteArrayInputStream(out.toByteArray()))
                
                tokenObject = ResumptionToken(resumptionToken,self.__metadataPrefix,nextResumptionToken,result.toString())
                
                if firstLoop:
                    self.__currentToken = ResumptionToken(None,self.__metadataPrefix,resumptionToken,None)
                    tokenObject = None 
                    firstLoop = False
                
                startRow = startRow + recordsPerPage
                
                if startRow > totalFound:
                    tokenObject = ResumptionToken(resumptionToken,self.__metadataPrefix,"",result.toString())
                    self.tokensDB.storeToken(tokenObject)
                    break;
                if tokenObject is not None:
                    self.tokensDB.storeToken(tokenObject)    
                
                
                
                resumptionToken = nextResumptionToken
                nextResumptionToken = "%016x" % random.getrandbits(128)
#.........這裏部分代碼省略.........
開發者ID:the-fascinator,項目名稱:fascinator-portal,代碼行數:103,代碼來源:oai.py


注:本文中的com.googlecode.fascinator.common.solr.SolrResult.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。