[ML] When deleting a filter refresh the index immediately (elastic/x-pack-elasticsearch#1587)

Otherwise it's possible that the get_filter endpoint can return a filter that's been
deleted. Although this is the behaviour of the search API, specific metadata
management APIs should provide better guarantees.

Original commit: elastic/x-pack-elasticsearch@818495f176
This commit is contained in:
David Roberts 2017-05-31 14:36:43 +01:00 committed by GitHub
parent 518f8a9120
commit ef25e2b604
2 changed files with 4 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import org.elasticsearch.action.bulk.TransportBulkAction;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.support.master.AcknowledgedRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
@ -182,6 +183,7 @@ public class DeleteFilterAction extends Action<DeleteFilterAction.Request, Delet
DeleteRequest deleteRequest = new DeleteRequest(MlMetaIndex.INDEX_NAME, MlMetaIndex.TYPE, MlFilter.documentId(filterId));
BulkRequest bulkRequest = new BulkRequest();
bulkRequest.add(deleteRequest);
bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
transportAction.execute(bulkRequest, new ActionListener<BulkResponse>() {
@Override
public void onResponse(BulkResponse bulkResponse) {

View File

@ -15,6 +15,7 @@ import org.elasticsearch.action.bulk.TransportBulkAction;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
@ -182,6 +183,7 @@ public class PutFilterAction extends Action<PutFilterAction.Request, PutFilterAc
throw new IllegalStateException("Failed to serialise filter with id [" + filter.getId() + "]", e);
}
BulkRequest bulkRequest = new BulkRequest().add(indexRequest);
bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
transportBulkAction.execute(bulkRequest, new ActionListener<BulkResponse>() {
@Override