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


Python indexer.SearchRequest类代码示例

本文整理汇总了Python中com.googlecode.fascinator.api.indexer.SearchRequest的典型用法代码示例。如果您正苦于以下问题:Python SearchRequest类的具体用法?Python SearchRequest怎么用?Python SearchRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: export

 def export(self, exportType):        
     exportQuery = "%s:%s" % (self.facetField, self.facetFieldValue)
     outputType = "text/%s; charset=UTF-8" % type        
     responseHeader = "attachment; filename=%s.%s" % (self.facetFieldValue, exportType) 
     
     try:
         out = ByteArrayOutputStream() 
         recnumreq = SearchRequest(exportQuery)
         recnumreq.setParam("fl","create_timestamp")
         recnumreq.setParam("rows", "0")
         self.indexer.search(recnumreq, out)
         recnumres = SolrResult(ByteArrayInputStream(out.toByteArray()))
         self.__rowsFoundSolr = "%s" % recnumres.getNumFound()
     except:
         self.errorMsg = "Export query failure. The issue has been logged (%s - %s)." % (sys.exc_info()[0], sys.exc_info()[1])
         self.log.error("Export query threw an exception (package type was %s): %s - %s" % (self.facetFieldValue, sys.exc_info()[0], sys.exc_info()[1]))
         return
     
     out = ByteArrayOutputStream()
     req = SearchRequest(exportQuery)
     req.setParam("wt", exportType)        
     req.setParam("rows", self.__rowsFoundSolr)
     self.indexer.search(req, out)
     self.response.setHeader("Content-Disposition", responseHeader)
     writer = self.response.getPrintWriter(outputType)
     writer.println(out.toString("UTF-8"))
     writer.close()
开发者ID:ozej8y,项目名称:redbox,代码行数:27,代码来源:csv.py

示例2: findPackagesToTransition

 def findPackagesToTransition(self, fromWorkflowId, fromWorkflowStage):
     req = SearchRequest("workflow_id:"+fromWorkflowId+" AND _query_:\"workflow_step:"+fromWorkflowStage+"\"")
     req.setParam("fq", "owner:[* TO *]")
     req.setParam("fq", "security_filter:[* TO *]")
     out = ByteArrayOutputStream()
     self.indexer.search(req, out)
     solrResult = SolrResult(ByteArrayInputStream(out.toByteArray()))
     return solrResult.getResults()
开发者ID:jonhurn,项目名称:redbox,代码行数:8,代码来源:transitionWorkflow.py

示例3: getAttachments

    def getAttachments(self):
        attachmentType = "review-attachments"

        req = SearchRequest("attached_to:%s AND attachment_type:%s" % (self.oid, attachmentType))
        req.setParam("rows", "1000")
        out = ByteArrayOutputStream()
        self.Services.indexer.search(req, out)
        response = SolrResult(ByteArrayInputStream(out.toByteArray()))
        return response.getResults()
开发者ID:qcif,项目名称:rdsi-arms,代码行数:9,代码来源:ARMSDetail.py

示例4: search_solr

    def search_solr(self):
        query = "(rootUri:"
        if self.rootUriList:
            query += "(" + " OR ".join(self.rootUriList) + ")"
        else:
            query += '"' + self.rootUri + '"'
        if self.type:
            query += ' AND type:"' + self.type + '"'
        query += ")"
        # print "**********", query

        req = SearchRequest(query)
        req.setParam("facet", "false")
        req.setParam("rows", str(99999))
        req.setParam("sort", "dateCreated asc")
        req.setParam("start", str(0))

        # security_roles = page.authentication.get_roles_list();
        # security_query = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
        # req.addParam("fq", security_query)

        out = ByteArrayOutputStream()
        Services.indexer.annotateSearch(req, out)
        result = SolrResult(ByteArrayInputStream(out.toByteArray())).getResults()

        # Every annotation for this URI
        if self.type == "http://www.purl.org/anotar/ns/type/0.1#Tag":
            return self.process_tags(result)
        else:
            return self.process_response(result)
开发者ID:kiranba,项目名称:the-fascinator,代码行数:30,代码来源:anotar.py

示例5: __loadSolrData

 def __loadSolrData(self, oid):
     portal = self.vc("page").getPortal()
     query = 'id:"%s"' % oid
     if portal.getSearchQuery():
         query += " AND " + portal.getSearchQuery()
     req = SearchRequest(query)
     req.addParam("fq", 'item_type:"object"')
     req.addParam("fq", portal.getQuery())
     out = ByteArrayOutputStream()
     self.vc("Services").getIndexer().search(req, out)
     return SolrResult(ByteArrayInputStream(out.toByteArray()))
