Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/94708.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 94708
summary: Return 200 when closing empty PIT or scroll
area: Search
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.action.admin.indices.stats.CommonStats;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.routing.ShardRouting;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -21,6 +22,7 @@
import org.elasticsearch.index.query.RangeQueryBuilder;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.indices.IndicesService;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.SearchContextMissingException;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchService;
Expand Down Expand Up @@ -277,6 +279,15 @@ public void testIndexNotFound() {
}
}

public void testAllowNoIndex() {
OpenPointInTimeRequest request = new OpenPointInTimeRequest("my_index").indicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN)
.keepAlive(TimeValue.timeValueMinutes(between(1, 10)));
String pit = client().execute(OpenPointInTimeAction.INSTANCE, request).actionGet().getPointInTimeId();
ClosePointInTimeResponse closeResp = client().execute(ClosePointInTimeAction.INSTANCE, new ClosePointInTimeRequest(pit))
.actionGet();
assertThat(closeResp.status(), equalTo(RestStatus.OK));
}

public void testCanMatch() throws Exception {
final Settings.Builder settings = Settings.builder()
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, randomIntBetween(5, 10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@
package org.elasticsearch.action.search;

import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.rest.RestStatus;

import java.io.IOException;

import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
import static org.elasticsearch.rest.RestStatus.OK;

public class ClosePointInTimeResponse extends ClearScrollResponse {
public ClosePointInTimeResponse(boolean succeeded, int numFreed) {
super(succeeded, numFreed);
Expand All @@ -20,4 +24,13 @@ public ClosePointInTimeResponse(boolean succeeded, int numFreed) {
public ClosePointInTimeResponse(StreamInput in) throws IOException {
super(in);
}

@Override
public RestStatus status() {
if (isSucceeded() || getNumFreed() > 0) {
return OK;
} else {
return NOT_FOUND;
}
}
}