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


Python SearchRequest.setParam方法代码示例

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


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

示例1: numberOfModifiedRecord

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def numberOfModifiedRecord(self):
     indexer = self.services.getIndexer()
     portalQuery = self.services.getPortalManager().get(self.portal.getName()).getQuery()
     portalSearchQuery = self.services.getPortalManager().get(self.portal.getName()).getSearchQuery()
     
     # Security prep work
     current_user = self.page.authentication.get_username()
     security_roles = self.page.authentication.get_roles_list()
     security_filter = 'security_filter:("' + '" OR "'.join(security_roles) + '")'
     security_exceptions = 'security_exception:"' + current_user + '"'
     owner_query = 'owner:"' + current_user + '"'
     security_query = "(" + security_filter + ") OR (" + security_exceptions + ") OR (" + owner_query + ")"
     
     req = SearchRequest("modified:true")
     req.setParam("fq", 'item_type:"object"')
     if portalQuery:
         req.addParam("fq", portalQuery)
     if portalSearchQuery:
         req.addParam("fq", portalSearchQuery)
     req.addParam("fq", "")
     req.setParam("rows", "0")
     if not self.page.authentication.is_admin():
         req.addParam("fq", security_query)
     out = ByteArrayOutputStream()
     indexer.search(req, out)
     
     self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     return self.__result.get("response/numFound")
开发者ID:kiranba,项目名称:the-fascinator,代码行数:30,代码来源:batchprocess.py

示例2: __isLinked

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def __isLinked(self, ids, map):
     query = 'package_node_id:("' + '" OR "'.join(ids) + '")'
     req = SearchRequest(query)
     req.setParam("fq", 'recordtype:"master"')
     req.addParam("fq", 'item_type:"object"')
     req.setParam("rows", "9999")
     
     out = ByteArrayOutputStream()
     self.__indexer.search(req, out)
     result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     
     currentList = []
     for doc in result.getJsonList("response/docs"):
         currentList.extend(doc.getList("package_node_id"))
     
     if type(map).__name__ == "LinkedHashMap":
         for author in map.keySet():
             authorDocs = map.get(author)
             for doc in authorDocs:
                 if doc.get("id") in currentList:
                     doc.set("linked", "true")
     else:
         for author in map.keys():
             authorList = map[author]
             for count in authorList:
                 doc = authorList[count]
                 if doc.get("id") in currentList:
                     doc.set("linked", "true")
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:30,代码来源:nameAuthority.py

示例3: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [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

示例4: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def __search(self):
     indexer = Services.getIndexer()
     portalQuery = Services.getPortalManager().get(portalId).getQuery()
     
     req = SearchRequest("last_modified:[NOW-1MONTH TO *]")
     req.setParam("fq", 'item_type:"object"')
     if portalQuery:
         req.addParam("fq", portalQuery)
     req.setParam("rows", "10")
     req.setParam("sort", "last_modified desc, f_dc_title asc");
     out = ByteArrayOutputStream()
     indexer.search(req, out)
     self.__latest = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     
     req = SearchRequest("*:*")
     req.setParam("fq", 'item_type:"object"')
     if portalQuery:
         req.addParam("fq", portalQuery)
     req.addParam("fq", "")
     req.setParam("rows", "0")
     out = ByteArrayOutputStream()
     indexer.search(req, out)
     
     sessionState.set("fq", 'item_type:"object"')
     #sessionState.set("query", portalQuery.replace("\"", "'"))
     
     self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
开发者ID:kiranba,项目名称:the-fascinator,代码行数:29,代码来源:home.py

示例5: __getSolrData

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def __getSolrData(self):
     prefix = self.getSearchTerms()
     if prefix != "":
         query = 'dc_title:"%(prefix)s" OR dc_title:"%(prefix)s*"' % { "prefix" : prefix }
     else:
         query = "*:*"
     
     portal = self.services.portalManager.get(self.portalId)
     if portal.searchQuery != "*:*":
         query = query + " AND " + portal.searchQuery
     req = SearchRequest(query)
     req.setParam("fq", 'item_type:"object"')
     if portal.query:
         req.addParam("fq", portal.query)
     req.setParam("fl", "score")
     req.setParam("sort", "score desc, f_dc_title asc")
     req.setParam("start", self.getStartIndex())
     req.setParam("rows", self.getItemsPerPage())
     
     try:
         out = ByteArrayOutputStream()
         indexer = self.services.getIndexer()
         indexer.search(req, out)
         return JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     except Exception, e:
         self.log.error("Failed to lookup '{}': {}", prefix, str(e))
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:28,代码来源:lookup.py

示例6: __activate__

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def __activate__(self, context):
     response = context["response"]
     writer = response.getPrintWriter("text/plain; charset=UTF-8")
     auth = context["page"].authentication
     result = JsonConfigHelper()
     result.set("status", "error")
     result.set("message", "An unknown error has occurred")
     if auth.is_logged_in() and auth.is_admin():
         services = context["Services"]
         formData = context["formData"]
         func = formData.get("func")
         oid = formData.get("oid")
         portalId = formData.get("portalId")
         portalManager = services.portalManager
         if func == "reharvest":
             if oid:
                 print "Reharvesting object '%s'" % oid
                 portalManager.reharvest("oid")
                 result.set("status", "ok")
                 result.set("message", "Object '%s' queued for reharvest")
             elif portalId:
                 print " Reharvesting view '%s'" % portalId
                 # TODO security filter
                 # TODO this should loop through the whole portal,
                 #      not just the first page of results
                 portal = portalManager.get(portalId)
                 req = SearchRequest(portal.query)
                 req.setParam("fq", 'item_type:"object"')
                 out = ByteArrayOutputStream();
                 services.indexer.search(req, out)
                 json = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
                 objectIds = json.getList("response/docs//id")
                 if not objectIds.isEmpty():
                     portalManager.reharvest(objectIds)
                 result.set("status", "ok")
                 result.set("message", "Objects in '%s' queued for reharvest" % portalId)
             else:
                 response.setStatus(500)
                 result.set("message", "No object or view specified for reharvest")
         elif func == "reindex":
             if oid:
                 print "Reindexing object '%s'" % oid
                 services.indexer.index(oid)
                 services.indexer.commit()
                 result.set("status", "ok")
                 result.set("message", "Objects in '%s' queued for reharvest" % portalId)
             else:
                 response.setStatus(500)
                 result.set("message", "No object specified to reindex")
         else:
             response.setStatus(500)
             result.set("message", "Unknown action '%s'" % func)
     else:
         response.setStatus(500)
         result.set("message", "Only administrative users can access this API")
     writer.println(result.toString())
     writer.close()
开发者ID:kiranba,项目名称:the-fascinator,代码行数:59,代码来源:reharvest.py

示例7: __getMetadata

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 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()
     self.__indexer.search(req, out)
     result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     #self.log.info("result={}", result.toString())
     return result.getJsonList("response/docs").get(0)
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:16,代码来源:nameAuthority.py

示例8: search_solr

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
    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 = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
        result = result.getJsonList("response/docs")

        # 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,代码行数:33,代码来源:anotar.py

示例9: __getSolrData

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def __getSolrData(self):
     prefix = self.getSearchTerms()
     if prefix:
         query = '%(prefix)s OR %(prefix)s*' % { "prefix" : prefix }
     else:
         query = "*:*"
     
     level = self.getFormData("level", None)
     if level is not None:
         if level=="top":
             #query += " AND skos_hasTopConcept:http*"
             query += ' AND dc_identifier:"http://purl.org/anzsrc/seo/#division"'
         else:
             query += ' AND skos_broader:"%s"' % level
     
     req = SearchRequest(query)
     req.addParam("fq", 'item_type:"object"')
     req.addParam("fq", 'repository_type:"SEO"')
     req.setParam("fl", "score")
     req.setParam("sort", "score desc")
     req.setParam("start", self.getStartIndex())
     req.setParam("rows", self.getItemsPerPage())
     
     try:
         out = ByteArrayOutputStream()
         indexer = self.services.getIndexer()
         indexer.search(req, out)
         return JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     except Exception, e:
         self.log.error("Failed to lookup '{}': {}", prefix, str(e))
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:32,代码来源:lookup.py

示例10: __search

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def __search(self):
     query = formData.get("query")
     if query is None or query == "":
         query = "*:*"
     req = SearchRequest(query)
     req.setParam("facet", ["true"])
     req.setParam("fl", ["id"])
     req.setParam("fq", ['item_type:"object"'])
     req.setParam("rows", ["100"])
     req.setParam("facet.field", "file_path")
     out = ByteArrayOutputStream()
     indexer = Services.getIndexer()
     indexer.search(req, out)
     self.__result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     self.__facetList = FacetList("file_path", self.__result)
开发者ID:kiranba,项目名称:the-fascinator,代码行数:17,代码来源:search-tree.py

示例11: getSuggestedNames

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
    def getSuggestedNames(self):
        # search common forms
        lookupNames = []
        surname = self.__metadata.getList("surname").get(0)
        firstName = self.__metadata.getList("firstName").get(0)
        firstInitial = firstName[0].upper()
        secondName = self.__metadata.getList("secondName")
        if not secondName.isEmpty():
            secondName = secondName.get(0)
        if secondName and secondName != "":
            secondInitial = secondName[0].upper()
            lookupNames.append("%s, %s. %s." % (surname, firstInitial, secondInitial))
            lookupNames.append("%s, %s %s." % (surname, firstName, secondInitial))
            lookupNames.append("%s, %s %s" % (surname, firstName, secondName))
            lookupNames.append("%s %s %s" % (firstName, secondName, surname))
        lookupNames.append("%s, %s." % (surname, firstInitial))
        lookupNames.append("%s, %s" % (surname, firstName))
        lookupNames.append("%s %s" % (firstName, surname))
        query = '" OR dc_title:"'.join(lookupNames)

        # general word search from each part of the name
        parts = [p for p in self.getPackageTitle().split(" ") if len(p) > 0]
        query2 = " OR dc_title:".join(parts)

        req = SearchRequest('(dc_title:"%s")^2.5 OR (dc_title:%s)^0.5' % (query, query2))
        self.log.info("suggestedNames query={}", req.query)
        req.setParam("fq", 'recordtype:"author"')
        req.addParam("fq", 'item_type:"object"')
        req.setParam("rows", "9999")
        req.setParam("fl", "score")
        req.setParam("sort", "score desc")

        # 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())
        docs = result.getJsonList("response/docs")

        map = LinkedHashMap()
        for doc in docs:
            authorName = doc.getList("dc_title").get(0)
            if map.containsKey(authorName):
                authorDocs = map.get(authorName)
            else:
                authorDocs = ArrayList()
                map.put(authorName, authorDocs)
            authorDocs.add(doc)

        self.__maxScore = max(1.0, float(result.get("response/maxScore")))

        return map
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:60,代码来源:nameAuthority.py

示例12: __getAuthorDetails

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def __getAuthorDetails(self, citationIds):
     query = " OR id:".join(citationIds)
     req = SearchRequest('id:%s' % query)
     req.setParam("fq", 'recordtype:"author"')
     req.addParam("fq", 'item_type:"object"')
     req.setParam("rows", "9999")
     
     # 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()
     self.__indexer.search(req, out)
     result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     return result.getJsonList("response/docs")
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:18,代码来源:nameAuthority.py

示例13: getAuthorities

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def getAuthorities(self):
     req = SearchRequest('package_node_id:%s' % self.metadata.get("id"))
     req.setParam("fq", 'recordtype:"master"')
     req.addParam("fq", 'item_type:"object"')
     req.setParam("rows", "9999")
     
     # 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()))
     
     docs = result.getJsonList("response/docs")
     
     return docs
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:21,代码来源:detail.py

示例14: __getNavData

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def __getNavData(self):
     query = self.sessionState.get("query")
     if query == "":
         query = "*:*"
     req = SearchRequest(query)
     req.setParam("fl", "id dc_title")
     req.setParam("sort", "f_dc_title asc")
     req.setParam("rows", "10000")   ## TODO there could be more than this
     req.setParam("facet", "true")
     req.addParam("facet.field", "workflow_step")
     req.setParam("facet.sort", "false")
     
     pq = self.services.portalManager.get(self.portalId).query
     req.setParam("fq", pq)
     req.addParam("fq", 'item_type:"object"')
     fq = self.sessionState.get("fq")
     if fq:
         for q in fq:
             req.addParam("fq", q)
     
     out = ByteArrayOutputStream()
     self.__indexer.search(req, out)
     result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     oidList = result.getList("response/docs/id")
     nameList = result.getList("response/docs/dc_title")
     
     wfStep = result.getList("facet_counts/facet_fields/workflow_step")
     self.pending = 0
     self.confirmed = 0
     for i in range(len(wfStep)):
         if wfStep[i] == "pending":
             self.pending = wfStep[i+1]
         if wfStep[i] == "live":
             self.confirmed = wfStep[i+1]
     
     self.total = self.pending + self.confirmed
     return oidList, nameList
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:39,代码来源:nameAuthority.py

示例15: __searchNames

# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import setParam [as 别名]
 def __searchNames(self, searchText):
     # search common forms
     lookupNames = []
     
     req = SearchRequest('(dc_title:"%s")^2.5' % searchText)
     self.log.info("searchNames query={}", req.query)
     req.setParam("fq", 'recordtype:"author"')
     req.addParam("fq", 'item_type:"object"')
     req.setParam("rows", "9999")
     req.setParam("fl", "score")
     req.setParam("sort", "score desc")
     
     out = ByteArrayOutputStream()
     self.__indexer.search(req, out)
     result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
     
     docs = result.getJsonList("response/docs")
     
     #Using this map because velocity gave error if LinkHashedMap is used
     map={}
     idList = []
     count = 0
     for doc in docs:
         authorName = str(doc.getList("dc_title").get(0))
         idList.append(doc.get("id"))
         if map.has_key(authorName):
             docsDic = map.get(authorName)
         else:
             docsDic = {}
             map[authorName] = docsDic
         #hash storageId and authorName
         doc.set("authorHash", self.getHash(authorName))
         doc.set("storageHash", self.getHash(doc.get("storage_id")))
         doc.set("affiliation", self.getCitationAffiliation(doc))
         ##doc.set("linked", Boolean.toString(linked))
         docsDic["%s" % count] = doc
         count +=1
     
     if idList:
         self.__isLinked(idList, map)
     return map
开发者ID:redbox-mint-contrib,项目名称:z-defunct-lacs,代码行数:43,代码来源:nameAuthority.py


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