Clean up ShardSearchLocalRequest (#38574)
Added a constructor accepting `StreamInput` as argument, which allowed to make most of the instance members final as well as remove the default constructor. Removed a test only constructor in favour of invoking the existing constructor that takes a `SearchRequest` as first argument. Also removed profile members and related methods as they were all unused.
This commit is contained in:
parent
92201ef563
commit
6443b46184
|
@ -39,7 +39,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shard level search request that gets created and consumed on the local node.
|
* Shard level search request that gets created and consumed on the local node.
|
||||||
* Used by warmers and by api that need to create a search context within their execution.
|
* Used directly by api that need to create a search context within their execution.
|
||||||
*
|
*
|
||||||
* Source structure:
|
* Source structure:
|
||||||
* <pre>
|
* <pre>
|
||||||
|
@ -56,51 +56,41 @@ import java.io.IOException;
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ShardSearchLocalRequest implements ShardSearchRequest {
|
public class ShardSearchLocalRequest implements ShardSearchRequest {
|
||||||
private String clusterAlias;
|
private final String clusterAlias;
|
||||||
private ShardId shardId;
|
private final ShardId shardId;
|
||||||
private int numberOfShards;
|
private final int numberOfShards;
|
||||||
private SearchType searchType;
|
private final SearchType searchType;
|
||||||
private Scroll scroll;
|
private final Scroll scroll;
|
||||||
private String[] types = Strings.EMPTY_ARRAY;
|
private final String[] types;
|
||||||
|
private final float indexBoost;
|
||||||
|
private final Boolean requestCache;
|
||||||
|
private final long nowInMillis;
|
||||||
|
private final boolean allowPartialSearchResults;
|
||||||
|
private final String[] indexRoutings;
|
||||||
|
private final String preference;
|
||||||
|
//these are the only two mutable fields, as they are subject to rewriting
|
||||||
private AliasFilter aliasFilter;
|
private AliasFilter aliasFilter;
|
||||||
private float indexBoost;
|
|
||||||
private SearchSourceBuilder source;
|
private SearchSourceBuilder source;
|
||||||
private Boolean requestCache;
|
|
||||||
private long nowInMillis;
|
|
||||||
private boolean allowPartialSearchResults;
|
|
||||||
private String[] indexRoutings = Strings.EMPTY_ARRAY;
|
|
||||||
private String preference;
|
|
||||||
private boolean profile;
|
|
||||||
|
|
||||||
ShardSearchLocalRequest() {
|
public ShardSearchLocalRequest(SearchRequest searchRequest, ShardId shardId, int numberOfShards, AliasFilter aliasFilter,
|
||||||
}
|
float indexBoost, long nowInMillis, @Nullable String clusterAlias, String[] indexRoutings) {
|
||||||
|
this(shardId, numberOfShards, searchRequest.searchType(), searchRequest.source(), searchRequest.types(),
|
||||||
ShardSearchLocalRequest(SearchRequest searchRequest, ShardId shardId, int numberOfShards, AliasFilter aliasFilter, float indexBoost,
|
searchRequest.requestCache(), aliasFilter, indexBoost, searchRequest.allowPartialSearchResults(), indexRoutings,
|
||||||
long nowInMillis, @Nullable String clusterAlias, String[] indexRoutings) {
|
searchRequest.preference(), searchRequest.scroll(), nowInMillis, clusterAlias);
|
||||||
this(shardId, numberOfShards, searchRequest.searchType(),
|
|
||||||
searchRequest.source(), searchRequest.types(), searchRequest.requestCache(), aliasFilter, indexBoost,
|
|
||||||
searchRequest.allowPartialSearchResults(), indexRoutings, searchRequest.preference());
|
|
||||||
// If allowPartialSearchResults is unset (ie null), the cluster-level default should have been substituted
|
// If allowPartialSearchResults is unset (ie null), the cluster-level default should have been substituted
|
||||||
// at this stage. Any NPEs in the above are therefore an error in request preparation logic.
|
// at this stage. Any NPEs in the above are therefore an error in request preparation logic.
|
||||||
assert searchRequest.allowPartialSearchResults() != null;
|
assert searchRequest.allowPartialSearchResults() != null;
|
||||||
this.scroll = searchRequest.scroll();
|
|
||||||
this.nowInMillis = nowInMillis;
|
|
||||||
this.clusterAlias = clusterAlias;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShardSearchLocalRequest(ShardId shardId, String[] types, long nowInMillis, AliasFilter aliasFilter) {
|
public ShardSearchLocalRequest(ShardId shardId, String[] types, long nowInMillis, AliasFilter aliasFilter) {
|
||||||
this.types = types;
|
this(shardId, -1, null, null, types, null, aliasFilter, 1.0f, false, Strings.EMPTY_ARRAY, null, null, nowInMillis, null);
|
||||||
this.nowInMillis = nowInMillis;
|
|
||||||
this.aliasFilter = aliasFilter;
|
|
||||||
this.shardId = shardId;
|
|
||||||
indexBoost = 1.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ShardSearchLocalRequest(ShardId shardId, int numberOfShards, SearchType searchType, SearchSourceBuilder source, String[] types,
|
private ShardSearchLocalRequest(ShardId shardId, int numberOfShards, SearchType searchType, SearchSourceBuilder source, String[] types,
|
||||||
Boolean requestCache, AliasFilter aliasFilter, float indexBoost, boolean allowPartialSearchResults,
|
Boolean requestCache, AliasFilter aliasFilter, float indexBoost, boolean allowPartialSearchResults,
|
||||||
String[] indexRoutings, String preference) {
|
String[] indexRoutings, String preference, Scroll scroll, long nowInMillis,
|
||||||
|
@Nullable String clusterAlias) {
|
||||||
this.shardId = shardId;
|
this.shardId = shardId;
|
||||||
this.numberOfShards = numberOfShards;
|
this.numberOfShards = numberOfShards;
|
||||||
this.searchType = searchType;
|
this.searchType = searchType;
|
||||||
|
@ -112,6 +102,66 @@ public class ShardSearchLocalRequest implements ShardSearchRequest {
|
||||||
this.allowPartialSearchResults = allowPartialSearchResults;
|
this.allowPartialSearchResults = allowPartialSearchResults;
|
||||||
this.indexRoutings = indexRoutings;
|
this.indexRoutings = indexRoutings;
|
||||||
this.preference = preference;
|
this.preference = preference;
|
||||||
|
this.scroll = scroll;
|
||||||
|
this.nowInMillis = nowInMillis;
|
||||||
|
this.clusterAlias = clusterAlias;
|
||||||
|
}
|
||||||
|
|
||||||
|
ShardSearchLocalRequest(StreamInput in) throws IOException {
|
||||||
|
shardId = ShardId.readShardId(in);
|
||||||
|
searchType = SearchType.fromId(in.readByte());
|
||||||
|
numberOfShards = in.readVInt();
|
||||||
|
scroll = in.readOptionalWriteable(Scroll::new);
|
||||||
|
source = in.readOptionalWriteable(SearchSourceBuilder::new);
|
||||||
|
types = in.readStringArray();
|
||||||
|
aliasFilter = new AliasFilter(in);
|
||||||
|
indexBoost = in.readFloat();
|
||||||
|
nowInMillis = in.readVLong();
|
||||||
|
requestCache = in.readOptionalBoolean();
|
||||||
|
clusterAlias = in.readOptionalString();
|
||||||
|
if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
|
||||||
|
allowPartialSearchResults = in.readBoolean();
|
||||||
|
} else if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
|
||||||
|
allowPartialSearchResults = in.readOptionalBoolean();
|
||||||
|
} else {
|
||||||
|
allowPartialSearchResults = false;
|
||||||
|
}
|
||||||
|
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
|
||||||
|
indexRoutings = in.readStringArray();
|
||||||
|
preference = in.readOptionalString();
|
||||||
|
} else {
|
||||||
|
indexRoutings = Strings.EMPTY_ARRAY;
|
||||||
|
preference = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final void innerWriteTo(StreamOutput out, boolean asKey) throws IOException {
|
||||||
|
shardId.writeTo(out);
|
||||||
|
out.writeByte(searchType.id());
|
||||||
|
if (!asKey) {
|
||||||
|
out.writeVInt(numberOfShards);
|
||||||
|
}
|
||||||
|
out.writeOptionalWriteable(scroll);
|
||||||
|
out.writeOptionalWriteable(source);
|
||||||
|
out.writeStringArray(types);
|
||||||
|
aliasFilter.writeTo(out);
|
||||||
|
out.writeFloat(indexBoost);
|
||||||
|
if (asKey == false) {
|
||||||
|
out.writeVLong(nowInMillis);
|
||||||
|
}
|
||||||
|
out.writeOptionalBoolean(requestCache);
|
||||||
|
out.writeOptionalString(clusterAlias);
|
||||||
|
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
|
||||||
|
out.writeBoolean(allowPartialSearchResults);
|
||||||
|
} else if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
|
||||||
|
out.writeOptionalBoolean(allowPartialSearchResults);
|
||||||
|
}
|
||||||
|
if (asKey == false) {
|
||||||
|
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
|
||||||
|
out.writeStringArray(indexRoutings);
|
||||||
|
out.writeOptionalString(preference);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -174,7 +224,6 @@ public class ShardSearchLocalRequest implements ShardSearchRequest {
|
||||||
return allowPartialSearchResults;
|
return allowPartialSearchResults;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Scroll scroll() {
|
public Scroll scroll() {
|
||||||
return scroll;
|
return scroll;
|
||||||
|
@ -190,75 +239,6 @@ public class ShardSearchLocalRequest implements ShardSearchRequest {
|
||||||
return preference;
|
return preference;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProfile(boolean profile) {
|
|
||||||
this.profile = profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSearchType(SearchType type) {
|
|
||||||
this.searchType = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void innerReadFrom(StreamInput in) throws IOException {
|
|
||||||
shardId = ShardId.readShardId(in);
|
|
||||||
searchType = SearchType.fromId(in.readByte());
|
|
||||||
numberOfShards = in.readVInt();
|
|
||||||
scroll = in.readOptionalWriteable(Scroll::new);
|
|
||||||
source = in.readOptionalWriteable(SearchSourceBuilder::new);
|
|
||||||
types = in.readStringArray();
|
|
||||||
aliasFilter = new AliasFilter(in);
|
|
||||||
indexBoost = in.readFloat();
|
|
||||||
nowInMillis = in.readVLong();
|
|
||||||
requestCache = in.readOptionalBoolean();
|
|
||||||
clusterAlias = in.readOptionalString();
|
|
||||||
if (in.getVersion().onOrAfter(Version.V_7_0_0)) {
|
|
||||||
allowPartialSearchResults = in.readBoolean();
|
|
||||||
} else if (in.getVersion().onOrAfter(Version.V_6_3_0)) {
|
|
||||||
allowPartialSearchResults = in.readOptionalBoolean();
|
|
||||||
}
|
|
||||||
if (in.getVersion().onOrAfter(Version.V_6_4_0)) {
|
|
||||||
indexRoutings = in.readStringArray();
|
|
||||||
preference = in.readOptionalString();
|
|
||||||
} else {
|
|
||||||
indexRoutings = Strings.EMPTY_ARRAY;
|
|
||||||
preference = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void innerWriteTo(StreamOutput out, boolean asKey) throws IOException {
|
|
||||||
shardId.writeTo(out);
|
|
||||||
out.writeByte(searchType.id());
|
|
||||||
if (!asKey) {
|
|
||||||
out.writeVInt(numberOfShards);
|
|
||||||
}
|
|
||||||
out.writeOptionalWriteable(scroll);
|
|
||||||
out.writeOptionalWriteable(source);
|
|
||||||
out.writeStringArray(types);
|
|
||||||
aliasFilter.writeTo(out);
|
|
||||||
out.writeFloat(indexBoost);
|
|
||||||
if (asKey == false) {
|
|
||||||
out.writeVLong(nowInMillis);
|
|
||||||
}
|
|
||||||
out.writeOptionalBoolean(requestCache);
|
|
||||||
out.writeOptionalString(clusterAlias);
|
|
||||||
if (out.getVersion().onOrAfter(Version.V_7_0_0)) {
|
|
||||||
out.writeBoolean(allowPartialSearchResults);
|
|
||||||
} else if (out.getVersion().onOrAfter(Version.V_6_3_0)) {
|
|
||||||
out.writeOptionalBoolean(allowPartialSearchResults);
|
|
||||||
}
|
|
||||||
if (asKey == false) {
|
|
||||||
if (out.getVersion().onOrAfter(Version.V_6_4_0)) {
|
|
||||||
out.writeStringArray(indexRoutings);
|
|
||||||
out.writeOptionalString(preference);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BytesReference cacheKey() throws IOException {
|
public BytesReference cacheKey() throws IOException {
|
||||||
BytesStreamOutput out = new BytesStreamOutput();
|
BytesStreamOutput out = new BytesStreamOutput();
|
||||||
|
|
|
@ -83,17 +83,6 @@ public interface ShardSearchRequest {
|
||||||
*/
|
*/
|
||||||
String preference();
|
String preference();
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets if this shard search needs to be profiled or not
|
|
||||||
* @param profile True if the shard should be profiled
|
|
||||||
*/
|
|
||||||
void setProfile(boolean profile);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if this shard search is being profiled or not
|
|
||||||
*/
|
|
||||||
boolean isProfile();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the cache key for this shard search request, based on its content
|
* Returns the cache key for this shard search request, based on its content
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -48,9 +48,8 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class ShardSearchTransportRequest extends TransportRequest implements ShardSearchRequest, IndicesRequest {
|
public class ShardSearchTransportRequest extends TransportRequest implements ShardSearchRequest, IndicesRequest {
|
||||||
|
|
||||||
private OriginalIndices originalIndices;
|
private final OriginalIndices originalIndices;
|
||||||
|
private final ShardSearchLocalRequest shardSearchLocalRequest;
|
||||||
private ShardSearchLocalRequest shardSearchLocalRequest;
|
|
||||||
|
|
||||||
public ShardSearchTransportRequest(OriginalIndices originalIndices, SearchRequest searchRequest, ShardId shardId, int numberOfShards,
|
public ShardSearchTransportRequest(OriginalIndices originalIndices, SearchRequest searchRequest, ShardId shardId, int numberOfShards,
|
||||||
AliasFilter aliasFilter, float indexBoost, long nowInMillis,
|
AliasFilter aliasFilter, float indexBoost, long nowInMillis,
|
||||||
|
@ -62,8 +61,7 @@ public class ShardSearchTransportRequest extends TransportRequest implements Sha
|
||||||
|
|
||||||
public ShardSearchTransportRequest(StreamInput in) throws IOException {
|
public ShardSearchTransportRequest(StreamInput in) throws IOException {
|
||||||
super(in);
|
super(in);
|
||||||
shardSearchLocalRequest = new ShardSearchLocalRequest();
|
shardSearchLocalRequest = new ShardSearchLocalRequest(in);
|
||||||
shardSearchLocalRequest.innerReadFrom(in);
|
|
||||||
originalIndices = OriginalIndices.readOriginalIndices(in);
|
originalIndices = OriginalIndices.readOriginalIndices(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,10 +72,6 @@ public class ShardSearchTransportRequest extends TransportRequest implements Sha
|
||||||
OriginalIndices.writeOriginalIndices(originalIndices, out);
|
OriginalIndices.writeOriginalIndices(originalIndices, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void searchType(SearchType searchType) {
|
|
||||||
shardSearchLocalRequest.setSearchType(searchType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] indices() {
|
public String[] indices() {
|
||||||
if (originalIndices == null) {
|
if (originalIndices == null) {
|
||||||
|
@ -179,16 +173,6 @@ public class ShardSearchTransportRequest extends TransportRequest implements Sha
|
||||||
return shardSearchLocalRequest.cacheKey();
|
return shardSearchLocalRequest.cacheKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setProfile(boolean profile) {
|
|
||||||
shardSearchLocalRequest.setProfile(profile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isProfile() {
|
|
||||||
return shardSearchLocalRequest.isProfile();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
|
public Task createTask(long id, String type, String action, TaskId parentTaskId, Map<String, String> headers) {
|
||||||
return new SearchTask(id, type, action, getDescription(), parentTaskId, headers);
|
return new SearchTask(id, type, action, getDescription(), parentTaskId, headers);
|
||||||
|
|
|
@ -134,17 +134,7 @@ public class SearchSlowLogTests extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProfile(boolean profile) {
|
public BytesReference cacheKey() {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isProfile() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BytesReference cacheKey() throws IOException {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.elasticsearch.action.search.SearchPhaseExecutionException;
|
||||||
import org.elasticsearch.action.search.SearchRequest;
|
import org.elasticsearch.action.search.SearchRequest;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.action.search.SearchTask;
|
import org.elasticsearch.action.search.SearchTask;
|
||||||
import org.elasticsearch.action.search.SearchType;
|
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
import org.elasticsearch.action.support.IndicesOptions;
|
||||||
import org.elasticsearch.action.support.PlainActionFuture;
|
import org.elasticsearch.action.support.PlainActionFuture;
|
||||||
import org.elasticsearch.action.support.WriteRequest;
|
import org.elasticsearch.action.support.WriteRequest;
|
||||||
|
@ -259,14 +258,14 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
startGun.await();
|
startGun.await();
|
||||||
try {
|
try {
|
||||||
final int rounds = scaledRandomIntBetween(100, 10000);
|
final int rounds = scaledRandomIntBetween(100, 10000);
|
||||||
|
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(true);
|
||||||
for (int i = 0; i < rounds; i++) {
|
for (int i = 0; i < rounds; i++) {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
PlainActionFuture<SearchPhaseResult> result = new PlainActionFuture<>();
|
PlainActionFuture<SearchPhaseResult> result = new PlainActionFuture<>();
|
||||||
service.executeQueryPhase(
|
service.executeQueryPhase(
|
||||||
new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.DEFAULT,
|
new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
new SearchSourceBuilder(), new String[0], false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f,
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f, -1, null, null),
|
||||||
true, null, null),
|
|
||||||
new SearchTask(123L, "", "", "", null, Collections.emptyMap()), result);
|
new SearchTask(123L, "", "", "", null, Collections.emptyMap()), result);
|
||||||
SearchPhaseResult searchPhaseResult = result.get();
|
SearchPhaseResult searchPhaseResult = result.get();
|
||||||
IntArrayList intCursors = new IntArrayList(1);
|
IntArrayList intCursors = new IntArrayList(1);
|
||||||
|
@ -300,16 +299,14 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
final IndicesService indicesService = getInstanceFromNode(IndicesService.class);
|
final IndicesService indicesService = getInstanceFromNode(IndicesService.class);
|
||||||
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
||||||
final IndexShard indexShard = indexService.getShard(0);
|
final IndexShard indexShard = indexService.getShard(0);
|
||||||
|
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(true);
|
||||||
final SearchContext contextWithDefaultTimeout = service.createContext(
|
final SearchContext contextWithDefaultTimeout = service.createContext(
|
||||||
new ShardSearchLocalRequest(
|
new ShardSearchLocalRequest(
|
||||||
|
searchRequest,
|
||||||
indexShard.shardId(),
|
indexShard.shardId(),
|
||||||
1,
|
1,
|
||||||
SearchType.DEFAULT,
|
|
||||||
new SearchSourceBuilder(),
|
|
||||||
new String[0],
|
|
||||||
false,
|
|
||||||
new AliasFilter(null, Strings.EMPTY_ARRAY),
|
new AliasFilter(null, Strings.EMPTY_ARRAY),
|
||||||
1.0f, true, null, null)
|
1.0f, -1, null, null)
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
// the search context should inherit the default timeout
|
// the search context should inherit the default timeout
|
||||||
|
@ -320,16 +317,14 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
final long seconds = randomIntBetween(6, 10);
|
final long seconds = randomIntBetween(6, 10);
|
||||||
|
searchRequest.source(new SearchSourceBuilder().timeout(TimeValue.timeValueSeconds(seconds)));
|
||||||
final SearchContext context = service.createContext(
|
final SearchContext context = service.createContext(
|
||||||
new ShardSearchLocalRequest(
|
new ShardSearchLocalRequest(
|
||||||
|
searchRequest,
|
||||||
indexShard.shardId(),
|
indexShard.shardId(),
|
||||||
1,
|
1,
|
||||||
SearchType.DEFAULT,
|
|
||||||
new SearchSourceBuilder().timeout(TimeValue.timeValueSeconds(seconds)),
|
|
||||||
new String[0],
|
|
||||||
false,
|
|
||||||
new AliasFilter(null, Strings.EMPTY_ARRAY),
|
new AliasFilter(null, Strings.EMPTY_ARRAY),
|
||||||
1.0f, true, null, null)
|
1.0f, -1, null, null)
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
// the search context should inherit the query timeout
|
// the search context should inherit the query timeout
|
||||||
|
@ -351,19 +346,20 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
||||||
final IndexShard indexShard = indexService.getShard(0);
|
final IndexShard indexShard = indexService.getShard(0);
|
||||||
|
|
||||||
|
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(true);
|
||||||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||||
|
searchRequest.source(searchSourceBuilder);
|
||||||
// adding the maximum allowed number of docvalue_fields to retrieve
|
// adding the maximum allowed number of docvalue_fields to retrieve
|
||||||
for (int i = 0; i < indexService.getIndexSettings().getMaxDocvalueFields(); i++) {
|
for (int i = 0; i < indexService.getIndexSettings().getMaxDocvalueFields(); i++) {
|
||||||
searchSourceBuilder.docValueField("field" + i);
|
searchSourceBuilder.docValueField("field" + i);
|
||||||
}
|
}
|
||||||
try (SearchContext context = service.createContext(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.DEFAULT,
|
try (SearchContext context = service.createContext(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
searchSourceBuilder, new String[0], false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f, true, null, null))) {
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f, -1, null, null))) {
|
||||||
assertNotNull(context);
|
assertNotNull(context);
|
||||||
searchSourceBuilder.docValueField("one_field_too_much");
|
searchSourceBuilder.docValueField("one_field_too_much");
|
||||||
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class,
|
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class,
|
||||||
() -> service.createContext(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.DEFAULT,
|
() -> service.createContext(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
searchSourceBuilder, new String[0], false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f,
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f, -1, null, null)));
|
||||||
true, null, null)));
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Trying to retrieve too many docvalue_fields. Must be less than or equal to: [100] but was [101]. "
|
"Trying to retrieve too many docvalue_fields. Must be less than or equal to: [100] but was [101]. "
|
||||||
+ "This limit can be set by changing the [index.max_docvalue_fields_search] index level setting.",
|
+ "This limit can be set by changing the [index.max_docvalue_fields_search] index level setting.",
|
||||||
|
@ -381,22 +377,23 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
||||||
final IndexShard indexShard = indexService.getShard(0);
|
final IndexShard indexShard = indexService.getShard(0);
|
||||||
|
|
||||||
|
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(true);
|
||||||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||||
|
searchRequest.source(searchSourceBuilder);
|
||||||
// adding the maximum allowed number of script_fields to retrieve
|
// adding the maximum allowed number of script_fields to retrieve
|
||||||
int maxScriptFields = indexService.getIndexSettings().getMaxScriptFields();
|
int maxScriptFields = indexService.getIndexSettings().getMaxScriptFields();
|
||||||
for (int i = 0; i < maxScriptFields; i++) {
|
for (int i = 0; i < maxScriptFields; i++) {
|
||||||
searchSourceBuilder.scriptField("field" + i,
|
searchSourceBuilder.scriptField("field" + i,
|
||||||
new Script(ScriptType.INLINE, MockScriptEngine.NAME, CustomScriptPlugin.DUMMY_SCRIPT, Collections.emptyMap()));
|
new Script(ScriptType.INLINE, MockScriptEngine.NAME, CustomScriptPlugin.DUMMY_SCRIPT, Collections.emptyMap()));
|
||||||
}
|
}
|
||||||
try (SearchContext context = service.createContext(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.DEFAULT,
|
try (SearchContext context = service.createContext(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
searchSourceBuilder, new String[0], false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f, true, null, null))) {
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f, -1, null, null))) {
|
||||||
assertNotNull(context);
|
assertNotNull(context);
|
||||||
searchSourceBuilder.scriptField("anotherScriptField",
|
searchSourceBuilder.scriptField("anotherScriptField",
|
||||||
new Script(ScriptType.INLINE, MockScriptEngine.NAME, CustomScriptPlugin.DUMMY_SCRIPT, Collections.emptyMap()));
|
new Script(ScriptType.INLINE, MockScriptEngine.NAME, CustomScriptPlugin.DUMMY_SCRIPT, Collections.emptyMap()));
|
||||||
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class,
|
IllegalArgumentException ex = expectThrows(IllegalArgumentException.class,
|
||||||
() -> service.createContext(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.DEFAULT,
|
() -> service.createContext(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
searchSourceBuilder, new String[0], false, new AliasFilter(null, Strings.EMPTY_ARRAY),
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f, -1, null, null)));
|
||||||
1.0f, true, null, null)));
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"Trying to retrieve too many script_fields. Must be less than or equal to: [" + maxScriptFields + "] but was ["
|
"Trying to retrieve too many script_fields. Must be less than or equal to: [" + maxScriptFields + "] but was ["
|
||||||
+ (maxScriptFields + 1)
|
+ (maxScriptFields + 1)
|
||||||
|
@ -412,12 +409,14 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
||||||
final IndexShard indexShard = indexService.getShard(0);
|
final IndexShard indexShard = indexService.getShard(0);
|
||||||
|
|
||||||
|
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(true);
|
||||||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||||
|
searchRequest.source(searchSourceBuilder);
|
||||||
searchSourceBuilder.scriptField("field" + 0,
|
searchSourceBuilder.scriptField("field" + 0,
|
||||||
new Script(ScriptType.INLINE, MockScriptEngine.NAME, CustomScriptPlugin.DUMMY_SCRIPT, Collections.emptyMap()));
|
new Script(ScriptType.INLINE, MockScriptEngine.NAME, CustomScriptPlugin.DUMMY_SCRIPT, Collections.emptyMap()));
|
||||||
searchSourceBuilder.size(0);
|
searchSourceBuilder.size(0);
|
||||||
try (SearchContext context = service.createContext(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.DEFAULT,
|
try (SearchContext context = service.createContext(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
searchSourceBuilder, new String[0], false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f, true, null, null))) {
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1.0f, -1, null, null))) {
|
||||||
assertEquals(0, context.scriptFields().fields().size());
|
assertEquals(0, context.scriptFields().fields().size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,13 +514,12 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ShardScrollRequestTest extends ShardSearchLocalRequest {
|
private static class ShardScrollRequestTest extends ShardSearchLocalRequest {
|
||||||
private Scroll scroll;
|
private Scroll scroll;
|
||||||
|
|
||||||
ShardScrollRequestTest(ShardId shardId) {
|
ShardScrollRequestTest(ShardId shardId) {
|
||||||
super(shardId, 1, SearchType.DEFAULT, new SearchSourceBuilder(),
|
super(new SearchRequest().allowPartialSearchResults(true),
|
||||||
new String[0], false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, true, null, null);
|
shardId, 1, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null);
|
||||||
|
|
||||||
this.scroll = new Scroll(TimeValue.timeValueMinutes(1));
|
this.scroll = new Scroll(TimeValue.timeValueMinutes(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,30 +535,30 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
final IndicesService indicesService = getInstanceFromNode(IndicesService.class);
|
final IndicesService indicesService = getInstanceFromNode(IndicesService.class);
|
||||||
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
final IndexService indexService = indicesService.indexServiceSafe(resolveIndex("index"));
|
||||||
final IndexShard indexShard = indexService.getShard(0);
|
final IndexShard indexShard = indexService.getShard(0);
|
||||||
final boolean allowPartialSearchResults = true;
|
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(true);
|
||||||
assertTrue(service.canMatch(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.QUERY_THEN_FETCH, null,
|
assertTrue(service.canMatch(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
Strings.EMPTY_ARRAY, false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, allowPartialSearchResults, null, null)));
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
|
|
||||||
assertTrue(service.canMatch(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.QUERY_THEN_FETCH,
|
searchRequest.source(new SearchSourceBuilder());
|
||||||
new SearchSourceBuilder(), Strings.EMPTY_ARRAY, false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f,
|
assertTrue(service.canMatch(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
allowPartialSearchResults, null, null)));
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
|
|
||||||
assertTrue(service.canMatch(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.QUERY_THEN_FETCH,
|
searchRequest.source(new SearchSourceBuilder().query(new MatchAllQueryBuilder()));
|
||||||
new SearchSourceBuilder().query(new MatchAllQueryBuilder()), Strings.EMPTY_ARRAY, false,
|
assertTrue(service.canMatch(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, allowPartialSearchResults, null, null)));
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
|
|
||||||
assertTrue(service.canMatch(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.QUERY_THEN_FETCH,
|
searchRequest.source(new SearchSourceBuilder().query(new MatchNoneQueryBuilder())
|
||||||
new SearchSourceBuilder().query(new MatchNoneQueryBuilder())
|
.aggregation(new TermsAggregationBuilder("test", ValueType.STRING).minDocCount(0)));
|
||||||
.aggregation(new TermsAggregationBuilder("test", ValueType.STRING).minDocCount(0)), Strings.EMPTY_ARRAY, false,
|
assertTrue(service.canMatch(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, allowPartialSearchResults, null, null)));
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
assertTrue(service.canMatch(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.QUERY_THEN_FETCH,
|
searchRequest.source(new SearchSourceBuilder().query(new MatchNoneQueryBuilder())
|
||||||
new SearchSourceBuilder().query(new MatchNoneQueryBuilder())
|
.aggregation(new GlobalAggregationBuilder("test")));
|
||||||
.aggregation(new GlobalAggregationBuilder("test")), Strings.EMPTY_ARRAY, false,
|
assertTrue(service.canMatch(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, allowPartialSearchResults, null, null)));
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
|
|
||||||
assertFalse(service.canMatch(new ShardSearchLocalRequest(indexShard.shardId(), 1, SearchType.QUERY_THEN_FETCH,
|
searchRequest.source(new SearchSourceBuilder().query(new MatchNoneQueryBuilder()));
|
||||||
new SearchSourceBuilder().query(new MatchNoneQueryBuilder()), Strings.EMPTY_ARRAY, false,
|
assertFalse(service.canMatch(new ShardSearchLocalRequest(searchRequest, indexShard.shardId(), 1,
|
||||||
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, allowPartialSearchResults, null, null)));
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCanRewriteToMatchNone() {
|
public void testCanRewriteToMatchNone() {
|
||||||
|
@ -607,8 +605,9 @@ public class SearchServiceTests extends ESSingleNodeTestCase {
|
||||||
assertEquals("can not update private setting [index.search.throttled]; this setting is managed by Elasticsearch",
|
assertEquals("can not update private setting [index.search.throttled]; this setting is managed by Elasticsearch",
|
||||||
iae.getMessage());
|
iae.getMessage());
|
||||||
assertFalse(service.getIndicesService().indexServiceSafe(index).getIndexSettings().isSearchThrottled());
|
assertFalse(service.getIndicesService().indexServiceSafe(index).getIndexSettings().isSearchThrottled());
|
||||||
ShardSearchLocalRequest req = new ShardSearchLocalRequest(new ShardId(index, 0), 1, SearchType.QUERY_THEN_FETCH, null,
|
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(false);
|
||||||
Strings.EMPTY_ARRAY, false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, false, null, null);
|
ShardSearchLocalRequest req = new ShardSearchLocalRequest(searchRequest, new ShardId(index, 0), 1,
|
||||||
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null);
|
||||||
Thread currentThread = Thread.currentThread();
|
Thread currentThread = Thread.currentThread();
|
||||||
// we still make sure can match is executed on the network thread
|
// we still make sure can match is executed on the network thread
|
||||||
service.canMatch(req, ActionListener.wrap(r -> assertSame(Thread.currentThread(), currentThread), e -> fail("unexpected")));
|
service.canMatch(req, ActionListener.wrap(r -> assertSame(Thread.currentThread(), currentThread), e -> fail("unexpected")));
|
||||||
|
|
|
@ -64,7 +64,6 @@ public class ShardSearchTransportRequestTests extends AbstractSearchTestCase {
|
||||||
assertArrayEquals(deserializedRequest.indices(), shardSearchTransportRequest.indices());
|
assertArrayEquals(deserializedRequest.indices(), shardSearchTransportRequest.indices());
|
||||||
assertArrayEquals(deserializedRequest.types(), shardSearchTransportRequest.types());
|
assertArrayEquals(deserializedRequest.types(), shardSearchTransportRequest.types());
|
||||||
assertEquals(deserializedRequest.indicesOptions(), shardSearchTransportRequest.indicesOptions());
|
assertEquals(deserializedRequest.indicesOptions(), shardSearchTransportRequest.indicesOptions());
|
||||||
assertEquals(deserializedRequest.isProfile(), shardSearchTransportRequest.isProfile());
|
|
||||||
assertEquals(deserializedRequest.nowInMillis(), shardSearchTransportRequest.nowInMillis());
|
assertEquals(deserializedRequest.nowInMillis(), shardSearchTransportRequest.nowInMillis());
|
||||||
assertEquals(deserializedRequest.source(), shardSearchTransportRequest.source());
|
assertEquals(deserializedRequest.source(), shardSearchTransportRequest.source());
|
||||||
assertEquals(deserializedRequest.searchType(), shardSearchTransportRequest.searchType());
|
assertEquals(deserializedRequest.searchType(), shardSearchTransportRequest.searchType());
|
||||||
|
|
|
@ -183,17 +183,7 @@ public class SliceBuilderTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setProfile(boolean profile) {
|
public BytesReference cacheKey() {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isProfile() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BytesReference cacheKey() throws IOException {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.elasticsearch.action.ActionListener;
|
||||||
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
||||||
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
|
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
|
||||||
import org.elasticsearch.action.delete.DeleteResponse;
|
import org.elasticsearch.action.delete.DeleteResponse;
|
||||||
|
import org.elasticsearch.action.search.SearchRequest;
|
||||||
import org.elasticsearch.action.search.SearchResponse;
|
import org.elasticsearch.action.search.SearchResponse;
|
||||||
import org.elasticsearch.action.search.SearchType;
|
import org.elasticsearch.action.search.SearchType;
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
import org.elasticsearch.action.support.IndicesOptions;
|
||||||
|
@ -248,21 +249,21 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
|
||||||
IndexShard shard = indexService.getShard(0);
|
IndexShard shard = indexService.getShard(0);
|
||||||
assertFalse(indexService.getIndexSettings().isSearchThrottled());
|
assertFalse(indexService.getIndexSettings().isSearchThrottled());
|
||||||
SearchService searchService = getInstanceFromNode(SearchService.class);
|
SearchService searchService = getInstanceFromNode(SearchService.class);
|
||||||
assertTrue(searchService.canMatch(new ShardSearchLocalRequest(shard.shardId(), 1, SearchType.QUERY_THEN_FETCH, null,
|
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(true);
|
||||||
Strings.EMPTY_ARRAY, false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, true, null, null)));
|
assertTrue(searchService.canMatch(new ShardSearchLocalRequest(searchRequest, shard.shardId(), 1,
|
||||||
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
|
|
||||||
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
||||||
|
searchRequest.source(sourceBuilder);
|
||||||
sourceBuilder.query(QueryBuilders.rangeQuery("field").gte("2010-01-03||+2d").lte("2010-01-04||+2d/d"));
|
sourceBuilder.query(QueryBuilders.rangeQuery("field").gte("2010-01-03||+2d").lte("2010-01-04||+2d/d"));
|
||||||
assertTrue(searchService.canMatch(new ShardSearchLocalRequest(shard.shardId(), 1, SearchType.QUERY_THEN_FETCH, sourceBuilder,
|
assertTrue(searchService.canMatch(new ShardSearchLocalRequest(searchRequest, shard.shardId(), 1,
|
||||||
Strings.EMPTY_ARRAY, false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, true, null, null)));
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
|
|
||||||
sourceBuilder = new SearchSourceBuilder();
|
|
||||||
sourceBuilder.query(QueryBuilders.rangeQuery("field").gt("2010-01-06T02:00").lt("2010-01-07T02:00"));
|
sourceBuilder.query(QueryBuilders.rangeQuery("field").gt("2010-01-06T02:00").lt("2010-01-07T02:00"));
|
||||||
assertFalse(searchService.canMatch(new ShardSearchLocalRequest(shard.shardId(), 1, SearchType.QUERY_THEN_FETCH, sourceBuilder,
|
assertFalse(searchService.canMatch(new ShardSearchLocalRequest(searchRequest, shard.shardId(), 1,
|
||||||
Strings.EMPTY_ARRAY, false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, true, null, null)));
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XPackClient xPackClient = new XPackClient(client());
|
XPackClient xPackClient = new XPackClient(client());
|
||||||
assertAcked(xPackClient.freeze(new TransportFreezeIndexAction.FreezeRequest("index")));
|
assertAcked(xPackClient.freeze(new TransportFreezeIndexAction.FreezeRequest("index")));
|
||||||
{
|
{
|
||||||
|
@ -273,18 +274,19 @@ public class FrozenIndexTests extends ESSingleNodeTestCase {
|
||||||
IndexShard shard = indexService.getShard(0);
|
IndexShard shard = indexService.getShard(0);
|
||||||
assertTrue(indexService.getIndexSettings().isSearchThrottled());
|
assertTrue(indexService.getIndexSettings().isSearchThrottled());
|
||||||
SearchService searchService = getInstanceFromNode(SearchService.class);
|
SearchService searchService = getInstanceFromNode(SearchService.class);
|
||||||
assertTrue(searchService.canMatch(new ShardSearchLocalRequest(shard.shardId(), 1, SearchType.QUERY_THEN_FETCH, null,
|
SearchRequest searchRequest = new SearchRequest().allowPartialSearchResults(true);
|
||||||
Strings.EMPTY_ARRAY, false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, true, null, null)));
|
assertTrue(searchService.canMatch(new ShardSearchLocalRequest(searchRequest, shard.shardId(), 1,
|
||||||
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
|
|
||||||
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
||||||
sourceBuilder.query(QueryBuilders.rangeQuery("field").gte("2010-01-03||+2d").lte("2010-01-04||+2d/d"));
|
sourceBuilder.query(QueryBuilders.rangeQuery("field").gte("2010-01-03||+2d").lte("2010-01-04||+2d/d"));
|
||||||
assertTrue(searchService.canMatch(new ShardSearchLocalRequest(shard.shardId(), 1, SearchType.QUERY_THEN_FETCH, sourceBuilder,
|
searchRequest.source(sourceBuilder);
|
||||||
Strings.EMPTY_ARRAY, false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, true, null, null)));
|
assertTrue(searchService.canMatch(new ShardSearchLocalRequest(searchRequest, shard.shardId(), 1,
|
||||||
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
|
|
||||||
sourceBuilder = new SearchSourceBuilder();
|
|
||||||
sourceBuilder.query(QueryBuilders.rangeQuery("field").gt("2010-01-06T02:00").lt("2010-01-07T02:00"));
|
sourceBuilder.query(QueryBuilders.rangeQuery("field").gt("2010-01-06T02:00").lt("2010-01-07T02:00"));
|
||||||
assertFalse(searchService.canMatch(new ShardSearchLocalRequest(shard.shardId(), 1, SearchType.QUERY_THEN_FETCH, sourceBuilder,
|
assertFalse(searchService.canMatch(new ShardSearchLocalRequest(searchRequest, shard.shardId(), 1,
|
||||||
Strings.EMPTY_ARRAY, false, new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, true, null, null)));
|
new AliasFilter(null, Strings.EMPTY_ARRAY), 1f, -1, null, null)));
|
||||||
|
|
||||||
IndicesStatsResponse response = client().admin().indices().prepareStats("index").clear().setRefresh(true).get();
|
IndicesStatsResponse response = client().admin().indices().prepareStats("index").clear().setRefresh(true).get();
|
||||||
assertEquals(0, response.getTotal().refresh.getTotal()); // never opened a reader
|
assertEquals(0, response.getTotal().refresh.getTotal()); // never opened a reader
|
||||||
|
|
Loading…
Reference in New Issue