mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-09 14:35:04 +00:00
javadoc
This commit is contained in:
parent
d0cdbeffba
commit
ef369fc40f
@ -26,22 +26,40 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Numeric histogram information.
|
* Numeric histogram facet.
|
||||||
*
|
*
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public interface HistogramFacet extends Facet, Iterable<HistogramFacet.Entry> {
|
public interface HistogramFacet extends Facet, Iterable<HistogramFacet.Entry> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key field name used with this facet.
|
||||||
|
*/
|
||||||
String keyFieldName();
|
String keyFieldName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key field name used with this facet.
|
||||||
|
*/
|
||||||
String getKeyFieldName();
|
String getKeyFieldName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value field name used with this facet.
|
||||||
|
*/
|
||||||
String valueFieldName();
|
String valueFieldName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value field name used with this facet.
|
||||||
|
*/
|
||||||
String getValueFieldName();
|
String getValueFieldName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An ordered list of histogram facet entries.
|
||||||
|
*/
|
||||||
List<Entry> entries();
|
List<Entry> entries();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An ordered list of histogram facet entries.
|
||||||
|
*/
|
||||||
List<Entry> getEntries();
|
List<Entry> getEntries();
|
||||||
|
|
||||||
public static enum ComparatorType {
|
public static enum ComparatorType {
|
||||||
@ -131,6 +149,9 @@ public interface HistogramFacet extends Facet, Iterable<HistogramFacet.Entry> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A histogram entry representing a single entry within the result of a histogram facet.
|
||||||
|
*/
|
||||||
public class Entry {
|
public class Entry {
|
||||||
private final long key;
|
private final long key;
|
||||||
private final long count;
|
private final long count;
|
||||||
@ -142,34 +163,58 @@ public interface HistogramFacet extends Facet, Iterable<HistogramFacet.Entry> {
|
|||||||
this.total = total;
|
this.total = total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key value of the histogram.
|
||||||
|
*/
|
||||||
public long key() {
|
public long key() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The key value of the histogram.
|
||||||
|
*/
|
||||||
public long getKey() {
|
public long getKey() {
|
||||||
return key();
|
return key();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of hits that fall within that key "range" or "interval".
|
||||||
|
*/
|
||||||
public long count() {
|
public long count() {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of hits that fall within that key "range" or "interval".
|
||||||
|
*/
|
||||||
public long getCount() {
|
public long getCount() {
|
||||||
return count();
|
return count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sum / total of the value field that fall within this key "interval".
|
||||||
|
*/
|
||||||
public double total() {
|
public double total() {
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sum / total of the value field that fall within this key "interval".
|
||||||
|
*/
|
||||||
public double getTotal() {
|
public double getTotal() {
|
||||||
return total();
|
return total();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mean of this facet interval.
|
||||||
|
*/
|
||||||
public double mean() {
|
public double mean() {
|
||||||
return total / count;
|
return total / count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mean of this facet interval.
|
||||||
|
*/
|
||||||
public double getMean() {
|
public double getMean() {
|
||||||
return mean();
|
return mean();
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,11 @@ import org.elasticsearch.search.builder.SearchSourceBuilderException;
|
|||||||
import org.elasticsearch.search.facets.AbstractFacetBuilder;
|
import org.elasticsearch.search.facets.AbstractFacetBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* A facet builder of histogram facets.
|
||||||
|
*
|
||||||
* @author kimchy (shay.banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class HistogramFacetBuilder extends AbstractFacetBuilder {
|
public class HistogramFacetBuilder extends AbstractFacetBuilder {
|
||||||
@ -35,41 +38,76 @@ public class HistogramFacetBuilder extends AbstractFacetBuilder {
|
|||||||
private long interval = -1;
|
private long interval = -1;
|
||||||
private HistogramFacet.ComparatorType comparatorType;
|
private HistogramFacet.ComparatorType comparatorType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a new histogram facet with the provided facet logical name.
|
||||||
|
*
|
||||||
|
* @param name The logical name of the facet
|
||||||
|
*/
|
||||||
public HistogramFacetBuilder(String name) {
|
public HistogramFacetBuilder(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The field name to perform the histogram facet. Translates to perform the histogram facet
|
||||||
|
* using the provided field as both the {@link #keyField(String)} and {@link #valueField(String)}.
|
||||||
|
*/
|
||||||
public HistogramFacetBuilder field(String field) {
|
public HistogramFacetBuilder field(String field) {
|
||||||
this.keyFieldName = field;
|
this.keyFieldName = field;
|
||||||
this.valueFieldName = field;
|
this.valueFieldName = field;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The field name to use in order to control where the hit will "fall into" within the histogram
|
||||||
|
* entries. Essentially, using the key field numeric value, the hit will be "rounded" into the relevant
|
||||||
|
* bucket controlled by the interval.
|
||||||
|
*/
|
||||||
public HistogramFacetBuilder keyField(String keyField) {
|
public HistogramFacetBuilder keyField(String keyField) {
|
||||||
this.keyFieldName = keyField;
|
this.keyFieldName = keyField;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The field name to use as the value of the hit to compute data based on values within the interval
|
||||||
|
* (for example, total).
|
||||||
|
*/
|
||||||
public HistogramFacetBuilder valueField(String valueField) {
|
public HistogramFacetBuilder valueField(String valueField) {
|
||||||
this.valueFieldName = valueField;
|
this.valueFieldName = valueField;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interval used to control the bucket "size" where each key value of a hit will fall into.
|
||||||
|
*/
|
||||||
public HistogramFacetBuilder interval(long interval) {
|
public HistogramFacetBuilder interval(long interval) {
|
||||||
this.interval = interval;
|
this.interval = interval;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interval used to control the bucket "size" where each key value of a hit will fall into.
|
||||||
|
*/
|
||||||
|
public HistogramFacetBuilder interval(long interval, TimeUnit unit) {
|
||||||
|
return interval(unit.toMillis(interval));
|
||||||
|
}
|
||||||
|
|
||||||
public HistogramFacetBuilder comparator(HistogramFacet.ComparatorType comparatorType) {
|
public HistogramFacetBuilder comparator(HistogramFacet.ComparatorType comparatorType) {
|
||||||
this.comparatorType = comparatorType;
|
this.comparatorType = comparatorType;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the facet run in global mode (not bounded by the search query) or not (bounded by
|
||||||
|
* the search query). Defaults to <tt>false</tt>.
|
||||||
|
*/
|
||||||
public HistogramFacetBuilder global(boolean global) {
|
public HistogramFacetBuilder global(boolean global) {
|
||||||
this.global = global;
|
this.global = global;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An additional filter used to further filter down the set of documents the facet will run on.
|
||||||
|
*/
|
||||||
public HistogramFacetBuilder filter(XContentFilterBuilder filter) {
|
public HistogramFacetBuilder filter(XContentFilterBuilder filter) {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user