[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:
parent
518f8a9120
commit
ef25e2b604
|
@ -15,6 +15,7 @@ import org.elasticsearch.action.bulk.TransportBulkAction;
|
||||||
import org.elasticsearch.action.delete.DeleteRequest;
|
import org.elasticsearch.action.delete.DeleteRequest;
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
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.AcknowledgedRequest;
|
||||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
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));
|
DeleteRequest deleteRequest = new DeleteRequest(MlMetaIndex.INDEX_NAME, MlMetaIndex.TYPE, MlFilter.documentId(filterId));
|
||||||
BulkRequest bulkRequest = new BulkRequest();
|
BulkRequest bulkRequest = new BulkRequest();
|
||||||
bulkRequest.add(deleteRequest);
|
bulkRequest.add(deleteRequest);
|
||||||
|
bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
||||||
transportAction.execute(bulkRequest, new ActionListener<BulkResponse>() {
|
transportAction.execute(bulkRequest, new ActionListener<BulkResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(BulkResponse bulkResponse) {
|
public void onResponse(BulkResponse bulkResponse) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.elasticsearch.action.bulk.TransportBulkAction;
|
||||||
import org.elasticsearch.action.index.IndexRequest;
|
import org.elasticsearch.action.index.IndexRequest;
|
||||||
import org.elasticsearch.action.support.ActionFilters;
|
import org.elasticsearch.action.support.ActionFilters;
|
||||||
import org.elasticsearch.action.support.HandledTransportAction;
|
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.AcknowledgedResponse;
|
||||||
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
import org.elasticsearch.action.support.master.MasterNodeOperationRequestBuilder;
|
||||||
import org.elasticsearch.action.support.master.MasterNodeReadRequest;
|
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);
|
throw new IllegalStateException("Failed to serialise filter with id [" + filter.getId() + "]", e);
|
||||||
}
|
}
|
||||||
BulkRequest bulkRequest = new BulkRequest().add(indexRequest);
|
BulkRequest bulkRequest = new BulkRequest().add(indexRequest);
|
||||||
|
bulkRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE);
|
||||||
|
|
||||||
transportBulkAction.execute(bulkRequest, new ActionListener<BulkResponse>() {
|
transportBulkAction.execute(bulkRequest, new ActionListener<BulkResponse>() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue