javadoc
This commit is contained in:
parent
6611e7db44
commit
f10699d5b8
|
@ -24,6 +24,8 @@ import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A sort builder to sort based on a document field.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class FieldSortBuilder extends SortBuilder {
|
||||
|
@ -32,10 +34,18 @@ public class FieldSortBuilder extends SortBuilder {
|
|||
|
||||
private SortOrder order;
|
||||
|
||||
/**
|
||||
* Constructs a new sort based on a document field.
|
||||
*
|
||||
* @param fieldName The field name.
|
||||
*/
|
||||
public FieldSortBuilder(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
||||
/**
|
||||
* The order of sorting. Defaults to {@link SortOrder#ASC}.
|
||||
*/
|
||||
public FieldSortBuilder order(SortOrder order) {
|
||||
this.order = order;
|
||||
return this;
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A geo distance based sorting on a geo point like field.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class GeoDistanceSortBuilder extends SortBuilder {
|
||||
|
@ -40,6 +42,11 @@ public class GeoDistanceSortBuilder extends SortBuilder {
|
|||
private DistanceUnit unit;
|
||||
private SortOrder order;
|
||||
|
||||
/**
|
||||
* Constructs a new distance based sort on a geo point like field.
|
||||
*
|
||||
* @param fieldName The geo point like field name.
|
||||
*/
|
||||
public GeoDistanceSortBuilder(String fieldName) {
|
||||
this.fieldName = fieldName;
|
||||
}
|
||||
|
@ -80,6 +87,9 @@ public class GeoDistanceSortBuilder extends SortBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The order of sorting. Defaults to {@link SortOrder#ASC}.
|
||||
*/
|
||||
public GeoDistanceSortBuilder order(SortOrder order) {
|
||||
this.order = order;
|
||||
return this;
|
||||
|
|
|
@ -24,12 +24,17 @@ import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
|||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A sort builder allowing to sort by score.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class ScoreSortBuilder extends SortBuilder {
|
||||
|
||||
private SortOrder order;
|
||||
|
||||
/**
|
||||
* The order of sort scoring. By default, its {@link SortOrder#DESC}.
|
||||
*/
|
||||
public ScoreSortBuilder order(SortOrder order) {
|
||||
this.order = order;
|
||||
return this;
|
||||
|
|
|
@ -20,22 +20,43 @@
|
|||
package org.elasticsearch.search.sort;
|
||||
|
||||
/**
|
||||
* A set of static factory methods for {@link SortBuilder}s.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class SortBuilders {
|
||||
|
||||
/**
|
||||
* Constructs a new score sort.
|
||||
*/
|
||||
public static ScoreSortBuilder scoreSort() {
|
||||
return new ScoreSortBuilder();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new field based sort.
|
||||
*
|
||||
* @param field The field name.
|
||||
*/
|
||||
public static FieldSortBuilder fieldSort(String field) {
|
||||
return new FieldSortBuilder(field);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new script based sort.
|
||||
*
|
||||
* @param script The script to use.
|
||||
* @param type The type, can either be "string" or "number".
|
||||
*/
|
||||
public static ScriptSortBuilder scriptSort(String script, String type) {
|
||||
return new ScriptSortBuilder(script, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* A geo distance based sort.
|
||||
*
|
||||
* @param fieldName The geo point like field name.
|
||||
*/
|
||||
public static GeoDistanceSortBuilder geoDistanceSort(String fieldName) {
|
||||
return new GeoDistanceSortBuilder(fieldName);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,17 @@
|
|||
package org.elasticsearch.search.sort;
|
||||
|
||||
/**
|
||||
* A sorting order.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public enum SortOrder {
|
||||
/**
|
||||
* Ascending order.
|
||||
*/
|
||||
ASC,
|
||||
/**
|
||||
* Descending order.
|
||||
*/
|
||||
DESC
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue