/** * Build a ScoreSortBuilder default to descending sort order. */ public ScoreSortBuilder() { // order defaults to desc when sorting on the _score order(SortOrder.DESC); }
}else{ nativeSearchQueryBuilder.withSort(SortBuilders.scoreSort().order(SortOrder.DESC)); nativeSearchQueryBuilder.withSort(SortBuilders.scoreSort().order(SortOrder.DESC)); nativeSearchQueryBuilder.withSort(SortBuilders.scoreSort().order(SortOrder.DESC)); NativeSearchQuery searchQuery = nativeSearchQueryBuilder.build(); LOGGER.info("DSL:{}", searchQuery.getQuery().toString());
/** * Read from a stream. */ public ScoreSortBuilder(StreamInput in) throws IOException { order(SortOrder.readFromStream(in)); }
/** * Adds a sort against the given field name and the sort ordering. * * @param name * The name of the field * @param order * The sort ordering */ public TopHitsAggregationBuilder sort(String name, SortOrder order) { if (name == null) { throw new IllegalArgumentException("sort [name] must not be null: [" + name + "]"); } if (order == null) { throw new IllegalArgumentException("sort [order] must not be null: [" + name + "]"); } if (name.equals(ScoreSortBuilder.NAME)) { sort(SortBuilders.scoreSort().order(order)); } sort(SortBuilders.fieldSort(name).order(order)); return this; }
/** * Adds a sort against the given field name and the sort ordering. * * @param name * The name of the field * @param order * The sort ordering */ public SearchSourceBuilder sort(String name, SortOrder order) { if (name.equals(ScoreSortBuilder.NAME)) { return sort(SortBuilders.scoreSort().order(order)); } return sort(SortBuilders.fieldSort(name).order(order)); }
/** * Build a ScoreSortBuilder default to descending sort order. */ public ScoreSortBuilder() { // order defaults to desc when sorting on the _score order(SortOrder.DESC); }
/** * Build a ScoreSortBuilder default to descending sort order. */ public ScoreSortBuilder() { // order defaults to desc when sorting on the _score order(SortOrder.DESC); }
/** * Build a ScoreSortBuilder default to descending sort order. */ public ScoreSortBuilder() { // order defaults to desc when sorting on the _score order(SortOrder.DESC); }
/** * Read from a stream. */ public ScoreSortBuilder(StreamInput in) throws IOException { order(SortOrder.readFromStream(in)); }
/** * Read from a stream. */ public ScoreSortBuilder(StreamInput in) throws IOException { order(SortOrder.readFromStream(in)); }
/** * Read from a stream. */ public ScoreSortBuilder(StreamInput in) throws IOException { order(SortOrder.readFromStream(in)); }
/** * Adds a sort against the given field name and the sort ordering. * * @param name * The name of the field * @param order * The sort ordering */ public TopHitsAggregationBuilder sort(String name, SortOrder order) { if (name == null) { throw new IllegalArgumentException("sort [name] must not be null: [" + name + "]"); } if (order == null) { throw new IllegalArgumentException("sort [order] must not be null: [" + name + "]"); } if (name.equals(ScoreSortBuilder.NAME)) { sort(SortBuilders.scoreSort().order(order)); } sort(SortBuilders.fieldSort(name).order(order)); return this; }
/** * Adds a sort against the given field name and the sort ordering. * * @param name * The name of the field * @param order * The sort ordering */ public TopHitsAggregationBuilder sort(String name, SortOrder order) { if (name == null) { throw new IllegalArgumentException("sort [name] must not be null: [" + name + "]"); } if (order == null) { throw new IllegalArgumentException("sort [order] must not be null: [" + name + "]"); } if (name.equals(ScoreSortBuilder.NAME)) { sort(SortBuilders.scoreSort().order(order)); } sort(SortBuilders.fieldSort(name).order(order)); return this; }
/** * Adds a sort against the given field name and the sort ordering. * * @param name * The name of the field * @param order * The sort ordering */ public TopHitsAggregationBuilder sort(String name, SortOrder order) { if (name == null) { throw new IllegalArgumentException("sort [name] must not be null: [" + name + "]"); } if (order == null) { throw new IllegalArgumentException("sort [order] must not be null: [" + name + "]"); } if (name.equals(ScoreSortBuilder.NAME)) { sort(SortBuilders.scoreSort().order(order)); } sort(SortBuilders.fieldSort(name).order(order)); return this; }
/** * Adds an order by clause for the given field in ascending order. * <p> * Copies the behavior from {@link SearchRequestBuilder#addSort(String, SortOrder)} to handle order by _score. * * @param field the field to order by * @return the query itself for fluent method calls */ public Query<E> orderByAsc(String field) { if (field.equals(ScoreSortBuilder.NAME)) { return orderBy(SortBuilders.scoreSort().order(SortOrder.ASC)); } return orderBy(SortBuilders.fieldSort(field).order(SortOrder.ASC)); }
/** * Adds a sort against the given field name and the sort ordering. * * @param name * The name of the field * @param order * The sort ordering */ public SearchSourceBuilder sort(String name, SortOrder order) { if (name.equals(ScoreSortBuilder.NAME)) { return sort(SortBuilders.scoreSort().order(order)); } return sort(SortBuilders.fieldSort(name).order(order)); }
/** * Adds a sort against the given field name and the sort ordering. * * @param name * The name of the field * @param order * The sort ordering */ public SearchSourceBuilder sort(String name, SortOrder order) { if (name.equals(ScoreSortBuilder.NAME)) { return sort(SortBuilders.scoreSort().order(order)); } return sort(SortBuilders.fieldSort(name).order(order)); }
/** * Adds a sort against the given field name and the sort ordering. * * @param name * The name of the field * @param order * The sort ordering */ public SearchSourceBuilder sort(String name, SortOrder order) { if (name.equals(ScoreSortBuilder.NAME)) { return sort(SortBuilders.scoreSort().order(order)); } return sort(SortBuilders.fieldSort(name).order(order)); }
/** * Adds an order by clause for the given field in descending order. * <p> * Copies the behavior from {@link SearchRequestBuilder#addSort(String, SortOrder)} to handle order by _score. * * @param field the field to order by * @return the query itself for fluent method calls */ public Query<E> orderByDesc(String field) { if (field.equals(ScoreSortBuilder.NAME)) { return orderBy(SortBuilders.scoreSort().order(SortOrder.DESC)); } return orderBy(SortBuilders.fieldSort(field).order(SortOrder.DESC)); }
break; case 2: builder.sort(SortBuilders.scoreSort().order(randomFrom(SortOrder.values()))); break; case 3: