本文整理汇总了Java中org.elasticsearch.search.facet.range.RangeFacetBuilder类的典型用法代码示例。如果您正苦于以下问题:Java RangeFacetBuilder类的具体用法?Java RangeFacetBuilder怎么用?Java RangeFacetBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RangeFacetBuilder类属于org.elasticsearch.search.facet.range包,在下文中一共展示了RangeFacetBuilder类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getPriceRangeFacet
import org.elasticsearch.search.facet.range.RangeFacetBuilder; //导入依赖的package包/类
private RangeFacetBuilder getPriceRangeFacet(String facetCode)
{
return FacetBuilders.rangeFacet(facetCode)
.field(SearchDocumentFieldName.PRICE.getFieldName())
.addRange(0, 10)
.addRange(10, 20)
.addRange(20, 100);
}
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:9,代码来源:ProductQueryServiceImpl.java
示例2: getPriceRangeFacet
import org.elasticsearch.search.facet.range.RangeFacetBuilder; //导入依赖的package包/类
private RangeFacetBuilder getPriceRangeFacet(final String facetCode)
{
return FacetBuilders.rangeFacet(facetCode).field(SearchDocumentFieldName.PRICE.getFieldName()).addRange(0, 10).addRange(10, 20)
.addRange(20, 100);
}
开发者ID:jaibeermalik,项目名称:elasticsearch-akka,代码行数:6,代码来源:ProductQueryServiceImpl.java
示例3: handleFacetQueries
import org.elasticsearch.search.facet.range.RangeFacetBuilder; //导入依赖的package包/类
/**
* This method adds multiple facets to Elastic search query builder.
*
* @param searchContext the search context
* @param searchRequestBuilder the search request builder
*/
private void handleFacetQueries(SearchContext searchContext, SearchRequestBuilder searchRequestBuilder) {
Map<String, Facet> facets = searchContext.getFacets();
for (Facet facet : facets.values()) {
if (!facet.isStatic()) {
FacetConfiguration liferayFacetConfiguration = facet.getFacetConfiguration();
JSONObject liferayFacetDataJSONObject = liferayFacetConfiguration.getData();
if (facet instanceof MultiValueFacet) {
TermsFacetBuilder termsFacetBuilder = FacetBuilders.termsFacet(liferayFacetConfiguration.getFieldName());
termsFacetBuilder.field(liferayFacetConfiguration.getFieldName());
if (liferayFacetDataJSONObject.has(ElasticsearchIndexerConstants.ELASTIC_SEARCH_MAXTERMS)) {
termsFacetBuilder.size(liferayFacetDataJSONObject.getInt(ElasticsearchIndexerConstants.ELASTIC_SEARCH_MAXTERMS));
}
searchRequestBuilder.addFacet(termsFacetBuilder);
} else if (facet instanceof RangeFacet) {
RangeFacetBuilder rangeFacetBuilder = FacetBuilders.rangeFacet(liferayFacetConfiguration.getFieldName());
/**
*A typical ranges array looks like below.
*[{"range":"[20140603200000 TO 20140603220000]","label":"past-hour"},{"range":"[20140602210000 TO 20140603220000]","label":"past-24-hours"},...]
*
*/
JSONArray rangesJSONArray = liferayFacetDataJSONObject.getJSONArray(ElasticsearchIndexerConstants.ELASTIC_SEARCH_RANGES);
rangeFacetBuilder.field(ElasticsearchIndexerConstants.ELASTIC_SEARCH_INNERFIELD_MDATE);
if (rangesJSONArray != null) {
for (int i = 0; i < rangesJSONArray.length(); i++) {
JSONObject rangeJSONObject = rangesJSONArray.getJSONObject(i);
String[] fromTovalues = fetchFromToValuesInRage(rangeJSONObject);
if(fromTovalues != null){
rangeFacetBuilder.addRange(fromTovalues[0].trim(), fromTovalues[1].trim());
}
}
}
searchRequestBuilder.addFacet(rangeFacetBuilder);
}
}
}
}
开发者ID:rivetlogic,项目名称:liferay-elasticsearch-integration,代码行数:47,代码来源:ElasticsearchHelper.java
示例4: getPriceRangeFacet
import org.elasticsearch.search.facet.range.RangeFacetBuilder; //导入依赖的package包/类
private RangeFacetBuilder getPriceRangeFacet(final String facetCode) {
return FacetBuilders.rangeFacet(facetCode)
.field(SearchDocumentFieldName.PRICE.getFieldName())
.addRange(0, 10).addRange(10, 20).addRange(20, 100);
}
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:6,代码来源:ProductQueryServiceImpl.java
示例5: testRangeFacet
import org.elasticsearch.search.facet.range.RangeFacetBuilder; //导入依赖的package包/类
@Test
public void testRangeFacet() {
RangeFacetBuilder rfb =
FacetBuilders.rangeFacet(rangeFacetName).field("speech_number").addRange(2, 3);
// more examples:
// FacetBuilders.rangeFacet("f")
// .field("price") // Field to compute on
// .addUnboundedFrom(3) // from -infinity to 3 (excluded)
// .addRange(3, 6) // from 3 to 6 (excluded)
// .addUnboundedTo(6); // from 6 to +infinity
SearchResponse response =
client.prepareSearch(indexShakeSpeare)
.setQuery(QueryBuilders.termQuery(fieldShakeSpeare, targetText)).addFacet(rfb)
.execute().actionGet();
RangeFacet f = (RangeFacet) response.getFacets().facetsAsMap().get(rangeFacetName);
// For each entry
for (RangeFacet.Entry entry : f) {
// Range from requested
System.out.println(String.format("Range from requested: %f", entry.getFrom()));
// Range to requested
System.out.println(String.format("Range to requested: %f", entry.getTo()));
// Doc count
System.out.println(String.format("Doc count: %d", entry.getCount()));
// Min value
System.out.println(String.format("Min value: %f", entry.getMin()));
// Max value
System.out.println(String.format("Max value: %f", entry.getMax()));
// Mean value
System.out.println(String.format("Mean value: %f", entry.getMean()));
// Sum of values
System.out.println(String.format("Sum of values: %f", entry.getTotal()));
}
}
开发者ID:destiny1020,项目名称:elasticsearch-java-client-examples,代码行数:44,代码来源:FacetsApiOfficial.java
示例6: addRangeFacet
import org.elasticsearch.search.facet.range.RangeFacetBuilder; //导入依赖的package包/类
/**
* http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/
* search-facets-range-facet.html
*
* @param name
* @param field
* @return
*/
public RangeFacetBuilder addRangeFacet(String name, String field) {
RangeFacetBuilder builder = FacetBuilders.rangeFacet(name).field(field);
this.facets.add(builder);
return builder;
}
开发者ID:yamingd,项目名称:argo,代码行数:14,代码来源:SearchCriteriaImpl.java
注:本文中的org.elasticsearch.search.facet.range.RangeFacetBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论