当前位置: 首页>>代码示例>>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;未经允许,请勿转载。