当前位置: 首页>>代码示例>>Python>>正文


Python SearchRequest.toString方法代码示例

本文整理汇总了Python中au.edu.usq.fascinator.api.indexer.SearchRequest.toString方法的典型用法代码示例。如果您正苦于以下问题:Python SearchRequest.toString方法的具体用法?Python SearchRequest.toString怎么用?Python SearchRequest.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在au.edu.usq.fascinator.api.indexer.SearchRequest的用法示例。


在下文中一共展示了SearchRequest.toString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __feed

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import toString [as 别名]
 def __feed(self):
     portal = Services.getPortalManager().get(portalId)
     recordsPerPage = portal.recordsPerPage
     pageNum = sessionState.get("pageNum", 1)
     
     query = "*:*"
     
     req = SearchRequest(query)
     req.setParam("facet", "true")
     req.setParam("rows", str(recordsPerPage))
     req.setParam("facet.field", portal.facetFieldList)
     req.setParam("facet.sort", "true")
     req.setParam("facet.limit", str(portal.facetCount))
     req.setParam("sort", "f_dc_title asc")
     
     portalQuery = portal.query
     if portalQuery:
         req.addParam("fq", portalQuery)
     else:
         fq = sessionState.get("fq")
         req.setParam("fq", fq)
     
     req.setParam("start", str((pageNum - 1) * recordsPerPage))
     
     print " * query: ", query
     print " * portalQuery='%s'" % portalQuery
     print " * feed.py:", req.toString()
     
     out = ByteArrayOutputStream()
     Services.indexer.search(req, out)
     self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
开发者ID:kiranba,项目名称:the-fascinator,代码行数:33,代码来源:atom.py

示例2: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import toString [as 别名]
 def __search(self):
     self.__result = JsonConfigHelper()
     
     portal = Services.getPortalManager().get(portalId)
     recordsPerPage = portal.recordsPerPage
     
     query = formData.get("query")
     if query is None or query == "":
         query = "*:*"
     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
     print " * portalQuery=%s" % portalQuery
     if portalQuery:
         req.addParam("fq", portalQuery)
     
     # TODO resumptionToken
     #req.setParam("start", str((self.__pageNum - 1) * recordsPerPage))
     
     print " * oai.py:", req.toString()
     
     out = ByteArrayOutputStream()
     Services.indexer.search(req, out)
     self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
开发者ID:kiranba,项目名称:the-fascinator,代码行数:31,代码来源:oai.py

示例3: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import toString [as 别名]
    def __search(self):
        self.__result = JsonConfigHelper()

        portal = self.services.getPortalManager().get(self.vc("portalId"))
        recordsPerPage = portal.recordsPerPage

        query = self.vc("formData").get("query")
        if query is None or query == "":
            query = "*:*"
        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
        print " * portalQuery=%s" % portalQuery
        if portalQuery:
            portalQuery += "&item_type:object"
        else:
            portalQuery += "item_type:object"
        req.addParam("fq", portalQuery)
        
        #Check if there's resumption token exist in the formData
        if self.__currentToken:
            start = self.__currentToken.getStart()
            totalFound = self.__currentToken.getTotalFound()
            nextTokenStart = start+recordsPerPage
            if nextTokenStart < totalFound:
                self.__token = ResumptionToken(start=nextTokenStart, metadataPrefix=self.__metadataPrefix, sessionExpiry=self.__sessionExpiry)
        else:
            start = 0
            metadataPrefix = self.vc("formData").get("metadataPrefix")
            self.__token = ResumptionToken(start=recordsPerPage, metadataPrefix=self.__metadataPrefix, sessionExpiry=self.__sessionExpiry)
        
        req.setParam("start", str(start))
        
        print " * oai.py:", req.toString()

        out = ByteArrayOutputStream()
        self.services.indexer.search(req, out)
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        
        totalFound = int(self.__result.get("response/numFound"))
        if totalFound == 0:
            self.__token = None
        elif self.__token:
            if self.__token.getStart() < totalFound:
                self.__token.setTotalFound(totalFound)
            else:
                self.__token = None
        
        #Storing the resumptionToken to session
        if self.__token:
            self.__resumptionTokenList[self.__token.getToken()] = self.__token #(totalFound, self.__token.getConstructedToken())
            #Need to know how long the server need to store this token
            self.sessionState.set("resumptionTokenList", self.__resumptionTokenList)
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:60,代码来源:oai.py

