本文整理汇总了Python中au.edu.usq.fascinator.api.indexer.SearchRequest.addParam方法的典型用法代码示例。如果您正苦于以下问题:Python SearchRequest.addParam方法的具体用法?Python SearchRequest.addParam怎么用?Python SearchRequest.addParam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类au.edu.usq.fascinator.api.indexer.SearchRequest
的用法示例。
在下文中一共展示了SearchRequest.addParam方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __search
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [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()))
示例2: __getSolrData
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [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))
示例3: __search
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [as 别名]
def __search(self):
query = formData.get("query")
searchQuery = sessionState.get("searchQuery")
if query is None or query == "":
query = "*:*"
if searchQuery and query == "*:*":
query = searchQuery
elif searchQuery:
query += " AND " + searchQuery
facetField = formData.get("facet.field")
req = SearchRequest(query)
req.setParam("facet", "true")
req.setParam("fl", "id")
req.setParam("rows", "0")
req.setParam("facet.limit", "-1")
req.setParam("facet.field", facetField)
fq = sessionState.get("fq")
if fq is not None:
req.setParam("fq", fq)
req.addParam("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 = Services.getIndexer()
indexer.search(req, out)
result = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
self.__facetList = FacetList(facetField, result)
示例4: __getStorageId
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [as 别名]
def __getStorageId(self, oid):
req = SearchRequest('id:"%s"' % oid)
req.addParam("fl", "storage_id")
out = ByteArrayOutputStream()
Services.indexer.search(req, out)
json = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
return json.getList("response/docs").get(0).get("storage_id")
示例5: __feed
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [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()))
示例6: __isLinked
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [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")
示例7: __getSolrData
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [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))
示例8: __isIndexed
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [as 别名]
def __isIndexed(self, oid):
query = 'id:"%s"' % oid
req = SearchRequest(query)
req.addParam("fq", 'item_type:"object"')
out = ByteArrayOutputStream()
self.Services.indexer.search(req, out)
solrData = SolrResult(ByteArrayInputStream(out.toByteArray()))
return solrData.getNumFound()!=0
示例9: getSuggestedNames
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [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
示例10: __search
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [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)
示例11: __loadSolrData
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [as 别名]
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()))
示例12: __loadSolrData
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [as 别名]
def __loadSolrData(self, oid):
portal = self.page.getPortal()
query = 'id:"%s"' % oid
if self.isDetail() and portal.getSearchQuery():
query += " AND " + portal.getSearchQuery()
req = SearchRequest(query)
req.addParam("fq", 'item_type:"object"')
if self.isDetail():
req.addParam("fq", portal.getQuery())
out = ByteArrayOutputStream()
self.services.getIndexer().search(req, out)
self.__solrData = JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))
示例13: numberOfModifiedRecord
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [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")
示例14: __getAuthorDetails
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [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")
示例15: __getFeed
# 需要导入模块: from au.edu.usq.fascinator.api.indexer import SearchRequest [as 别名]
# 或者: from au.edu.usq.fascinator.api.indexer.SearchRequest import addParam [as 别名]
def __getFeed(self):
portal = self.services.getPortalManager().get(self.portalId)
req = SearchRequest("*:*")
req.setParam("facet", "true")
req.setParam("rows", "1000")
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")
req.setParam("fq", 'item_type:"object"')
portalQuery = portal.getQuery()
if portalQuery:
req.addParam("fq", portalQuery)
out = ByteArrayOutputStream()
self.services.getIndexer().search(req, out)
return JsonConfigHelper(ByteArrayInputStream(out.toByteArray()))