本文整理汇总了Java中org.elasticsearch.search.facet.FacetBuilder类的典型用法代码示例。如果您正苦于以下问题:Java FacetBuilder类的具体用法?Java FacetBuilder怎么用?Java FacetBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FacetBuilder类属于org.elasticsearch.search.facet包,在下文中一共展示了FacetBuilder类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: toFacetBuilders
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
@Override
public List<FacetBuilder> toFacetBuilders(Map<String, Attribute> facetAttributes) {
List<FacetBuilder> facets = new ArrayList<>();
if (facetAttributes == null || facetAttributes.size() == 0)
return facets;
Set<String> keys = facetAttributes.keySet();
for (String key : keys) {
Attribute attribute = facetAttributes.get(key);
String attributeCode = toHashOrOptionFacetAttributeCode(attribute);
if (attributeCode != null) {
facets.add(FacetBuilders.termsFacet(attributeCode).fields(attributeCode));
}
}
return facets;
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:22,代码来源:DefaultSearchHelper.java
示例2: toFacetBuilders
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
@Override
public List<FacetBuilder> toFacetBuilders(Map<String, Attribute> filterAttributes) {
List<FacetBuilder> facets = new ArrayList<>();
if (filterAttributes == null || filterAttributes.size() == 0)
return facets;
Set<String> keys = filterAttributes.keySet();
for (String key : keys) {
Attribute attr = filterAttributes.get(key);
String attrCode = null;
List<FilterIndexField> indexFields = attr.getProductListFilterIndexFields();
if (indexFields != null && indexFields.contains(FilterIndexField.ATT_SLUG)) {
attrCode = toSlugAttributeCode(attr.getCode(), true);
} else if (indexFields != null && indexFields.contains(FilterIndexField.NATIVE)) {
attrCode = attr.getCode();
}
if (attrCode != null) {
FilterType filterType = attr.getProductListFilterType();
if (filterType == FilterType.RANGE) {
facets.add(FacetBuilders.rangeFacet(attrCode).addRange(0, 50).addRange(51, 100).addRange(101, 150)
.addRange(151, 200).addRange(201, 500).addRange(501, 1000).addRange(1001, 1500)
.addRange(1501, 2000).addRange(2001, 5000).addUnboundedTo(5001).field(attrCode));
} else {
facets.add(FacetBuilders.termsFacet(attrCode).fields(attrCode));
}
}
}
return facets;
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:35,代码来源:DefaultElasticsearchHelper.java
示例3: addFacet
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
/**
* Adds a facet
*
* @param facet the facet
* @return self
*/
public IndexQuery<T> addFacet(FacetBuilder facet) {
Validate.notNull(facet, "facet cannot be null");
facets.add(facet);
return this;
}
开发者ID:CedricGatay,项目名称:play2-elasticsearch-jest,代码行数:13,代码来源:IndexQuery.java
示例4: convertStatisticalFacet
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
private static FacetBuilder convertStatisticalFacet(
String label, StatisticalFacet facet, String filterJson, FilterBuilder visibilityFilter) {
if (facet.isSet(StatisticalFacet._Fields.SCRIPT)) {
// Script based
final StatisticalScriptFacetBuilder ssf = FacetBuilders.statisticalScriptFacet(label);
ssf.script(facet.getScript().getScript());
if (facet.getScript().isSetParams()) {
for (final Map.Entry<String, Object> entry : convertParamsList(facet.getScript().getParams())
.entrySet()) {
ssf.param(entry.getKey(), entry.getValue());
}
}
addFacetFilter(ssf, filterJson, visibilityFilter);
return ssf;
} else if (facet.isSet(StatisticalFacet._Fields.FIELDS)) {
// Traditional
final StatisticalFacetBuilder sf = FacetBuilders.statisticalFacet(label);
if (facet.getFields().size() > 1) {
sf.fields(facet.getFields().toArray(new String[facet.getFields().size()]));
} else {
sf.field(facet.getFields().get(0));
}
addFacetFilter(sf, filterJson, visibilityFilter);
return sf;
}
return null;
}
开发者ID:ezbake,项目名称:ezelastic,代码行数:34,代码来源:ThriftToFacetConversions.java
示例5: addFacetFilter
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
private static void addFacetFilter(FacetBuilder facet, String filterJson, FilterBuilder visibilityFilter) {
// If filterJson is set add it along with visibility filter
final FilterBuilder facetFilter;
if (StringUtils.isBlank(filterJson)) {
facetFilter = visibilityFilter;
} else {
facetFilter = FilterBuilders.andFilter(FilterBuilders.wrapperFilter(filterJson), visibilityFilter);
facet.facetFilter(FilterBuilders.wrapperFilter(filterJson));
}
facet.facetFilter(facetFilter);
}
开发者ID:ezbake,项目名称:ezelastic,代码行数:13,代码来源:ThriftToFacetConversions.java
示例6: getSearchRequestBuilder
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
public JestSearchRequestBuilder getSearchRequestBuilder(@Nullable IndexQueryPath indexQueryPath, FilterBuilder filter) {
// Build request
JestSearchRequestBuilder request = new JestSearchRequestBuilder();
if (indexQueryPath != null) {
request.setIndices(indexQueryPath.index)
.setTypes(indexQueryPath.type);
}
request.setSearchType(io.searchbox.params.SearchType.QUERY_THEN_FETCH)
.setFilter(filter);
// set Query
if (StringUtils.isNotBlank(query)) {
request.setQuery(query);
} else {
request.setQuery(builder);
}
// set no Fields -> only return id and type
if (noField) {
request.setNoFields();
}
// Facets
for (FacetBuilder facet : facets) {
request.addFacet(facet);
}
// Sorting
for (SortBuilder sort : sorts) {
request.addSort(sort);
}
// Paging
if (from > -1) {
request.setFrom(from);
}
if (size > -1) {
request.setSize(size);
}
// Explain
if (explain) {
request.setExplain(true);
}
if (IndexClient.config.showRequest) {
if (StringUtils.isNotBlank(query)) {
Logger.debug("ElasticSearch : Query -> " + query);
} else {
Logger.debug("ElasticSearch : Query -> " + builder.toString());
}
}
return request;
}
开发者ID:CedricGatay,项目名称:play2-elasticsearch-jest,代码行数:56,代码来源:IndexQuery.java
示例7: addFacet
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
public JestSearchRequestBuilder addFacet(FacetBuilder facet) {
this.searchSourceBuilder.facet(facet);
return this;
}
开发者ID:CedricGatay,项目名称:play2-elasticsearch-jest,代码行数:5,代码来源:JestSearchRequestBuilder.java
示例8: search
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
/**
* 检索.
* http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-search.html
* @param query
* @param page
* @param size
* @return
*/
public <T> SearchResult<T> search(Class<T> clazz, SearchCriteria query, int page, int size) throws SearchException {
String typeName = this.getTypeNameFromClass(clazz);
Timer.Context timer = searchMetrics.indexTimer(typeName, "search:"+size);
try {
int start = page < 1 ? 0 : (page - 1) * size;
SearchRequestBuilder request = client
.prepareSearch(indexName)
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setTypes(typeName)
.setFrom(start).setSize(size)
.setExplain(false);
if(query.getQuery()!=null){
request.setQuery(query.getQuery());
}
if(query.getSorts()!=null && query.getSorts().size()>0){
for (SortBuilder item : query.getSorts()) {
request.addSort(item);
}
}
if(query.getFields()!=null && query.getFields().size()>0){
request.addFields(this.toArray(query.getFields()));
}
if(query.getFilter()!=null){
request.setFilter(query.getFilter());
}
if(query.getFacets()!=null && query.getFacets().size() > 0){
for(FacetBuilder facet : query.getFacets()){
request.addFacet(facet);
}
}
if(query.getSuggests()!=null && query.getSuggests().size() > 0){
for(SuggestionBuilder<?> builder : query.getSuggests()){
request.addSuggestion(builder);
}
}
SearchResponse response = request.execute().actionGet();
searchMetrics.indexIncr(typeName, "search:"+size);
return parseSearchResponse(clazz, page, size, response);
} catch (Exception e) {
searchMetrics.failedIncr(typeName, "search:"+size, e);
logger.error("search Error. ", e);
throw new SearchException("search Error. typeName="+typeName, e);
}finally {
timer.stop();
}
}
开发者ID:yamingd,项目名称:argo,代码行数:55,代码来源:ElasticSearchTemplate.java
示例9: getFacets
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
@Override
public List<FacetBuilder> getFacets() {
return facets;
}
开发者ID:yamingd,项目名称:argo,代码行数:5,代码来源:SearchCriteriaImpl.java
示例10: addFacet
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T extends SearchCriteria> T addFacet(FacetBuilder facet) {
this.facets.add(facet);
return (T) this;
}
开发者ID:yamingd,项目名称:argo,代码行数:6,代码来源:SearchCriteriaImpl.java
示例11: facetBuilder
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
public SearchRequestBuilder<JsonInput, JsonOutput> facetBuilder(FacetBuilder facet) {
sourceBuilder().facet(facet);
return this;
}
开发者ID:javanna,项目名称:elasticshell,代码行数:5,代码来源:SearchRequestBuilder.java
示例12: getFacets
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
/**
* 使用org.elasticsearch.search.facet.FacetBuilders构造.
* org.elasticsearch.search.facet.FacetBuilders
* @return
*/
List<FacetBuilder> getFacets();
开发者ID:yamingd,项目名称:argo,代码行数:7,代码来源:SearchCriteria.java
示例13: toFacetBuilders
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
public List<FacetBuilder> toFacetBuilders(Map<String, Attribute> facetAttributes);
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:2,代码来源:SearchHelper.java
示例14: toFacetBuilders
import org.elasticsearch.search.facet.FacetBuilder; //导入依赖的package包/类
public List<FacetBuilder> toFacetBuilders(Map<String, Attribute> filterAttributes);
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:2,代码来源:ElasticsearchHelper.java
注:本文中的org.elasticsearch.search.facet.FacetBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论