本文整理汇总了Python中com.googlecode.fascinator.common.solr.SolrResult.getFacets方法的典型用法代码示例。如果您正苦于以下问题:Python SolrResult.getFacets方法的具体用法?Python SolrResult.getFacets怎么用?Python SolrResult.getFacets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.fascinator.common.solr.SolrResult
的用法示例。
在下文中一共展示了SolrResult.getFacets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getFacetFields
# 需要导入模块: from com.googlecode.fascinator.common.solr import SolrResult [as 别名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getFacets [as 别名]
def getFacetFields(self):
try:
out = ByteArrayOutputStream()
req = SearchRequest("*:*")
req.setParam("fl","facet_counts")
req.setParam("facet", "on")
req.setParam("facet.field", self.facetField)
req.setParam("wt", "json")
self.indexer.search(req, out)
res = SolrResult(ByteArrayInputStream(out.toByteArray()))
facets = res.getFacets()
facet = facets.get(self.facetField)
if facet is not None and facet.values().size() > 0:
self.facetFields = facet.values()
else:
self.errorMsg = "No facet field values to export. Please enter/harvest some data first."
except:
self.errorMsg = "Get facet field query failure. The issue has been logged (%s - %s)." % (sys.exc_info()[0], sys.exc_info()[1])
self.log.error("Get facet field threw an exception : %s - %s" % (sys.exc_info()[0], sys.exc_info()[1]))
return
示例2: __activate__
# 需要导入模块: from com.googlecode.fascinator.common.solr import SolrResult [as 别名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getFacets [as 别名]
#.........这里部分代码省略.........
temp += c
return temp
# eq = q
# # escape all solr/lucene special chars
# # from http://lucene.apache.org/java/2_4_0/queryparsersyntax.html#Escaping%20Special%20Characters
# for c in "+-&|!(){}[]^\"~*?:\\":
# eq = eq.replace(c, "\\%s" % c)
# ## Escape UTF8
# try:
# return URLEncoder.encode(eq, "UTF-8")
# except UnsupportedEncodingException, e:
# print "Error during UTF8 escape! ", repr(eq)
# return eq
def getQueryTime(self):
return int(self.__result.getQueryTime()) / 1000.0;
def getPaging(self):
return self.__paging
def getResult(self):
return self.__result
def getFacetField(self, key):
return self.__portal.facetFields.get(key)
def getFacetName(self, key):
return self.__portal.facetFields.get(key).getString(None, ["label"])
def getFacetCounts(self, key):
if self.__useSessionNavigation:
facetData = self.__result.getFacets()
if facetData is None:
return LinkedHashMap()
if not facetData.containsKey(key):
return LinkedHashMap()
return facetData.get(key).values()
else:
return LinkedHashMap()
# TODO : What were these doing? Hiding file path facets unless some facets are selected?
#if name.find("/") == -1 or self.hasSelectedFacets():
# values.put(name, count)
def getFacetDisplay(self):
return self.__portal.facetDisplay
def hasSelectedFacets(self):
return (self.__selected is not None and len(self.__selected) > 1) and \
not (self.__portal.query in self.__selected and len(self.__selected) == 2)
def getSelectedFacets(self):
return self.__selected
def isPortalQueryFacet(self, fq):
return fq == self.__portal.query
def isSelected(self, fq):
return fq in self.__selected
def getSelectedFacetIds(self):
return [md5.new(fq).hexdigest() for fq in self.__selected]
def getFileName(self, path):
return os.path.splitext(os.path.basename(path))[0]
示例3: __search
# 需要导入模块: from com.googlecode.fascinator.common.solr import SolrResult [as 别名]
# 或者: from com.googlecode.fascinator.common.solr.SolrResult import getFacets [as 别名]
def __search(self):
indexer = Services.getIndexer()
portalQuery = Services.getPortalManager().get(self.vc("portalId")).getQuery()
portalSearchQuery = Services.getPortalManager().get(self.vc("portalId")).getSearchQuery()
# Security prep work
current_user = self.vc("page").authentication.get_username()
security_roles = self.vc("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 + ")"
isAdmin = self.vc("page").authentication.is_admin()
req = SearchRequest("*:*")
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")
req.setParam("facet", "true")
req.setParam("facet.field", "workflow_step")
if not isAdmin:
req.addParam("fq", security_query)
out = ByteArrayOutputStream()
indexer.search(req, out)
steps = SolrResult(ByteArrayInputStream(out.toByteArray()))
self.__steps = steps.getFacets().get("workflow_step")
wfConfig = JsonSimple(FascinatorHome.getPathFile("harvest/workflows/dataset.json"))
jsonStageList = wfConfig.getJsonSimpleList(["stages"])
stages = []
for jsonStage in jsonStageList:
wfStage = WorkflowStage(jsonStage, self.__steps)
stages.append(wfStage)
self.__stages = stages
req = SearchRequest("*:*")
req.setParam("fq", 'item_type:"object"')
if portalQuery:
req.addParam("fq", portalQuery)
if portalSearchQuery:
req.addParam("fq", portalSearchQuery)
req.addParam("fq", "")
req.setParam("rows", "25")
req.setParam("sort", "last_modified desc, f_dc_title asc");
if not isAdmin:
req.addParam("fq", security_query)
out = ByteArrayOutputStream()
indexer.search(req, out)
self.__result = SolrResult(ByteArrayInputStream(out.toByteArray()))
req.addParam("fq", "workflow_step:%s" % stages[0].getName())
out = ByteArrayOutputStream()
indexer.search(req, out)
self.__alerts = SolrResult(ByteArrayInputStream(out.toByteArray()))
req = SearchRequest("last_modified:[NOW-1MONTH TO *] AND workflow_step:live")
req.setParam("fq", 'item_type:"object"')
if portalQuery:
req.addParam("fq", portalQuery)
if portalSearchQuery:
req.addParam("fq", portalSearchQuery)
req.setParam("rows", "10")
req.setParam("sort", "last_modified desc, f_dc_title asc");
if not isAdmin:
req.addParam("fq", security_query)
out = ByteArrayOutputStream()
indexer.search(req, out)
self.__latest = SolrResult(ByteArrayInputStream(out.toByteArray()))
self._searchEmbargoes()
self.vc("sessionState").set("fq", 'item_type:"object"')