API Change: opType=create, closes #107

This commit is contained in:
kimchy 2010-04-04 21:36:07 +03:00
parent ff1fa9daad
commit d0a79223db
1 changed files with 9 additions and 0 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.rest.action.index;
import com.google.common.collect.ImmutableList;
import com.google.inject.Inject;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.index.IndexRequest;
@ -43,6 +44,14 @@ public class RestIndexAction extends BaseRestHandler {
super(settings, client);
controller.registerHandler(POST, "/{index}/{type}", this); // auto id creation
controller.registerHandler(PUT, "/{index}/{type}/{id}", this);
controller.registerHandler(PUT, "/{index}/{type}/{id}/_create", new CreateHandler());
}
final class CreateHandler implements RestHandler {
@Override public void handleRequest(RestRequest request, RestChannel channel) {
request.params().put("op_type", ImmutableList.of("create"));
RestIndexAction.this.handleRequest(request, channel);
}
}
@Override public void handleRequest(final RestRequest request, final RestChannel channel) {