开发者ID:the-fascinator,项目名称:fascinator-portal,代码行数:11,代码来源:blog.py

示例6: __search

    def __search(self):
        indexer = self.services.getIndexer()
        
        # Security prep work
        isAdmin = self.vc("page").authentication.is_admin()
        if not isAdmin:
            print "ERROR: User is not an admin '"
            return None

        req = SearchRequest('eventType:harvestStart')
        req.setParam("rows", "100")
        out = ByteArrayOutputStream()
        indexer.searchByIndex(req, out, "eventLog")
        self.__harvestList = SolrResult(ByteArrayInputStream(out.toByteArray()))
开发者ID:the-fascinator,项目名称:fascinator-portal,代码行数:14,代码来源:reports.py

示例7: _searchSets

    def _searchSets(self, indexer, searchType, isAdmin=True, security_query=''):
        req = SearchRequest("packageType:"+searchType)
        req.setParam("fq", 'item_type:"object"')

        req.addParam("fq", "")
        req.setParam("sort", "last_modified desc, f_dc_title asc");
        if not isAdmin:
            req.addParam("fq", security_query)
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        return SolrResult(ByteArrayInputStream(out.toByteArray()))
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:11,代码来源:home.py

示例8: __buildSearch

    def __buildSearch(self, query):
        req = SearchRequest(query)
        req.setParam("rows", str(self.rowsPerQuery))
        req.setParam("fl", "*")
        req.setParam("fq", 'item_type:"object"')
        # The portal filter query
        portal = self.__getPortal()
        if portal.query != "":
            req.setParam("fq", portal.query)

        return req
开发者ID:the-fascinator,项目名称:fascinator-portal,代码行数:11,代码来源:deletebyquery.py

示例9: __getMetadata

 def __getMetadata(self, oid):
     req = SearchRequest('id:%s' % oid)
     req.setParam("fq", 'item_type:"object"')
     
     # Make sure 'fq' has already been set in the session
     ##security_roles = self.authentication.get_roles_list();
     ##security_query = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
     ##req.addParam("fq", security_query)
     
     out = ByteArrayOutputStream()
     indexer = self.services.getIndexer()
     indexer.search(req, out)
     result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     #self.log.info("result={}", result.toString())
     return result.getJsonList("response/docs").get(0)
开发者ID:Paul-Nguyen,项目名称:mint,代码行数:15,代码来源:nameAuthority.py

示例10: handleWorkflowStep

 def handleWorkflowStep(self):
     out = ByteArrayOutputStream()
     req = SearchRequest("workflow_step_label:[* TO *]" )
     req.setParam("fq", 'item_type:"object"')
     req.setParam("fq", 'workflow_id:"dataset"')
     req.setParam("rows", "1000")
     self.indexer.search(req, out)
     res = SolrResult(ByteArrayInputStream(out.toByteArray()))
     hits = HashSet()
     if (res.getNumFound() > 0):
         recordTypeResults = res.getResults()
         for recordTypeResult in recordTypeResults:
             recordTypeList = recordTypeResult.getList("workflow_step_label")
             if (recordTypeList.isEmpty()==False):
                 for hit in recordTypeList:
                     hits.add(hit)
         self.writer.println("[")
         
         hitnum = 0
         for hit in hits:
             if (hitnum > 0):
                 self.writer.println(",{\"value\": \"%s\",\n\"label\": \"%s\"}" % (hit,hit))
             else:    
                 self.writer.println("{\"value\": \"%s\",\n\"label\": \"%s\"}" % (hit,hit))
             hitnum += 1
         self.writer.println("]")
     else:   
          self.writer.println("[\"\"]")
     self.writer.close()
开发者ID:nishen,项目名称:redbox,代码行数:29,代码来源:lookup.py

示例11: handleGrantNumber

 def handleGrantNumber(self):
     out = ByteArrayOutputStream()
     req = SearchRequest("grant_numbers:%s*" % self.term)
     req.setParam("fq", 'item_type:"object"')
     req.setParam("fq", 'workflow_id:"dataset"')
     req.setParam("rows", "1000")
     self.indexer.search(req, out)
     res = SolrResult(ByteArrayInputStream(out.toByteArray()))
     hits = HashSet()
     if (res.getNumFound() > 0):
         creatorResults = res.getResults()
         for creatorRes in creatorResults:
             creatorList = creatorRes.getList("grant_numbers")
             if (creatorList.isEmpty()==False):
                 for hit in creatorList:
                     hits.add(hit)
         self.writer.print("[")
         hitnum = 0
         for hit in hits:
             if (hitnum > 0):
                 self.writer.print(",\"%s\"" % hit)
             else:    
                 self.writer.print("\"%s\"" % hit)
             hitnum += 1
         self.writer.print("]")
     else:   
          self.writer.println("[\"\"]")
     self.writer.close()