示例4: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import toString [as 别名]
    def __search(self):
        recordsPerPage = self.__portal.recordsPerPage

        query = formData.get("query")
        if query is None or query == "":
            query = "*:*"
        req = SearchRequest(query)
        req.setParam("facet", "true")
        req.setParam("rows", str(recordsPerPage))
        req.setParam("facet.field", self.__portal.facetFieldList)
        req.setParam("facet.sort", "true")
        req.setParam("facet.limit", str(self.__portal.facetCount))
        req.setParam("sort", "f_dc_title asc")
        
        # setup facets
        action = formData.get("action")
        value = formData.get("value")
        fq = sessionState.get("fq")
        if fq is not None:
            self.__pageNum = 1
            req.setParam("fq", fq)
        if action == "add_fq":
            self.__pageNum = 1
            name = formData.get("name")
            print " * add_fq: %s" % value
            req.addParam("fq", URLDecoder.decode(value, "UTF-8"))
        elif action == "remove_fq":
            self.__pageNum = 1
            req.removeParam("fq", URLDecoder.decode(value, "UTF-8"))
        elif action == "clear_fq":
            self.__pageNum = 1
            req.removeParam("fq")
        elif action == "select-page":
            self.__pageNum = int(value)
        req.addParam("fq", 'item_type:"object"')
        
        portalQuery = self.__portal.query
        print " * portalQuery=%s" % portalQuery
        if portalQuery:
            req.addParam("fq", portalQuery)
        
        self.__selected = req.getParams("fq")

        sessionState.set("fq", self.__selected)
        sessionState.set("pageNum", self.__pageNum)

        req.setParam("start", str((self.__pageNum - 1) * recordsPerPage))
        
        print " * search.py:", req.toString(), self.__pageNum

        out = ByteArrayOutputStream()
        Services.indexer.search(req, out)
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        if self.__result is not None:
            self.__paging = Pagination(self.__pageNum,
                                       int(self.__result.get("response/numFound")),
                                       self.__portal.recordsPerPage)
开发者ID:kiranba,项目名称:the-fascinator,代码行数:59,代码来源:search.py

