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


Java SolrQuery.setFacetMinCount方法代碼示例

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


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

示例1: enableFaceting

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private boolean enableFaceting(SolrQuery solrQuery, FacetQuery query) {
	FacetOptions facetOptions = query.getFacetOptions();
	if (facetOptions == null || !facetOptions.hasFacets()) {
		return false;
	}
	solrQuery.setFacet(true);
	solrQuery.setFacetMinCount(facetOptions.getFacetMinCount());
	solrQuery.setFacetLimit(facetOptions.getPageable().getPageSize());
	if (facetOptions.getPageable().getPageNumber() > 0) {
		int offset = Math.max(0, facetOptions.getPageable().getOffset());
		solrQuery.set(FacetParams.FACET_OFFSET, offset);
	}
	if (FacetOptions.FacetSort.INDEX.equals(facetOptions.getFacetSort())) {
		solrQuery.setFacetSort(FacetParams.FACET_SORT_INDEX);
	}
	return true;
}
 
開發者ID:yiduwangkai,項目名稱:dubbox-solr,代碼行數:18,代碼來源:DefaultQueryParser.java

示例2: SolrFacetQueryFactoryImpl

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
 *
 */
public SolrFacetQueryFactoryImpl() {
    // create the base query (copied on each request to create new queries)
    baseQuery = new SolrQuery();
    baseQuery.setRows(0);
    baseQuery.setFacet(true);
    baseQuery.setFacetMinCount(1);
}
 
開發者ID:acdh-oeaw,項目名稱:vlo-curation,代碼行數:11,代碼來源:SolrFacetQueryFactoryImpl.java

示例3: testGetFacets

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
/**
 * Test of getFacets method, of class SearchResultsDaoImpl.
 *
 * @throws java.lang.Exception
 */
@Test
public void testGetFacets() throws Exception {
    final SolrQuery query = new SolrQuery();
    query.setRows(10);
    query.setStart(0);
    query.setFields(FIELD_NAME, FIELD_ID, FIELD_DESCRIPTION);
    query.setQuery(null);

    query.setFacet(true);
    query.setFacetMinCount(1);
    query.addFacetField(FIELD_COLLECTION, FIELD_COUNTRY);

    List<FacetField> facetFields = instance.getFacets(query);
    assertNotNull(facetFields);
    assertEquals(2, facetFields.size());

    // 1 collection
    assertThat(facetFields, Matchers.<FacetField>hasItem(Matchers.allOf(
            Matchers.<FacetField>hasProperty("name", equalTo(FIELD_COLLECTION)),
            Matchers.<FacetField>hasProperty("valueCount", equalTo(1)))));

    // 2 countries
    assertThat(facetFields, Matchers.<FacetField>hasItem(Matchers.allOf(
            Matchers.<FacetField>hasProperty("name", equalTo(FIELD_COUNTRY)),
            Matchers.<FacetField>hasProperty("valueCount", equalTo(2)))));
}
 
開發者ID:acdh-oeaw,項目名稱:vlo-curation,代碼行數:32,代碼來源:SearchResultsDaoImplTest.java

示例4: addFacetParameters

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private void addFacetParameters(SolrQuery query) {
  query.setFacet(true);
  query.addFacetField(facetFieldExtractor.getRandomFacetField());
  query.setFacetMinCount(facetMinCount);
  query.setFacetLimit(facetLimit);
  if(facetMethod != null && !"".equals(facetMethod)) {
    query.add("facet.method", facetMethod);
  }
  
}
 
開發者ID:lafourchette,項目名稱:solrmeter,代碼行數:11,代碼來源:ComplexQueryGenerator.java

示例5: modifySolrQuery

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
protected void modifySolrQuery(SolrQuery qry, RenderTask task) {
	qry.setFacet(true);
	qry.setRows(0);
	qry.setFacetMinCount(1);
	qry.addFacetField(this.facetField);
}
 
開發者ID:KRMAssociatesInc,項目名稱:eHMP,代碼行數:8,代碼來源:Query.java

示例6: testSOLRPatient

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private void testSOLRPatient(SolrServer solr, Map<String, Object> src, FrameTask task) throws FrameExecException {
		String pid = (String) src.get("pid");
		SolrQuery q = new SolrQuery("*:*");
		q.addFilterQuery("pid:"+pid);
		q.addFacetField("domain");
		q.setFacetMinCount(0);
		q.setRows(0);
//		System.out.println("\n\nSRC:" + src);
		
		try {
			QueryResponse resp = solr.query(q);
			FacetField facet = resp.getFacetField("domain");
			for (FacetField.Count count : facet.getValues()) {
				// compensate for JDS/SOLR domain name miss-matches
				String name = count.getName();
				if (!src.containsKey(name) && domainMap.containsKey(name)) {
					name = domainMap.get(name);
				}
				if (name == null) continue; // skip some items for now.
				
				// get the counts for each system
				int o1 = (src.get(name) == null) ? -1 : (Integer) src.get(name);
				long o2 = count.getCount();
				if (o1 != o2) {
					// add an error message action if they do not match
					String msg = String.format(MSG, pid, count.getName(), o1, o2);
					task.addAction(new FrameAction.RefDataAction(Table.buildRow("error", msg, "class", null, "resolutions", null)));
				}
				
				// TODO: if a key in one count does not exist in the other, throw an error too
			}
		} catch (Exception ex) {
			throw new FrameExecException(this, "Error running SOLR Query", ex);
		}
	}
 
