当前位置: 首页>>代码示例>>Java>>正文


Java FacetField类代码示例

本文整理汇总了Java中org.apache.solr.client.solrj.response.FacetField的典型用法代码示例。如果您正苦于以下问题:Java FacetField类的具体用法?Java FacetField怎么用?Java FacetField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FacetField类属于org.apache.solr.client.solrj.response包,在下文中一共展示了FacetField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSets

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
/**
 * Creates a list with all available values for the given field (minus any blacklisted values).
 * 
 * @return
 * @throws SolrServerException
 * @should return all values
 */
public List<String> getSets(String field) throws SolrServerException {
    List<String> ret = new ArrayList<>();

    SolrQuery query = new SolrQuery();
    query.setQuery(field + ":* " + DataManager.getInstance().getConfiguration().getCollectionBlacklistFilterSuffix());
    query.setStart(0);
    query.setRows(0);
    query.addFacetField(field);
    logger.trace("Set query: {}", query.getQuery());
    QueryResponse resp = server.query(query);

    FacetField facetField = resp.getFacetField(field);
    if (facetField != null) {
        for (Count count : facetField.getValues()) {
            if (count.getCount() == 0) {
                continue;
            }
            ret.add(count.getName());
        }
    }

    Collections.sort(ret);
    logger.trace("{} terms found for {}", ret.size(), field);
    return ret;
}
 
开发者ID:intranda,项目名称:goobi-viewer-connector,代码行数:33,代码来源:SolrSearchIndex.java

示例2: processFacetResults

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
/**
 * Add any faceting results to the result builder.
 *
 * @param resultsBuilder query result builder
 * @param facetFields faceting results
 */
protected void processFacetResults(QueryResults.Builder<QR> resultsBuilder, List<FacetField> facetFields) {
    if (facetFields != null) {
        for (FacetField facetField : facetFields) {
            String fieldName = facetField.getName();

            List<FacetCount> facetCounts = new ArrayList<>();
            for (FacetField.Count count : facetField.getValues()) {
                facetCounts.add(new FacetCount(count.getName(), count.getCount()));
            }

            FacetResult facetResult = new FacetResult(fieldName, facetCounts);
            resultsBuilder.addFacetResult(facetResult);
        }
    }
}
 
开发者ID:bbende,项目名称:tripod,代码行数:22,代码来源:SolrService.java

