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


Python SolrResult.getResults方法代碼示例

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


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

示例1: findPublishedRecords

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
 def findPublishedRecords(self):
     #req = SearchRequest("published:\"true\"")
     req = SearchRequest("storage_id:\"c6a214670dc644e5ebdaede4a2243f67\"")
     out = ByteArrayOutputStream()
     self.indexer.search(req, out)
     solrResult = SolrResult(ByteArrayInputStream(out.toByteArray()))
     return solrResult.getResults()
開發者ID:redbox-mint,項目名稱:redbox,代碼行數:9,代碼來源:updateRelationships.py

示例2: handleWorkflowStep

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
 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,代碼行數:31,代碼來源:lookup.py

示例3: checkAprovedRequests

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
    def checkAprovedRequests(self, provisioned=0, startPage=1):
        """ A customised query for package type of arms at workflow_step of arms-approved
            Get a list of requests filtered by provisioning_checklist
        """
        workflowStep = "arms-approved"
        if self.packageType:
            req = SearchRequest(self.packageType)
        else:
            req = SearchRequest("packageType:arms")
        req.addParam("fq", 'workflow_step:' + workflowStep)
        if provisioned:
            req.addParam("fq", '-provisioning_checklist.4:null')
        else:
            req.addParam("fq", 'provisioning_checklist.4:null')
        req.setParam("sort", "date_object_modified desc, f_dc_title asc")
        req.setParam("fl","id,dc_title,date-provisioned")
        out = ByteArrayOutputStream()
        self.indexer.search(req, out)
        solrResults = SolrResult(ByteArrayInputStream(out.toByteArray()))

        if solrResults:
            results = solrResults.getResults()
            if results:
                results = self.mergeEvents(results, ["arms_draft","arms_redraft","arms_review","arms_approved","arms_rejected"])
            self._setPaging(results.size())
            return results
        else:
            return ArrayList()
開發者ID:qcif,項目名稱:rdsi-arms,代碼行數:30,代碼來源:Dashboard.py

示例4: handleQuery

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
 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,代碼行數:34,代碼來源:lookup.py

示例5: handleGrantNumber

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
 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,代碼行數:30,代碼來源:lookup.py

示例6: findPackagesToTransition

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
 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,代碼行數:10,代碼來源:transitionWorkflow.py

示例7: checkRequests

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
    def checkRequests(self, checklist_filter=['1'], role_filter='reviewer', exclusive=True, startPage=1):
        """ A customised query for arms at arms-review
            Get a list of requests filtered by provisioning_checklist

            For assessor, it is user based and queries against committee-responses.metadata
        """
        workflowStep = "arms-review"
        if self.packageType:
            req = SearchRequest(self.packageType)
        else:
            req = SearchRequest("packageType:arms")
        req.addParam("fq", 'workflow_step:' + workflowStep)
        for item in ['1','2','3','4']:
            if item in checklist_filter:
                req.addParam("fq", '-provisioning_checklist.' + item + ':null' + ' AND provisioning_checklist.' + item + ':[* TO *]')
            else:
                if exclusive:
                    # ensure that brand new submissions (not yet saved by reviewer) are also returned
                    req.addParam("fq", 'provisioning_checklist.' + item + ':null' + ' OR (*:* -provisioning_checklist.' + item + ':[* TO *])')
        req.setParam("sort", "date_object_modified desc, f_dc_title asc")
        req.setParam("fl",self.returnFields)
        out = ByteArrayOutputStream()
        self.indexer.search(req, out)
        solrResults = SolrResult(ByteArrayInputStream(out.toByteArray()))

        if solrResults:
            results = solrResults.getResults()
            if results:
                packageResults = results
                results = self.mergeEvents(packageResults, ["arms_draft","arms_redraft","arms_review","arms_approved","arms_rejected"])
            returnArray = JSONArray()
            if role_filter.startswith('assessor'):
                if role_filter == 'assessor':
                    query_status = ['new', 'draft']
                elif role_filter == 'assessor-assessed':
                    query_status = ['submitted']
                x = Assessment()
                x.activate(self.velocityContext)
                i = 0
                rows = self.recordsPerPage
                start = (startPage - 1) * self.recordsPerPage
                for r in results:
                    status = x.queryStatus(r.get("id"))
                    if status in query_status:
                        if i >= start and i - start < rows:
                            if status == 'submitted':
                                assessment_submitted_date = x.queryMyAttr('date')
                                if assessment_submitted_date:
                                    r.getJsonObject().put('date', assessment_submitted_date)
                            returnArray.add(r)
                        i = i + 1
            else:
                returnArray = results

            self._setPaging(returnArray.size())
            return returnArray
        else:
            return ArrayList()
開發者ID:qcif,項目名稱:rdsi-arms,代碼行數:60,代碼來源:Dashboard.py

示例8: findPackagesToPurge

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
 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,代碼行數:11,代碼來源:purgeEmptyRecords.py

示例9: getAttachments

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
    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,代碼行數:11,代碼來源:ARMSDetail.py

示例10: _packageResults

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
 def _packageResults(self, req, solrLog=None):
     out = ByteArrayOutputStream()
     if solrLog:
         self.indexer.searchByIndex(req, out, solrLog)
     else:
         self.indexer.searchByIndex(req, out)
     solrResults = SolrResult(ByteArrayInputStream(out.toByteArray()))
     if solrResults:
         return solrResults.getResults()
     else:
         return ArrayList()
