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


Python SolrResult.getFacets方法代碼示例

本文整理匯總了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
開發者ID:ozej8y,項目名稱:redbox,代碼行數:22,代碼來源:csv.py

示例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]
開發者ID:kiranba,項目名稱:the-fascinator,代碼行數:70,代碼來源:search.py

示例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"')
開發者ID:greg-pendlebury,項目名稱:redbox,代碼行數:76,代碼來源:home.py


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