Package org.elasticsearch.search.slice
Class SliceBuilder
java.lang.Object
org.elasticsearch.search.slice.SliceBuilder
- All Implemented Interfaces:
Writeable
,ToXContent
,ToXContentObject
A slice builder allowing to split a scroll in multiple partitions.
If the provided field is the "_uid" it uses a
TermsSliceQuery
to do the slicing. The slicing is done at the shard level first and then each shard is split into multiple slices.
For instance if the number of shards is equal to 2 and the user requested 4 slices
then the slices 0 and 2 are assigned to the first shard and the slices 1 and 3 are assigned to the second shard.
This way the total number of bitsets that we need to build on each shard is bounded by the number of slices
(instead of numShards*numSlices
).
Otherwise the provided field must be a numeric and doc_values must be enabled. In that case a
DocValuesSliceQuery
is used to filter the results.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final ParseField
static final ParseField
static final ParseField
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorDescriptionSliceBuilder
(int id, int max) Build a slice using the default strategy.SliceBuilder
(String field, int id, int max) Build a slice on a particular field. -
Method Summary
Modifier and TypeMethodDescriptionboolean
static SliceBuilder
fromXContent
(XContentParser parser) getField()
The name of the field to slice against.int
getId()
The id of the slice.int
getMax()
The maximum number of slices.int
hashCode()
org.apache.lucene.search.Query
toFilter
(ShardSearchRequest request, SearchExecutionContext context) Converts this QueryBuilder to a luceneQuery
.toString()
toXContent
(XContentBuilder builder, ToXContent.Params params) void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
FIELD_FIELD
-
ID_FIELD
-
MAX_FIELD
-
-
Constructor Details
-
SliceBuilder
public SliceBuilder(int id, int max) Build a slice using the default strategy.- Parameters:
id
- The id of the slicemax
- The maximum number of slices
-
SliceBuilder
Build a slice on a particular field.- Parameters:
field
- The name of the field to slice againstid
- The id of the slicemax
- The maximum number of slices
-
SliceBuilder
- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
getField
The name of the field to slice against. If null, a default slicing strategy is used. -
getId
public int getId()The id of the slice. -
getMax
public int getMax()The maximum number of slices. -
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContent
in interfaceToXContent
- Throws:
IOException
-
fromXContent
- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toFilter
public org.apache.lucene.search.Query toFilter(ShardSearchRequest request, SearchExecutionContext context) Converts this QueryBuilder to a luceneQuery
.- Parameters:
context
- Additional information needed to build the query
-
toString
-