開發者ID:qcif,項目名稱:rdsi-arms,代碼行數:13,代碼來源:Dashboard.py

示例11: __init__

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
class ReportsData:
    def __init__(self):
        pass

    def __activate__(self, context):
        #import pydevd;pydevd.settrace()
        self.velocityContext = context
        self.vc("sessionState").remove("fq")
        self.services = self.vc("Services")
        self.log = context["log"]
        self.__harvestList = None
        self.__search()

    # Get from velocity context
    def vc(self, index):
        if self.velocityContext[index] is not None:
            return self.velocityContext[index]
        else:
            print "ERROR: Requested context entry '" + index + "' doesn't exist"
            return None

    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()))

    
    def getHarvestlist(self):
        return self.__harvestList.getResults()

    def getItemCount(self):
        return self.__harvestList.getNumFound()
開發者ID:the-fascinator,項目名稱:fascinator-portal,代碼行數:44,代碼來源:reports.py

示例12: getAttachedFiles

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
 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,代碼行數:22,代碼來源:detail.py

示例13: __activate__

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
    def __activate__(self, context):
        formData = context["formData"]
        services = context["Services"]
        response = context["response"]

        # Prepare a query
        q = formData.get("q")
        if q is not None and q != "":
            query = "(item_type:object AND " + self.titleTokens(q.strip()) + ")"
        else:
            query = "item_type:object"
        # Can't link to yourself AND we're not interested in attachments
        oid = formData.get("qs")
        query += " AND -storage_id:\""+oid+"\""
        # And we're not interested in attachments
        query += " AND display_type:\"package-dataset\""
        req = SearchRequest(query)
        req.setParam("fl", "dc_title,storage_id,pidProperty")
        limit = formData.get("limit")
        if limit is None:
            limit = 10
        req.setParam("rows", limit)

        # Search Solr
        indexer = services.getIndexer()
        out = ByteArrayOutputStream()
        indexer.search(req, out)
        result = SolrResult(ByteArrayInputStream(out.toByteArray()))

        # Build a response
        list = []
        for doc in result.getResults():
            title = doc.getFirst("dc_title")
            #oid   = doc.getFirst("storage_id")
            oid = doc.getFirst("pidProperty")
            list.append("%s::%s" % (oid, title))
        result = "\n".join(list)

        writer = response.getPrintWriter("text/plain; charset=UTF-8")
        writer.println(result)
        writer.close()
開發者ID:ozej8y,項目名稱:redbox,代碼行數:43,代碼來源:datasets.py

示例14: __activate__

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
 def __activate__(self, context):
     formData = context["formData"]
     services = context["Services"]
     response = context["response"]
     query = "keywords:[* TO *]"
     q = formData.get("q")
     if q:
         query += " AND keywords:(%(q)s OR %(q)s*)" % { "q": q }
     req = SearchRequest(query)
     req.setParam("fl", "keywords")
     req.setParam("rows", "50")
     keywords = TreeSet()
     indexer = services.getIndexer()
     out = ByteArrayOutputStream()
     indexer.search(req, out)
     result = SolrResult(ByteArrayInputStream(out.toByteArray()))
     for doc in result.getResults():
         for keyword in doc.getList("keywords"):
             if keyword.startswith(q):
                 keywords.add(keyword)
     writer = response.getPrintWriter("text/plain; charset=UTF-8")
     writer.println("\n".join(keywords))
     writer.close()
開發者ID:andrewbrazzatti,項目名稱:redbox-core-dev-build,代碼行數:25,代碼來源:keywords.py

示例15: getFilteredAssessments

# 需要導入模塊: from com.googlecode.fascinator.common.solr import SolrResult [as 別名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getResults [as 別名]
    def getFilteredAssessments(self, packageType, stageName, filterType, startPage=1):
        """ A customised query to use filter to get certain assessment with desired status """
        ## reference /redbox-rdsi-arms/src/main/config/home/lib/jython/util/Assessment.py for methods
        filters = {'assessment-draft': ['new','draft'], 'assessment-submitted':['submitted']}
        statusFilter = filters[filterType]

        req = SearchRequest("packageType:" + packageType)
        req.addParam("fq", 'workflow_step:' + stageName)
        req.setParam("sort", "date_object_modified desc, f_dc_title asc")
        req.setParam("fl",self.returnFields)
        out = ByteArrayOutputStream()
        self.indexer.search(req, out)
        solrResults = SolrResult(ByteArrayInputStream(out.toByteArray()))

        if solrResults:
            results = solrResults.getResults()
            returnArray = JSONArray()
            x = Assessment()
            x.activate(self.velocityContext)
            i = 0
            rows = self.recordsPerPage
            start = (startPage - 1) * self.recordsPerPage
            for r in results:
                status = x.queryStatus(r.get("id"))
                if status in statusFilter:
                    if i >= start and i - start < rows:
                        assessment_submitted_date = x.queryAttr(r.get("id"), 'date')
                        if assessment_submitted_date:
                            r.getJsonObject().put('date', assessment_submitted_date)
                        returnArray.add(r)
                    i = i + 1

            self._setPaging(returnArray.size())
            return returnArray
        else:
            return ArrayList()
開發者ID:qcif,項目名稱:rdsi-arms,代碼行數:38,代碼來源:Dashboard.py


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