示例5: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import toString [as 别名]
    def __search(self):
        recordsPerPage = self.__portal.recordsPerPage
        
        uri = URLDecoder.decode(request.getAttribute("RequestURI"))
        query = None
        pagePath = portalId + "/" + pageName
        if uri != pagePath:
            query = uri[len(pagePath)+1:]
        if query is None or query == "":
            query = formData.get("query")
        if query is None or query == "":
            query = "*:*"
        
        if query == "*:*":
            self.__query = ""
        else:
            self.__query = query
        sessionState.set("query", self.__query)
        
        # find objects with annotations matching the query
        if query != "*:*":
            anotarQuery = self.__query
            annoReq = SearchRequest(anotarQuery)
            annoReq.setParam("facet", "false")
            annoReq.setParam("rows", str(99999))
            annoReq.setParam("sort", "dateCreated asc")
            annoReq.setParam("start", str(0))        
            anotarOut = ByteArrayOutputStream()
            Services.indexer.annotateSearch(annoReq, anotarOut)
            resultForAnotar = JsonConfigHelper(ByteArrayInputStream(anotarOut.toByteArray()))
            resultForAnotar = resultForAnotar.getJsonList("response/docs")
            ids = HashSet()
            for annoDoc in resultForAnotar:
                annotatesUri = annoDoc.get("annotatesUri")
                ids.add(annotatesUri)
                print "Found annotation for %s" % annotatesUri
            # add annotation ids to query
            query += ' OR id:("' + '" OR "'.join(ids) + '")'

        portalSearchQuery = self.__portal.searchQuery
        if portalSearchQuery == "":
            portalSearchQuery = query
        else:
            if query != "*:*":
                query += " AND " + portalSearchQuery
            else:
                query = portalSearchQuery

        req = SearchRequest(query)
        req.setParam("facet", "true")
        req.setParam("rows", str(recordsPerPage))
        req.setParam("facet.field", self.__portal.facetFieldList)
        req.setParam("facet.sort", "true")
        req.setParam("facet.limit", str(self.__portal.facetCount))
        req.setParam("sort", "f_dc_title asc")
        
        # setup facets
        action = formData.get("verb")
        value = formData.get("value")
        fq = sessionState.get("fq")
        if fq is not None:
            self.__pageNum = 1
            req.setParam("fq", fq)
        if action == "add_fq":
            self.__pageNum = 1
            name = formData.get("name")
            print " * add_fq: %s" % value
            req.addParam("fq", URLDecoder.decode(value, "UTF-8"))
        elif action == "remove_fq":
            self.__pageNum = 1
            req.removeParam("fq", URLDecoder.decode(value, "UTF-8"))
        elif action == "clear_fq":
            self.__pageNum = 1
            req.removeParam("fq")
        elif action == "select-page":
            self.__pageNum = int(value)
        req.addParam("fq", 'item_type:"object"')
        
        portalQuery = self.__portal.query
        print " * portalQuery=%s" % portalQuery
        if portalQuery:
            req.addParam("fq", portalQuery)
        
        self.__selected = list(req.getParams("fq"))

        sessionState.set("fq", self.__selected)
        sessionState.set("searchQuery", portalSearchQuery)
        sessionState.set("pageNum", self.__pageNum)
        
        # Make sure 'fq' has already been set in the session
        if not page.authentication.is_admin():
            security_roles = page.authentication.get_roles_list()
            security_query = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
            current_user = page.authentication.get_username()
            owner_query = 'owner:"' + current_user + '"'
            req.addParam("fq", "(" + security_query + ") OR (" + owner_query + ")")

        req.setParam("start", str((self.__pageNum - 1) * recordsPerPage))
        
        print " * search.py:", req.toString(), self.__pageNum
#.........这里部分代码省略.........
开发者ID:kiranba,项目名称:the-fascinator,代码行数:103,代码来源:search.py

示例6: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import toString [as 别名]
    def __search(self):
        recordsPerPage = self.__portal.recordsPerPage

        query = None
        if query is None or query == "":
            query = formData.get("query")
        if query is None or query == "":
            query = "*:*"

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

        # setup facets
        action = formData.get("verb")
        value = formData.get("value")
        fq = sessionState.get("fq")
        if fq is not None:
            self.__pageNum = 1
            req.setParam("fq", fq)
        if action == "add_fq":
            self.__pageNum = 1
            name = formData.get("name")
            print " * add_fq: %s" % value
            req.addParam("fq", URLDecoder.decode(value, "UTF-8"))
        elif action == "remove_fq":
            self.__pageNum = 1
            req.removeParam("fq", URLDecoder.decode(value, "UTF-8"))
        elif action == "clear_fq":
            self.__pageNum = 1
            req.removeParam("fq")
        elif action == "select-page":
            self.__pageNum = int(value)
        req.addParam("fq", 'item_type:"object"')

        portalQuery = self.__portal.query
        print " * portalQuery=%s" % portalQuery
        if portalQuery:
            req.addParam("fq", portalQuery)

        self.__selected = req.getParams("fq")

        sessionState.set("fq", self.__selected)
        sessionState.set("pageNum", self.__pageNum)

        req.setParam("start", str((self.__pageNum - 1) * recordsPerPage))

        print " * single.py:", req.toString(), self.__pageNum

        out = ByteArrayOutputStream()
        Services.indexer.search(req, out)
        self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        if self.__result is not None:
            self.__paging = Pagination(
                self.__pageNum, int(self.__result.get("response/numFound")), self.__portal.recordsPerPage
            )
            print " * single.py: updating manifest..."
            portal = self.getPortal()
            manifest = portal.getJsonMap("manifest")
            # add new items from search
            for doc in self.__result.getList("response/docs"):
                hashId = md5.new(doc.get("id")).hexdigest()
                node = portal.get("manifest//node-%s" % hashId)
                if node is None:
                    portal.set("manifest/node-%s/title" % hashId, doc.get("dc_title").get(0))
                    portal.set("manifest/node-%s/id" % hashId, doc.get("id"))
            # remove manifest items missing from search result
            # print manifest
            for key in manifest.keySet():
                item = manifest.get(key)
                id = item.get("id")
                doc = self.__result.getList('response/docs[@id="%s"]' % id)
                if len(doc) == 0:
                    portal.removePath("manifest//%s" % key)
            Services.getPortalManager().save(portal)
开发者ID:kiranba,项目名称:the-fascinator,代码行数:81,代码来源:single.py

示例7: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import toString [as 别名]
 def __search(self):
     requireEscape = False
     recordsPerPage = self.__portal.recordsPerPage
     uri = URLDecoder.decode(self.request.getAttribute("RequestURI"))
     query = None
     pagePath = self.__portal.getName() + "/" + self.pageName
     if query is None or query == "":
         query = self.formData.get("query")
         requireEscape = True
     if query is None or query == "":
         query = "*:*"
     
     if query == "*:*":
         self.__query = ""
     else:
         self.__query = query
         if requireEscape:
             query = self.__escapeQuery(query)
         query = "%s:%s" % (self.__searchField, query)
     self.sessionState.set("query", self.__query)
     
     # find objects with annotations matching the query
     if query != "*:*":
         anotarQuery = self.__query
         if requireEscape:
             anotarQuery = self.__escapeQuery(anotarQuery)
         annoReq = SearchRequest(anotarQuery)
         annoReq.setParam("facet", "false")
         annoReq.setParam("rows", str(99999))
         annoReq.setParam("sort", "dateCreated asc")
         annoReq.setParam("start", str(0))
         anotarOut = ByteArrayOutputStream()
         self.services.indexer.annotateSearch(annoReq, anotarOut)
         resultForAnotar = SolrResult(ByteArrayInputStream(anotarOut.toByteArray()))
         resultForAnotar = resultForAnotar.getResults()
         ids = HashSet()
         for annoDoc in resultForAnotar:
             annotatesUri = annoDoc.get("annotatesUri")
             ids.add(annotatesUri)
             print "Found annotation for %s" % annotatesUri
         # add annotation ids to query
         query += ' OR id:("' + '" OR "'.join(ids) + '")'
     
     portalSearchQuery = self.__portal.searchQuery
     if portalSearchQuery == "":
         portalSearchQuery = query
     else:
         if query != "*:*":
             query += " AND " + portalSearchQuery
         else:
             query = portalSearchQuery
     
     req = SearchRequest(query)
     req.setParam("facet", "true")
     req.setParam("rows", str(recordsPerPage))
     req.setParam("facet.field", self.__portal.facetFieldList)
     req.setParam("facet.sort", Boolean.toString(self.__portal.getFacetSort()))
     req.setParam("facet.limit", str(self.__portal.facetCount))
     req.setParam("sort", self.__sortBy)
     
     # setup facets
     if self.__useSessionNavigation:
         action = self.formData.get("verb")
         value = self.formData.get("value")
         fq = self.sessionState.get("fq")
         if fq is not None:
             self.__pageNum = 1
             req.setParam("fq", fq)
         if action == "add_fq":
             self.__pageNum = 1
             req.addParam("fq", URLDecoder.decode(value, "UTF-8"))
         elif action == "remove_fq":
             self.__pageNum = 1
             req.removeParam("fq", URLDecoder.decode(value, "UTF-8"))
         elif action == "clear_fq":
             self.__pageNum = 1
             req.removeParam("fq")
         elif action == "select-page":
             self.__pageNum = int(value)
     else:
         navUri = uri[len(pagePath):]
         self.__pageNum, fq, self.__fqParts = self.__parseUri(navUri)
         savedfq = self.sessionState.get("savedfq")
         limits = []
         if savedfq:
             limits.extend(savedfq)
         if fq:
             limits.extend(fq)
             self.sessionState.set("savedfq", limits)
             for q in fq:
                 req.addParam("fq", URLDecoder.decode(q, "UTF-8"))
     
     portalQuery = self.__portal.query
     if portalQuery:
         req.addParam("fq", portalQuery)
     req.addParam("fq", 'item_type:"object"')
     if req.getParams("fq"):
         self.__selected = ArrayList(req.getParams("fq"))
     
     if self.__useSessionNavigation:
#.........这里部分代码省略.........
开发者ID:the-fascinator-contrib,项目名称:builds-media-repository,代码行数:103,代码来源:search.py

示例8: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import toString [as 别名]
    def __search(self):
        self.log.debug(" === __search()")
        self.__result = SolrResult(None)

        portal = self.services.getPortalManager().get(self.__portalName)
        recordsPerPage = portal.recordsPerPage

        # Resolve our identifier
        id = self.vc("formData").get("identifier")
        self.log.debug(" === ID: '{}'", id)
        query = "*:*"
        if id is not None and id != "":
            # A default TF2 OID
            if id.startswith("oai:fascinator:"):
                query = "id:" + id.replace("oai:fascinator:", "")
            # Or a custom OAI ID
            else:
                query = "oai_identifier:" + id.replace(":", "\\:")

        self.log.debug(" === QUERY: '{}'", query)
        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
        self.log.debug(" * portalQuery={}", portalQuery)
        if portalQuery:
            req.addParam("fq", portalQuery)
        req.addParam("fq", "item_type:object")

        # Check if there's resumption token exist in the formData
        if self.__currentToken:
            start = self.__currentToken.getStart()
            totalFound = self.__currentToken.getTotalFound()
            nextTokenStart = start + recordsPerPage
            if nextTokenStart < totalFound:
                self.__token = ResumptionToken(start = nextTokenStart, \
                    metadataPrefix = self.__metadataPrefix, \
                    sessionExpiry = self.__sessionExpiry)
        else:
            start = 0
            metadataPrefix = self.vc("formData").get("metadataPrefix")
            self.__token = ResumptionToken(start = recordsPerPage, \
                metadataPrefix = self.__metadataPrefix, \
                sessionExpiry = self.__sessionExpiry)

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

        self.log.debug(" * oai.py:", req.toString())

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

        totalFound = self.__result.getNumFound()
        if totalFound == 0:
            self.__token = None
        elif self.__token:
            if self.__token.getStart() < totalFound:
                self.__token.setTotalFound(totalFound)
            else:
                self.__token = None

        #Storing the resumptionToken to session
        if self.__token:
            self.__resumptionTokenList[self.__token.getToken()] = self.__token #(totalFound, self.__token.getConstructedToken())
            #Need to know how long the server need to store this token
            self.sessionState.set("resumptionTokenList", self.__resumptionTokenList)
开发者ID:kiranba,项目名称:the-fascinator,代码行数:73,代码来源:oai.py


注:本文中的au.edu.usq.fascinator.api.indexer.SearchRequest.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。