org.elasticsearch.search.facet.Facet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch Show documentation
Show all versions of elasticsearch Show documentation
Elasticsearch subproject :server
/*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search licenses this
* file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.elasticsearch.search.facet;
import org.elasticsearch.ElasticSearchIllegalArgumentException;
import org.elasticsearch.search.facet.filter.FilterFacet;
import org.elasticsearch.search.facet.geodistance.GeoDistanceFacet;
import org.elasticsearch.search.facet.histogram.HistogramFacet;
import org.elasticsearch.search.facet.query.QueryFacet;
import org.elasticsearch.search.facet.range.RangeFacet;
import org.elasticsearch.search.facet.statistical.StatisticalFacet;
import org.elasticsearch.search.facet.terms.TermsFacet;
/**
* A search facet.
*
* @author kimchy (shay.banon)
*/
public interface Facet {
/**
* The type of the facet.
*/
enum Type {
/**
* Terms facet type, matching {@link TermsFacet}.
*/
TERMS(0, TermsFacet.class),
/**
* Query facet type, matching {@link QueryFacet}.
*/
QUERY(1, QueryFacet.class),
/**
* Statistical facet type, matching {@link StatisticalFacet}.
*/
STATISTICAL(2, StatisticalFacet.class),
/**
* Histogram facet type, matching {@link HistogramFacet}.
*/
HISTOGRAM(3, HistogramFacet.class),
/**
* Geo Distance facet type, matching {@link GeoDistanceFacet}.
*/
GEO_DISTANCE(4, GeoDistanceFacet.class),
/**
* Geo Distance facet type, matching {@link RangeFacet}.
*/
RANGE(5, RangeFacet.class),
/**
* Filter facet type, matching {@link FilterFacet}.
*/
FILTER(6, FilterFacet.class);
private int id;
private Class type;
Type(int id, Class type) {
this.id = id;
this.type = type;
}
public int id() {
return id;
}
/**
* The facet class type.
*/
public Class type() {
return this.type;
}
/**
* The facet class type.
*/
public Class getType() {
return type();
}
public static Type fromId(int id) {
if (id == 0) {
return TERMS;
} else if (id == 1) {
return QUERY;
} else if (id == 2) {
return STATISTICAL;
} else if (id == 3) {
return HISTOGRAM;
} else if (id == 4) {
return GEO_DISTANCE;
} else if (id == 5) {
return RANGE;
} else {
throw new ElasticSearchIllegalArgumentException("No match for id [" + id + "]");
}
}
}
/**
* The "logical" name of the search facet.
*/
String name();
/**
* The "logical" name of the search facet.
*/
String getName();
/**
* The type of the facet.
*/
Type type();
/**
* The type of the facet.
*/
Type getType();
}