开发者ID:nishen,项目名称:redbox,代码行数:28,代码来源:lookup.py

示例12: handleQuery

 def handleQuery(self, query, fieldName, formatStr):
     out = ByteArrayOutputStream()
     req = SearchRequest(query)
     req.setParam("fq", 'item_type:"object"')
     req.setParam("fq", 'workflow_id:"dataset"')
     req.setParam("rows", "1000")
     self.indexer.search(req, out)
     res = SolrResult(ByteArrayInputStream(out.toByteArray()))
     hits = HashSet()
     if (res.getNumFound() > 0):
         results = res.getResults()
         for searchRes in results:
             searchResList = searchRes.getList(fieldName)
             if (searchResList.isEmpty()==False):
                 for hit in searchResList:
                     if self.term is not None:
                         if hit.find(self.term) != -1:
                             hits.add(hit)
                     else:
                         hits.add(hit)
         self.writer.print("[")
         hitnum = 0
         for hit in hits:
             if (hitnum > 0):
                 self.writer.print(","+formatStr % {"hit":hit})
             else:    
                 self.writer.print(formatStr % {"hit":hit})
             hitnum += 1
         self.writer.print("]")
     else:   
          self.writer.println("[\"\"]")
     self.writer.close()
开发者ID:greg-pendlebury,项目名称:redbox,代码行数:32,代码来源:lookup.py

示例13: search_solr

 def search_solr(self):
     # Build our solr query
     readyForNla = "ready_for_nla:ready"
     nlaPidExists = "nlaId:http*"
     query = readyForNla + " AND NOT " + nlaPidExists
     # Prepare the query
     req = SearchRequest(query)
     req.setParam("facet", "false")
     req.setParam("rows", "20")
     # Run the query
     try:
         out = ByteArrayOutputStream()
         self.services.getIndexer().search(req, out)
         return SolrResult(ByteArrayInputStream(out.toByteArray()))
     except Exception, e:
         self.log.error("Error searching solr: ", e)
         self.throw_error("failure searching solr: " + e.getMessage())
         return None
开发者ID:Deakin,项目名称:mint,代码行数:18,代码来源:nla.py

示例14: findPackagesToPurge

 def findPackagesToPurge(self,packageType):
     req = SearchRequest("display_type:"+packageType +" AND date_object_created:[* TO NOW-7DAY]")
     req.setParam("fq", "owner:[* TO *]")
     req.setParam("fq", "security_filter:[* TO *]")
     req.setParam("fl", "storage_id,date_object_created,date_object_modified")
     out = ByteArrayOutputStream()
     self.indexer.search(req, out)
     solrResult = SolrResult(ByteArrayInputStream(out.toByteArray()))
     return solrResult.getResults()
开发者ID:redbox-mint,项目名称:redbox,代码行数:9,代码来源:purgeEmptyRecords.py

示例15: getAttachedFiles

 def getAttachedFiles(self, oid):
     # Build a query
     req = SearchRequest("attached_to:%s" % oid)
     req.setParam("rows", "1000")
     # Run a search
     out = ByteArrayOutputStream()
     self.Services.getIndexer().search(req, out)
     result = SolrResult(ByteArrayInputStream(out.toByteArray()))
     # Process results
     docs = JSONArray()
     for doc in result.getResults():
         attachmentType = self.escapeHtml(WordUtils.capitalizeFully(doc.getFirst("attachment_type").replace("-", " ")))
         accessRights = self.escapeHtml(WordUtils.capitalizeFully(doc.getFirst("access_rights")))
         entry = JsonObject()
         entry.put("filename",        self.escapeHtml(doc.getFirst("filename")))
         entry.put("attachment_type", attachmentType)
         entry.put("access_rights",   accessRights)
         entry.put("id",              self.escapeHtml(doc.getFirst("id")))
         docs.add(entry)
     return docs
开发者ID:ozej8y,项目名称:redbox,代码行数:20,代码来源:detail.py


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