|
|
@@ -26,6 +26,7 @@ import org.elasticsearch.action.CompositeIndicesRequest;
|
|
|
import org.elasticsearch.action.DocWriteRequest;
|
|
|
import org.elasticsearch.action.RoutingMissingException;
|
|
|
import org.elasticsearch.action.support.replication.ReplicatedWriteRequest;
|
|
|
+import org.elasticsearch.action.support.replication.ReplicationRequest;
|
|
|
import org.elasticsearch.client.Requests;
|
|
|
import org.elasticsearch.cluster.metadata.MappingMetaData;
|
|
|
import org.elasticsearch.cluster.metadata.MetaData;
|
|
|
@@ -36,6 +37,7 @@ import org.elasticsearch.common.bytes.BytesReference;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
|
import org.elasticsearch.common.lucene.uid.Versions;
|
|
|
+import org.elasticsearch.common.unit.ByteSizeValue;
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
|
|
@@ -70,6 +72,13 @@ import static org.elasticsearch.action.ValidateActions.addValidationError;
|
|
|
*/
|
|
|
public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implements DocWriteRequest<IndexRequest>, CompositeIndicesRequest {
|
|
|
|
|
|
+ /**
|
|
|
+ * Max length of the source document to include into toString()
|
|
|
+ *
|
|
|
+ * @see ReplicationRequest#createTask(long, java.lang.String, java.lang.String, org.elasticsearch.tasks.TaskId)
|
|
|
+ */
|
|
|
+ static final int MAX_SOURCE_LENGTH_IN_TOSTRING = 2048;
|
|
|
+
|
|
|
private String type;
|
|
|
private String id;
|
|
|
@Nullable
|
|
|
@@ -606,7 +615,12 @@ public class IndexRequest extends ReplicatedWriteRequest<IndexRequest> implement
|
|
|
public String toString() {
|
|
|
String sSource = "_na_";
|
|
|
try {
|
|
|
- sSource = XContentHelper.convertToJson(source, false);
|
|
|
+ if (source.length() > MAX_SOURCE_LENGTH_IN_TOSTRING) {
|
|
|
+ sSource = "n/a, actual length: [" + new ByteSizeValue(source.length()).toString() + "], max length: " +
|
|
|
+ new ByteSizeValue(MAX_SOURCE_LENGTH_IN_TOSTRING).toString();
|
|
|
+ } else {
|
|
|
+ sSource = XContentHelper.convertToJson(source, false);
|
|
|
+ }
|
|
|
} catch (Exception e) {
|
|
|
// ignore
|
|
|
}
|