示例3: getFacets

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
@Override
public List<FacetField> getFacets(SolrQuery query) {
    //final QueryResponse response = fireQuery(sanitise(query));
	//curation instance doesnt sanitase queries
    final QueryResponse response = fireQuery(query);
    final List<FacetField> facetFields = response.getFacetFields();
    if (logger.isDebugEnabled()) {
        if (facetFields.size() == 1) {
            final FacetField field = facetFields.get(0);
            logger.debug("Found facet field '{}' with {} values", field.getName(), field.getValueCount());
        } else {
            logger.debug("Found {} facet fields", facetFields.size());
        }
    }
    return facetFields;
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:17,代码来源:SearchResultsDaoImpl.java

示例4: removeSelectedValsFromResponse

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
private  List<FacetField> removeSelectedValsFromResponse(QueryFacetsSelection query, List<FacetField> response){
	List<FacetField> cleanedFacets = new ArrayList<>();
	
	//for each facet from response
	for(FacetField facet: response){
		FacetSelection facetSelection = query.getSelectionValues(facet.getName());
		
		if(facetSelection == null){
			cleanedFacets.add(facet);
			continue;
		}else{
 		Collection<String> selectedValues =  facetSelection.getValues();
 		
 		FacetField _newFacetField = new FacetField(facet.getName(), facet.getName(), facet.getEnd());
 		//for each value from facet check if is selected and if not add it to the new response
 		for(Count val: facet.getValues()){
 			if(!selectedValues.contains(val.getName()))
 				_newFacetField.add(val.getName(), val.getCount());
 		}
 		
 		cleanedFacets.add(_newFacetField);
		}
	}
	
	return cleanedFacets;
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:27,代码来源:SolrFacetFieldsService.java

示例5: removeSelected

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
private FacetField removeSelected(FacetField facetField, FacetSelection selection) {
    FacetField filtered = new FacetField(facetField.getName());
    if (selection != null
            && selection.getSelectionType() == FacetSelectionType.AND) {
        //we want to exclude the selected option(s) in case of an AND selection
        for (FacetField.Count value : facetField.getValues()) {
            final String valueName = value.getName();
            if (selection.getValues().contains(valueName)
                    //exclude negative value selectors
                    //(not such a great solution, added to make availability facet checkboxes work)
                    && selection.getQualifier(valueName) != FacetSelectionValueQualifier.NOT
                    ) {
                continue;
            } else {
                filtered.add(valueName, value.getCount());
            }
        }
        return filtered;
    } else {
        return facetField;
    }

}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:24,代码来源:FacetFieldsModel.java

示例6: FacetPanel

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
public FacetPanel(String id, IModel<String> facetNameModel, IModel<FacetField> facetFieldModel, final IModel<QueryFacetsSelection> selectionModel, IModel<ExpansionState> expansionState, int subListSize) {
    super(id, facetNameModel, expansionState);

    // panel showing values for selection
    facetValuesPanel = createFacetValuesPanel("facetValues", facetNameModel.getObject(), facetFieldModel, selectionModel, subListSize);
    add(facetValuesPanel);

    // panel showing current selection, allowing for deselection
    selectedFacetPanel = createSelectedFacetPanel("facetSelection", facetNameModel.getObject(), selectionModel);
    add(selectedFacetPanel);

    add(new AttributeAppender("class", new AbstractReadOnlyModel() {
        @Override
        public Object getObject() {
            return (selectedFacetPanel.getModelObject().isEmpty()) ? "unselected" : "selected";
        }
    }, " "));
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:19,代码来源:FacetPanel.java

示例7: createAllValuesLink

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
/**
 * Creates a link that leads to the 'all facet values' view, either as a
 * modal window (if JavaScript is enabled, see {@link #createAllValuesWindow(java.lang.String)
 * }) or by redirecting to {@link AllFacetValuesPage}
 *
 * @param id component id
 * @return 'show all values' link
 */
private Link createAllValuesLink(String id) {
    final Link link = new IndicatingAjaxFallbackLink<FacetField>(id, getModel()) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            if (target == null) {
                // no JavaScript, open a new page with values
                setResponsePage(new AllFacetValuesPage(getModel(), selectionModel));
            } else {
                // JavaScript enabled, show values in a modal popup
                valuesWindow.show(target);
            }
        }

        @Override
        protected void onConfigure() {
            super.onConfigure();
            // only show if there actually are more values!
            setVisible(getModelObject().getValueCount() > MAX_NUMBER_OF_FACETS_TO_SHOW);
        }

    };
    return link;
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:33,代码来源:FacetValuesPanel.java

示例8: testGetFacetFields

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
/**
 * Test of getFacetFields method, of class SolrFacetFieldsService.
 */
@Test
public void testGetFacetFields() {
    // selection passed to service
    final QueryFacetsSelection selection = new QueryFacetsSelection("query");
    // query returned by factory for selection
    final SolrQuery query = new SolrQuery("query");
    // fields returned by dao for query
    final List<FacetField> fields = ImmutableList.of(new FacetField("field1"), new FacetField("field2"));
    final List<String> facets = ImmutableList.of("facet1", "facet2");

    context.checking(new Expectations() {
        {
            oneOf(queryFactory).createFacetQuery(selection, facets, 20);
            will(returnValue(query));
            oneOf(dao).getFacets(query);
            will(returnValue(fields));
        }
    });

    final List<FacetField> result = instance.getFacetFields(selection, facets, 20);
    assertEquals(fields, result);
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:26,代码来源:SolrFacetFieldsServiceTest.java

示例9: testGetObject

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
/**
 * Test of load method, of class FacetFieldsModel.
 */
@Test
public void testGetObject() {
    final FacetFieldModel instance = new FacetFieldModel("facet4", new FacetFieldsModel(service, ImmutableList.of("facet4"), selectionModel, 20));
    
    context.checking(new Expectations() {
        {
            oneOf(service).getFacetFields(selection, ImmutableList.of("facet4"), 20);
            will(returnValue(Arrays.asList(
                    new FacetField("facet4")
            )));
        }
    });

    final FacetField result = instance.getObject();
    // selection should be returned
    assertEquals("facet4", result.getName());
    
    // make another call, should not trigger a call to service because model is loadabledetachable
    final FacetField result2 = instance.getObject();
    assertEquals(result, result2);
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:25,代码来源:FacetFieldModelTest.java

示例10: testGetObjectNotIncluded

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
/**
 * Test of load method, of class FacetFieldsModel.
 */
@Test
public void testGetObjectNotIncluded() {
    final FacetFieldModel instance = new FacetFieldModel("facet4", new FacetFieldsModel(service, ImmutableList.of("facet4"), selectionModel, 20));

    context.checking(new Expectations() {
        {
            oneOf(service).getFacetFields(selection, ImmutableList.of("facet4"), 20);
            will(returnValue(Collections.emptyList()));
        }
    });

    final FacetField result = instance.getObject();
    // selection should be returned
    assertNull(result);
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:19,代码来源:FacetFieldModelTest.java

示例11: obtainCollectionCounts

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
private List<VloReport.CollectionCount> obtainCollectionCounts(SolrServer solrServer) throws SolrServerException {
    final SolrQuery query = new SolrQuery();
    query.setRows(0);
    query.setFacet(true);
    query.addFacetField(FacetConstants.FIELD_COLLECTION);
    query.setFacetLimit(Integer.MAX_VALUE);

    final QueryResponse result = solrServer.query(query);
    final FacetField collectionField = result.getFacetField(FacetConstants.FIELD_COLLECTION);
    logger.debug("Collection field: {}", collectionField.getValues());

    final List<VloReport.CollectionCount> counts
            = collectionField.getValues().stream().map((count) -> {
                VloReport.CollectionCount collectionCount = new VloReport.CollectionCount();
                collectionCount.setCollection(count.getName());
                collectionCount.setCount(count.getCount());
                return collectionCount;
            }).collect(Collectors.toList());
    return counts;
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:21,代码来源:CollectionsCollector.java

示例12: obtainFacetStats

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
private List<VloReport.Facet> obtainFacetStats(VloConfig config, SolrServer solrServer) throws SolrServerException {
    final SolrQuery query = new SolrQuery();
    query.setRows(0);
    query.setFacet(true);
    FacetConstants.AVAILABLE_FACETS.forEach((field) -> {
        query.addFacetField(field);
    });
    query.setFacetLimit(-1);

    final QueryResponse result = solrServer.query(query);
    final List<FacetField> facetFields = result.getFacetFields();

    final List<VloReport.Facet> facets
            = facetFields.stream().map((field) -> {
                final VloReport.Facet facet = new VloReport.Facet();
                facet.setName(field.getName());
                facet.setValueCount(field.getValueCount());
                return facet;
            }).collect(Collectors.toList());
    return facets;
}
 
开发者ID:acdh-oeaw,项目名称:vlo-curation,代码行数:22,代码来源:FacetValueCountsCollector.java

示例13: testRestrictedSearch

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
/**
 *
 */
@Test
public final void testRestrictedSearch() throws Exception {
	Map<String, String> selectedFacets = new HashMap<String, String>();

	selectedFacets.put("taxon.distribution_TDWG_0_ss", "AUSTRALASIA");

	Page<SearchableObject> results = getSearchableObjectDao().search("taxon.scientific_name_t:Aus", null, null, null,
			new String[] {"taxon.distribution_TDWG_0_ss" , "taxon.distribution_TDWG_1_ss"}, null, selectedFacets, null, null);
	assertEquals("There should be 2 taxa matching Aus found in AUSTRALASIA", new Integer(2), (Integer)results.getSize());
	for(String facetName : results.getFacetNames()) {
		logger.debug(facetName);
		FacetField facet = results.getFacetField(facetName);
		for(Count count : facet.getValues()) {
			logger.debug("\t" + count.getName() + " " + count.getCount());
		}
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:21,代码来源:SearchTest.java

示例14: testSearchWithFacets

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
/**
 *
 */
@Test
public final void testSearchWithFacets() throws Exception {
	Map<String, String> selectedFacets = new HashMap<String, String>();
	selectedFacets.put("base.class_s", "org.emonocot.model.Taxon");
	Page<SearchableObject> pager = searchableObjectService.search("Aus",
			null, null, null, new String[] {"base.class_s",
			"taxon.family_ss", "taxon.distribution_TDWG_0_ss",
	"searchable.sources_ss" },
	null, selectedFacets, null, null);
	assertThat("There should be two facets returned",
			pager.getFacetNames(), containsInAnyOrder("base.class_s",
					"taxon.family_ss", "taxon.distribution_TDWG_0_ss",
					"searchable.sources_ss"));

	FacetField classFacet = pager.getFacetField("base.class_s");
	String[] Strings = new String[classFacet.getValueCount()];
	for (int i = 0; i < Strings.length; i++) {
		Strings[i] = classFacet.getValues().get(i).getName();
	}

	assertThat("org.emonocot.model.Taxon should be a facet in CLASS",
			Strings, hasItemInArray("org.emonocot.model.Taxon"));
	assertEquals("There should be one value for the FAMILY facet", 1, pager
			.getFacetField("taxon.family_ss").getValues().size());
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:29,代码来源:FacetingTest.java

示例15: getRowTotal

import org.apache.solr.client.solrj.response.FacetField; //导入依赖的package包/类
public Long getRowTotal(Member row) {
	FacetField.Count count = null;
	for(FacetField.Count c : totalRows.getValues()) {
		if(c.getName() == null) {
			if(row.getValue() == null){
				count = c;
				break;
			}
		} else if(c.getName().equals(row.getValue())) {
			count = c;
			break;
		}
	}
	if(count == null) {
		return null;
	} else {
		return count.getCount();
	}
}
 
开发者ID:RBGKew,项目名称:eMonocot,代码行数:20,代码来源:CellSet.java


注:本文中的org.apache.solr.client.solrj.response.FacetField类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。