開發者ID:KRMAssociatesInc,項目名稱:eHMP,代碼行數:36,代碼來源:SOLRIntegrityCheckFrame.java

示例7: getEventPropertyNames

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public Set<String> getEventPropertyNames(String... globalAgentIds) {
    SolrQuery solrQuery = new SolrQuery(ALL_DOCS_QUERY);
    solrQuery.setRows(0);

    StringBuilder globalAgentIdFilterQuery = new StringBuilder();
    globalAgentIdFilterQuery.append(FIELD_GLOBAL_AGENT_ID);
    globalAgentIdFilterQuery.append(":(");
    for (String eachGlobalAgentId : globalAgentIds) {
        globalAgentIdFilterQuery.append(escapeSolr(eachGlobalAgentId));
        globalAgentIdFilterQuery.append(" OR ");
    }
    globalAgentIdFilterQuery.setLength(globalAgentIdFilterQuery.length() - 4);
    globalAgentIdFilterQuery.append(')');
    solrQuery.addFilterQuery(globalAgentIdFilterQuery.toString());

    solrQuery.setFacet(true);
    solrQuery.setFacetMinCount(1);
    solrQuery.addFacetField(FIELD_PROPERTY_ID);

    try {
        QueryResponse response = this.solrClient.query(solrQuery);

        Set<String> result = new TreeSet<>();
        for (Count eachCount : response.getFacetField(FIELD_PROPERTY_ID).getValues()) {
            result.add(eachCount.getName());
        }

        return result;
    } catch (SolrException | SolrServerException | IOException e) {
        throw new DataRetrievalException("Failed to retrieve event property names", e);
    }
}
 
開發者ID:Indoqa,項目名稱:logspace,代碼行數:34,代碼來源:SolrAgentService.java

示例8: getSuggestion

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
@Override
public Suggestion getSuggestion(SuggestionInput input) {
    TimeTracker timeTracker = new TimeTracker();

    SolrQuery solrQuery = new SolrQuery(ALL_DOCS_QUERY);
    solrQuery.setRows(0);

    if (!StringUtils.isBlank(input.getText())) {
        solrQuery.addFilterQuery(FIELD_TOKENIZED_SEARCH_FIELD + ":" + escapeSolr(input.getText()) + "*");
    }

    addFilterQuery(solrQuery, FIELD_PROPERTY_ID, input.getPropertyId());
    addFilterQuery(solrQuery, FIELD_SPACE, input.getSpaceId());
    addFilterQuery(solrQuery, FIELD_SYSTEM, input.getSystemId());

    solrQuery.setFacetMinCount(1);
    solrQuery.addFacetField(FIELD_GLOBAL_AGENT_ID);

    try {
        Suggestion result = new Suggestion();

        QueryResponse response = this.solrClient.query(solrQuery);

        FacetField globalAgentIdFacetField = response.getFacetField(FIELD_GLOBAL_AGENT_ID);
        for (Count eachValue : globalAgentIdFacetField.getValues()) {
            String globalAgentId = eachValue.getName();

            result.addAgentDescription(this.getAgentDescription(globalAgentId));
        }

        result.setExecutionTime(timeTracker.getElapsed(MILLISECONDS));
        return result;
    } catch (SolrException | SolrServerException | IOException e) {
        throw new DataRetrievalException("Failed to create suggestions", e);
    }
}
 
開發者ID:Indoqa,項目名稱:logspace,代碼行數:37,代碼來源:SolrAgentService.java

示例9: loadAgentDescription

import org.apache.solr.client.solrj.SolrQuery; //導入方法依賴的package包/類
private AgentDescription loadAgentDescription(String globalAgentId) throws SolrServerException, IOException {
    SolrQuery query = new SolrQuery(ALL_DOCS_QUERY);
    query.setRows(0);

    query.setFilterQueries(FIELD_GLOBAL_AGENT_ID + ":\"" + globalAgentId + "\"");

    query.setFacetMinCount(1);
    query.addFacetField(FIELD_SPACE, FIELD_SYSTEM, FIELD_PROPERTY_ID);

    QueryResponse response = this.solrClient.query(query);

    AgentDescription result = new AgentDescription();
    result.setGlobalId(globalAgentId);
    result.setName(IdHelper.getAgentId(globalAgentId));
    result.setSpace(this.getFirstFacetValue(response, FIELD_SPACE));
    result.setSystem(this.getFirstFacetValue(response, FIELD_SYSTEM));

    List<PropertyDescription> propertyDescriptions = new ArrayList<>();
    FacetField facetField = response.getFacetField(FIELD_PROPERTY_ID);
    for (Count eachValue : facetField.getValues()) {
        propertyDescriptions.add(createPropertyDescription(eachValue.getName()));
    }
    Collections.sort(propertyDescriptions);
    result.setPropertyDescriptions(propertyDescriptions);

    return result;
}
 
開發者ID:Indoqa,項目名稱:logspace,代碼行數:28,代碼來源:SolrAgentService.java

示例10: 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

示例11: 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

示例12: 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.setFacetMinCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。