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


Java SolrQuery.setFacetPrefix方法代碼示例

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


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

示例1: appendFacetingOnFields

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private void appendFacetingOnFields(SolrQuery solrQuery, FacetQuery query) {
	FacetOptions facetOptions = query.getFacetOptions();
	solrQuery.addFacetField(convertFieldListToStringArray(facetOptions.getFacetOnFields()));
	if (facetOptions.hasFacetPrefix()) {
		solrQuery.setFacetPrefix(facetOptions.getFacetPrefix());
	}
	for (FacetOptions.FieldWithFacetParameters parametrizedField : facetOptions.getFieldsWithParameters()) {
		addPerFieldFacetParameters(solrQuery, parametrizedField);
		if (parametrizedField.getSort() != null && FacetOptions.FacetSort.INDEX.equals(parametrizedField.getSort())) {
			addFieldSpecificParameterToSolrQuery(solrQuery, parametrizedField, new FacetParameter(FacetParams.FACET_SORT,
					FacetParams.FACET_SORT_INDEX));
		}

	}
}
 
開發者ID:yiduwangkai,項目名稱:dubbox-solr,代碼行數:16,代碼來源:DefaultQueryParser.java

示例2: categoriesAvailable

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
public static Map<String, Object> categoriesAvailable(String catalogId, String categoryId, String productId, 
        String facetPrefix, boolean displayproducts, int viewIndex, int viewSize, List<String> queryFilters, Boolean excludeVariants, String core) {
    // create the data model
    Map<String, Object> result = new HashMap<>();
    HttpSolrClient client = null;
    QueryResponse returnMap = new QueryResponse();
    try {
        // do the basic query
        client = SolrUtil.getHttpSolrClient(core);
        // create Query Object
        String query = "inStock[1 TO *]";
        if (categoryId != null)
            query += " +cat:"+ SolrExprUtil.escapeTermFull(categoryId);
        else if (productId != null)
            query += " +productId:" + SolrExprUtil.escapeTermFull(productId);
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.setQuery(query);

        if (catalogId != null)
            solrQuery.addFilterQuery("+catalog:" + SolrExprUtil.escapeTermFull(catalogId));
        
        if (excludeVariants == null) excludeVariants = SolrProductSearch.excludeVariantsDefault;
        if (excludeVariants)
            SolrProductUtil.addExcludeVariantsFilter(solrQuery);
        
        if (displayproducts) {
            if (viewSize > -1) {
                solrQuery.setRows(viewSize);
            } else
                solrQuery.setRows(50000);
            if (viewIndex > -1) {
                // 2016-04-01: This must be calculated
                //solrQuery.setStart(viewIndex);
                if (viewSize > 0) {
                    solrQuery.setStart(viewSize * viewIndex);
                }
            }
        } else {
            solrQuery.setFields("cat");
            solrQuery.setRows(0);
        }
        
        if(UtilValidate.isNotEmpty(facetPrefix)){
            solrQuery.setFacetPrefix(facetPrefix);
        }
        
        solrQuery.setFacetMinCount(0);
        solrQuery.setFacet(true);
        solrQuery.addFacetField("cat");
        solrQuery.setFacetLimit(-1);
        if (Debug.verboseOn()) Debug.logVerbose("solr: solrQuery: " + solrQuery, module);
        returnMap = client.query(solrQuery,METHOD.POST);
        result.put("rows", returnMap);
        result.put("numFound", returnMap.getResults().getNumFound());
    } catch (Exception e) {
        Debug.logError(e.getMessage(), module);
    }
    return result;
}
 
開發者ID:ilscipio,項目名稱:scipio-erp,代碼行數:60,代碼來源:SolrCategoryUtil.java

示例3: suggestOLD

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
protected void suggestOLD(PatientSearch search, FrameTask task) throws FrameException {
			/*
			 * Suggestion strategy as of 1/31/14
			 * - stick to the patient-specific faceting of phrases (but using the shingled filter)
			 * - also use the spellchecker to find misspellings (non-patient specific)
			 * - TODO: still need to pull the clinical text suggested keywords in? (not stored in phrase)
			 * - TODO: really need to investigate the eDisMax parser and it's shingle capability
			 *  
			 * http://localhost:8080/solr/select?q=*:*&fq=pid:10101&rows=0&facet=true&facet.field=phrase&facet.mincount=1&facet.prefix=discharge%20sum&spellcheck=true&spellcheck.q=dischare%20sum
			 */
			String str = search.getQueryStr();
			SolrQuery q = new SolrQuery("*:*");
//			q.addFilterQuery("pid:"+search.pid);
			q.setRows(0);
			q.setFacetLimit(3);
			q.setFacetMinCount(1);
			q.addFacetField(SearchService.PHRASE);
			q.setFacetPrefix(str);
			q.set("spellcheck", true);
			q.set(SpellingParams.SPELLCHECK_Q, str);
			q.set(SpellingParams.SPELLCHECK_DICT, "spell","suggest"); // TODO: build into searcher?
			q.set(SpellingParams.SPELLCHECK_COLLATE, true);
			
			// if facets exist, use them as patient-specific suggestions
	        QueryResponse response = execSolrQuery(q, task);
	        if (response.getFacetField(SearchService.PHRASE) != null) {
	        	List<Count> counts = response.getFacetField(SearchService.PHRASE).getValues();
	        	for (Count count : counts) {
	        		search.addSuggestion(new SuggestItem(count.getName(), count.getName(), "Patient Match"))
	        			.setSort(SuggestItem.SortCat.SUGGEST, count.getCount());
	        	}
	        }
			
			// if spellcheck results exist, list them as non-patient suggestions
			SpellCheckResponse spell = response.getSpellCheckResponse();
			if (spell != null) {
				// add suggestions
				for (Suggestion s : spell.getSuggestions()) {
					for (String str2 : s.getAlternatives()) {
						search.addSuggestion(new SuggestItem(str2, str2, "Spelling Suggestion"))
							.setSort(SuggestItem.SortCat.SPELL, 1);
					}
				}
			}
		}
 
開發者ID:KRMAssociatesInc,項目名稱:eHMP,代碼行數:46,代碼來源:GoldSearchFrame.java


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