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


Java SolrQuery.addFacetQuery方法代碼示例

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


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

示例1: attachFacets

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
 * Notifies solr about which facets you want it to determine results and counts for
 * 
 * @param query
 * @param namedFacetMap
 */
protected void attachFacets(SolrQuery query, Map<String, SearchFacetDTO> namedFacetMap) {
    query.setFacet(true);
    for (Entry<String, SearchFacetDTO> entry : namedFacetMap.entrySet()) {
        SearchFacetDTO dto = entry.getValue();
        String facetTagField = entry.getValue().isActive() ? shs.getGlobalFacetTagField() : entry.getKey();

        // Clone the list - we don't want to remove these facets from the DB
        List<SearchFacetRange> facetRanges = new ArrayList<SearchFacetRange>(dto.getFacet().getSearchFacetRanges());

        if (extensionManager != null) {
            extensionManager.getProxy().filterSearchFacetRanges(dto, facetRanges);
        }

        if (facetRanges != null && facetRanges.size() > 0) {
            for (SearchFacetRange range : facetRanges) {
                query.addFacetQuery(getSolrTaggedFieldString(entry.getKey(), facetTagField, "ex", range));
            }
        } else {
            query.addFacetField(getSolrTaggedFieldString(entry.getKey(), facetTagField, "ex", null));
        }
    }
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:29,代碼來源:SolrSearchServiceImpl.java

示例2: attachFacets

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public void attachFacets(SolrQuery query, Map<String, SearchFacetDTO> namedFacetMap) {
    query.setFacet(true);
    for (Entry<String, SearchFacetDTO> entry : namedFacetMap.entrySet()) {
        SearchFacetDTO dto = entry.getValue();

        // Clone the list - we don't want to remove these facets from the DB
        List<SearchFacetRange> facetRanges = new ArrayList<SearchFacetRange>(dto.getFacet().getSearchFacetRanges());

        if (extensionManager != null) {
            extensionManager.getProxy().filterSearchFacetRanges(dto, facetRanges);
        }

        if (facetRanges != null && facetRanges.size() > 0) {
            for (SearchFacetRange range : facetRanges) {
                query.addFacetQuery(getSolrTaggedFieldString(entry.getKey(), "key", range));
            }
        } else {
            query.addFacetField(getSolrTaggedFieldString(entry.getKey(), "key", null));
        }
    }
}
 
開發者ID:takbani,項目名稱:blcdemo,代碼行數:23,代碼來源:SolrHelperServiceImpl.java

示例3: createQueryException

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private QueryException createQueryException() {
	QueryException queryException = new QueryException();
	SolrQuery query = new SolrQuery();
	query.setQuery("test");
	query.setFilterQueries("field=value");
	query.addFacetQuery("filterQuery=value");
	queryException.setQuery(query);
	return queryException;
}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:10,代碼來源:QueryLogStatisticTestCase.java

示例4: appendFacetingQueries

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private void appendFacetingQueries(SolrQuery solrQuery, FacetQuery query) {
	FacetOptions facetOptions = query.getFacetOptions();
	for (SolrDataQuery fq : facetOptions.getFacetQueries()) {
		String facetQueryString = getQueryString(fq);
		if (StringUtils.isNotBlank(facetQueryString)) {
			solrQuery.addFacetQuery(facetQueryString);
		}
	}
}
 
開發者ID:yiduwangkai,項目名稱:dubbox-solr,代碼行數:10,代碼來源:DefaultQueryParser.java

示例5: initQuery

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
public SolrQuery initQuery() {
		// create default SOLR query
		SolrQuery query = new SolrQuery(ClientUtils.escapeQueryChars(getQueryStr()));
		query.addFilterQuery("pid:" + pid); // specific to the current patient
		query.setParam("q.op", "AND"); 
		query.setRows(101); // limit to 100 rows
		
		// default fields to fetch
		query.setFields(UID, DATETIME, SUMMARY, URL_FIELD, DOMAIN, KIND, FACILITY);
		
		// apply range filter (if specified)
		if (hasFilter("range")) {
			String range = getFilter("range");
			query.addFilterQuery("{!tag=dt}datetime:[" + new PointInTime(range) + " TO *]");
		}
		
		// apply kind(s) filter (if specified)
		if (hasFilter("kinds")) {
			Set<String> kinds = StringUtils.commaDelimitedListToSet(getFilter("kinds"));
			String kindFilter = StringUtils.collectionToDelimitedString(kinds, " OR ", "\"", "\"");
			query.addFilterQuery("kind:(" + kindFilter + ")");
		}

		// apply types filter (if specified)
		if (hasFilter("types")) {
			Set<String> types = StringUtils.commaDelimitedListToSet(getFilter("types"));
			String typeFilter = StringUtils.collectionToDelimitedString(types, " OR ", "\"", "\"");
			query.addFilterQuery("{!tag=domain}domain:(" + typeFilter + ")");
		}
		
		// add date range facets
    	for (String s : facetsNames.keySet()) {
    		query.addFacetQuery(s);
    	}
    	
    	query.addFacetField("{!ex=domain}domain");
    	query.setFacetMinCount(1);
    	
    	// extra debug stuff
    	if (isDebugEnabled()) {
    		query.set("debug", "true");
    	}

//    	System.out.println(URLDecoder.decode(query.toString()));
		return query;
	}
 
開發者ID:KRMAssociatesInc,項目名稱:eHMP,代碼行數:47,代碼來源:PatientSearch.java


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